Debouned Pin class.
More...
#include <Pins.h>
|
| DebouncedPin (uint8_t pin, uint8_t initState) |
| Protected constructor used by sub-classes. More...
|
|
void | readPin () |
| Debounce the pin readings to get a stable state of the pin. More...
|
|
int | clicks (uint8_t pressed, uint8_t released) |
| Return the number of clicks. More...
|
|
|
static uint8_t | nextId () |
| Return the next auto-assigned button identifier. More...
|
|
Debouned Pin class.
Manages making reliable readings from an input pin. The readPin() method manages debouncing the pin readings. You cannot use this class directly. Use one of the Button sub-classes instead.
Definition at line 102 of file Pins.h.
◆ DebouncedPin()
able::DebouncedPin::DebouncedPin |
( |
uint8_t |
pin, |
|
|
uint8_t |
initState |
|
) |
| |
|
inlineprotected |
Protected constructor used by sub-classes.
Use a sub-class of this class instead of this class directly.
- Parameters
-
pin | The pin to read from. |
initState | The initial (un-pushed) state of the button. |
Definition at line 155 of file Pins.h.
◆ clicks()
int able::Pin::clicks |
( |
uint8_t |
pressed, |
|
|
uint8_t |
released |
|
) |
| |
|
inlineprotectedinherited |
Return the number of clicks.
- Parameters
-
pressed | The pressed state of a button. |
released | The released state of a button. |
- Returns
- Always no clicks (0) as clicks not supported by default.
Definition at line 83 of file Pins.h.
◆ debounceTime()
static uint8_t able::DebouncedPin::debounceTime |
( |
| ) |
|
|
inlinestatic |
Return the pin debounce time.
- Returns
- The number of milliseconds of debounce time.
Definition at line 200 of file Pins.h.
◆ heldTime()
static uint16_t able::DebouncedPin::heldTime |
( |
| ) |
|
|
inlinestatic |
Return the pin held time.
- Returns
- The number of milliseconds after which a pin is held.
Definition at line 209 of file Pins.h.
◆ idleTime()
static uint32_t able::DebouncedPin::idleTime |
( |
| ) |
|
|
inlinestatic |
Return the pin idle time.
- Returns
- The number of milliseconds after which a pin is idle.
Definition at line 218 of file Pins.h.
◆ nextId()
static uint8_t able::Pin::nextId |
( |
| ) |
|
|
inlinestaticprotectedinherited |
Return the next auto-assigned button identifier.
- Returns
- The next auto-assigned button identifier. Each call increases the auto-assigned identifier.
Definition at line 29 of file Pins.h.
◆ readPin()
void able::DebouncedPin::readPin |
( |
| ) |
|
|
inlineprotected |
Debounce the pin readings to get a stable state of the pin.
In order to save memory, virtual functions are not used (which can consume almost 1K of memory to deal with). Runtime polymorphism is not required, so avoiding virtual functions saves memory.
Definition at line 176 of file Pins.h.
◆ setDebounceTime()
static void able::DebouncedPin::setDebounceTime |
( |
uint8_t |
debounceTime | ) |
|
|
inlinestatic |
Set the debounce time for input pins.
Pins may read noise as buttons are pressed and released. This noise can be registered as multiple button presses in a short time period, confusing your program. The debounce time is the number of milliseconds to wait when a reading changes before using that reading. See https://docs.arduino.cc/built-in-examples/digital/Debounce for details on debounce.
- Parameters
-
debounceTime | The number of milliseconds before a button state change is returned (default 50ms, max 255ms). |
Definition at line 119 of file Pins.h.
◆ setHeldTime()
static void able::DebouncedPin::setHeldTime |
( |
uint16_t |
heldTime | ) |
|
|
inlinestatic |
Set the held time for input pins.
If a button is pressed for longer than this time, it will be held.
- Parameters
-
heldTime | The number of milliseconds for a held state (default 1s). |
Definition at line 129 of file Pins.h.
◆ setIdleTime()
static void able::DebouncedPin::setIdleTime |
( |
uint32_t |
idleTime | ) |
|
|
inlinestatic |
Set the idle time for input pins.
If a button is unpressed for longer than this time, it will be idle.
- Parameters
-
idleTime | The number of milliseconds for an idle state (default 60s). |
Definition at line 139 of file Pins.h.
◆ autoId_
uint8_t able::Pin::autoId_ = 0 |
|
staticprotectedinherited |
Auto-assigned button identifier.
Definition at line 91 of file Pins.h.
◆ currState_
uint8_t able::Pin::currState_ |
|
protectedinherited |
The reading of the pin.
Definition at line 94 of file Pins.h.
◆ debounceTime_
uint8_t able::DebouncedPin::debounceTime_ = 50 |
|
staticprotected |
Time required to debounce all input pins.
Definition at line 226 of file Pins.h.
◆ heldTime_
uint16_t able::DebouncedPin::heldTime_ = 1000 |
|
staticprotected |
Time required for button to be held.
Definition at line 227 of file Pins.h.
◆ idleTime_
uint32_t able::DebouncedPin::idleTime_ = 60000 |
|
staticprotected |
Time required for button to be idle.
Definition at line 228 of file Pins.h.
◆ millisStart_
unsigned long able::DebouncedPin::millisStart_ |
|
protected |
Debounce start timer to handle button transition.
Definition at line 231 of file Pins.h.
◆ pin_
The Arduino pin connected to the button.
Definition at line 93 of file Pins.h.
◆ prevReading_
uint8_t able::DebouncedPin::prevReading_ |
|
protected |
The previous pin reading, to monitor state transitions.
Definition at line 230 of file Pins.h.
The documentation for this class was generated from the following files: