AbleButtons
V0.4.0
Lightweight button library for Arduino.
Loading...
Searching...
No Matches
Circuits.h
Go to the documentation of this file.
1
/**
2
* @file Circuits.h Definition of Pulldown and pull-up ressitor circuits.
3
*
4
* @copyright Copyright (c) 2022 John Scott.
5
*/
6
#pragma once
7
#include <Arduino.h>
8
9
namespace
able {
10
/**
11
* Resistor circuit base class. All resistor circuits inherit directly/
12
* indirectly from this base class. This class cannot be instantiated
13
* directly but it's sub-classes are used by the compile for compile-time
14
* template specialisation.
15
*/
16
class
Circuit
{
17
private
:
18
//
19
// Creators, copying and assignment (not supported)...
20
//
21
Circuit
() =
delete
;
///< Creating resistor circuits is not supported.
22
Circuit
(
const
Circuit
&) =
delete
;
///< Copying resistor circuits is not supported.
23
Circuit
&operator=(
const
Circuit
&) =
delete
;
///< Assigning resistor circuits is not supported.
24
};
25
26
/**
27
* Declaration of a pulldown resistor circuit connected to the pin. Pulldown
28
* resistors "pull" the pin signal LOW when the button is *not* pressed. When
29
* a button is pressed, the signal changes to HIGH as the button is connected
30
* to a +ve voltage supply, allowing the current to flow to the pin.
31
*/
32
class
PulldownResistorCircuit
:
private
Circuit
{
33
public
:
34
//
35
// Constants...
36
//
37
enum
{
38
PIN_MODE = INPUT,
39
BUTTON_PRESSED = HIGH,
40
BUTTON_RELEASED = LOW
41
};
42
43
private
:
44
//
45
// Creators, copying and assignment (not supported)...
46
//
47
PulldownResistorCircuit
() =
delete
;
///< Creating resistor circuits is not supported.
48
PulldownResistorCircuit
(
const
PulldownResistorCircuit
&) =
delete
;
///< Copying resistor circuits is not supported.
49
PulldownResistorCircuit
&operator=(
const
PulldownResistorCircuit
&) =
delete
;
///< Assigning resistor circuits is not supported.
50
};
51
52
/**
53
* Declaration of a pull-up resistor circuit connected to the pin. Pull-up
54
* resistors "pull" the pin signal HIGH when the button is *not* pressed. When
55
* a button is pressed, the signal changes to LOW as the button is connected
56
* to ground. Using internal pull-up resistors in Arduino microcontrollers
57
* allows a button to be connected to ground without any additional resistors.
58
* This makes them easy to connect up and use.
59
*/
60
class
PullupResistorCircuit
:
private
Circuit
{
61
public
:
62
//
63
// Constants...
64
//
65
enum
{
66
PIN_MODE = INPUT_PULLUP,
67
BUTTON_PRESSED = LOW,
68
BUTTON_RELEASED = HIGH
69
};
70
71
private
:
72
//
73
// Creators, copying and assignment (not supported)...
74
//
75
PullupResistorCircuit
() =
delete
;
///< Creating resistor objects is not supported.
76
PullupResistorCircuit
(
const
PullupResistorCircuit
&) =
delete
;
///< Copying resistor objects is not supported.
77
PullupResistorCircuit
&operator=(
const
PullupResistorCircuit
&) =
delete
;
///< Assignment is not supported.
78
};
79
}
able::Circuit
Resistor circuit base class.
Definition:
Circuits.h:16
able::PulldownResistorCircuit
Declaration of a pulldown resistor circuit connected to the pin.
Definition:
Circuits.h:32
able::PullupResistorCircuit
Declaration of a pull-up resistor circuit connected to the pin.
Definition:
Circuits.h:60
AbleButtons
src
Circuits.h
Generated by
1.9.5