Pin class that counts state changes within a time-period.
More...
#include <Pins.h>
|
int | clicks (uint8_t pressed, uint8_t released) const |
| Return the number of clicks. More...
|
|
|
| DoubleClickerPin (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...
|
|
Pin class that counts state changes within a time-period.
This enables it to identify double-clicks.
Definition at line 312 of file Pins.h.
◆ DoubleClickerPin()
able::DoubleClickerPin::DoubleClickerPin |
( |
uint8_t |
pin, |
|
|
uint8_t |
initState |
|
) |
| |
|
inlineprotected |
Protected constructor used by sub-classes.
Use a Button 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 341 of file Pins.h.
◆ clicks() [1/2]
int able::ClickerPin::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 single clicks (1) as double-clicks not supported.
Definition at line 297 of file Pins.h.
◆ clicks() [2/2]
int able::DoubleClickerPin::clicks |
( |
uint8_t |
pressed, |
|
|
uint8_t |
released |
|
) |
| const |
|
inline |
Return the number of clicks.
- Parameters
-
pressed | The pressed state of a button. |
released | The released state of a button. |
- Returns
- no click (0), single click (1) or double-click (2).
Definition at line 373 of file Pins.h.
◆ clickTime()
static uint16_t able::DoubleClickerPin::clickTime |
( |
| ) |
|
|
inlinestatic |
Return the double-click time.
- Returns
- The number of milliseconds of debounce time.
Definition at line 361 of file Pins.h.
◆ debounceTime()
static uint8_t able::DebouncedPin::debounceTime |
( |
| ) |
|
|
inlinestaticinherited |
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 |
( |
| ) |
|
|
inlinestaticinherited |
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 |
( |
| ) |
|
|
inlinestaticinherited |
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::DoubleClickerPin::readPin |
( |
| ) |
|
|
inlineprotected |
Debounce the pin readings to get a stable state of the pin.
When the state changes, remember the previous state so clicks (press then release can be identified). Calls DebouncedPin::readPin() and monitors for a change in debounced state, remembering the previous state.
Definition at line 392 of file Pins.h.
◆ setClickTime()
static void able::DoubleClickerPin::setClickTime |
( |
uint16_t |
clickTime | ) |
|
|
inlinestatic |
Set the click time for input pins.
If a button is clicked again within this millisecond value, it will be counted, else the count resets. Allows tracking of double-clicks within the specified time.
- Parameters
-
clickTime | The number of milliseconds between clicks. |
Definition at line 325 of file Pins.h.
◆ setDebounceTime()
static void able::DebouncedPin::setDebounceTime |
( |
uint8_t |
debounceTime | ) |
|
|
inlinestaticinherited |
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 | ) |
|
|
inlinestaticinherited |
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 | ) |
|
|
inlinestaticinherited |
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.
◆ clickTime_
uint16_t able::DoubleClickerPin::clickTime_ = 250 |
|
staticprotected |
Time required for button to be double-clicked.
Definition at line 415 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 |
|
staticprotectedinherited |
Time required to debounce all input pins.
Definition at line 226 of file Pins.h.
◆ heldTime_
uint16_t able::DebouncedPin::heldTime_ = 1000 |
|
staticprotectedinherited |
Time required for button to be held.
Definition at line 227 of file Pins.h.
◆ idleTime_
uint32_t able::DebouncedPin::idleTime_ = 60000 |
|
staticprotectedinherited |
Time required for button to be idle.
Definition at line 228 of file Pins.h.
◆ millisStart_
unsigned long able::DebouncedPin::millisStart_ |
|
protectedinherited |
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.
◆ prevMillis_
unsigned long able::DoubleClickerPin::prevMillis_ |
|
protected |
Previous millisecond count from last state change.
Definition at line 418 of file Pins.h.
◆ prevReading_
uint8_t able::DebouncedPin::prevReading_ |
|
protectedinherited |
The previous pin reading, to monitor state transitions.
Definition at line 230 of file Pins.h.
◆ prevState_
uint8_t able::ClickerPin::prevState_ |
|
protectedinherited |
Previous debounced reading of the pin.
Definition at line 305 of file Pins.h.
◆ stateCount_
uint8_t able::DoubleClickerPin::stateCount_ |
|
protected |
Count changes in state within double-click time.
Definition at line 417 of file Pins.h.
The documentation for this class was generated from the following files: