Core Button class.
More...
#include <Button.h>
|
enum | { BUTTON_PRESSED = Circuit::BUTTON_PRESSED
, BUTTON_RELEASED = Circuit::BUTTON_RELEASED
} |
|
|
static uint8_t | nextId () |
| Return the next auto-assigned button identifier. More...
|
|
template<typename
Circuit, typename
Pin>
class able::Button< Circuit, Pin >
Core Button class.
It supports pulldown and pull-up resistor circuits specified using the Circuit template parameter and different pin features using the Pin template parameter.
- Parameters
-
Definition at line 22 of file Button.h.
◆ anonymous enum
◆ Button()
Create a button on the specified pin.
- Parameters
-
pin | The pin connected to the button. |
Definition at line 42 of file Button.h.
◆ begin()
Initialise the button.
Called from setup() of an Arduino program.
Definition at line 60 of file Button.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.
◆ handle()
Handle the button.
Called from loop() of an Arduino program.
Definition at line 67 of file Button.h.
◆ isClicked()
Determine if the button is clicked.
Clicks are registered as a press then release. If the ClickerPin (or subclass) is used, the button returns the click state, otherwise the compile will fail with errors.
- Returns
- True if clicked else false.
Definition at line 156 of file Button.h.
◆ isDoubleClicked()
Determine if the button is double-clicked.
Double-clicks are registered as two clicks within the double-click time. If the DoubleClickPin is used, the button returns the double-click state, otherwise the compile will fail with errors.
- Returns
- True if double-clicked else false.
Definition at line 182 of file Button.h.
◆ isHeld()
Determine if the button is currently held down.
- Returns
- True if held, else false.
Definition at line 136 of file Button.h.
◆ isIdle()
Determine if the button is currently idle (unpressed for a "long" time).
- Returns
- True if idle, else false.
Definition at line 145 of file Button.h.
◆ isPressed()
Determine if the button is currently pressed.
- Returns
- True if pressed, else false.
Definition at line 127 of file Button.h.
◆ isSingleClicked()
Determine if the button is exclusively single-clicked.
Clicks are registered as a press then release. Single-clicks wait until any double-click time has passed to ensure it's exclusively a click and not the first click in a double-click sequence. If the DoubleClickerPin is used, the button returns the single-click state, otherwise the compile will fail with errors.
- Returns
- True if exclusively clicked else false.
Definition at line 170 of file Button.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::Pin::readPin |
( |
| ) |
|
|
inlineprotectedinherited |
Read the pin directly.
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 66 of file Pins.h.
◆ resetClicked()
Reset the clicked state of the button, returning what is was.
This allows the click state to be effectively read once so that a clicked state only triggers something once, when checked. For example toggling something on/off when the button is clicked. For buttons that don't support clicking, the compile will fail with errors.
- Returns
- True if the button was clicked, else false.
Definition at line 80 of file Button.h.
◆ resetDoubleClicked()
Reset the double-clicked state of the button, returning what is was.
This allows the double-click state to be effectively read once so that a double-clicked state only triggers something once, when checked. For example toggling something on/off when the button is double- clicked. For buttons that don't support double-clicking, the compile will fail with errors.
- Returns
- True if the button was double-clicked, else false.
Definition at line 111 of file Button.h.
◆ resetSingleClicked()
Reset the clicked state of the button, returning what is was.
This allows the click state to be effectively read once so that a clicked state only triggers something once, when checked. For example toggling something on/off when the button is clicked. For buttons that don't support clicking, the compile will fail with errors.
- Returns
- True if the button was clicked, else false.
Definition at line 95 of file Button.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.
◆ pin_
The Arduino pin connected to the button.
Definition at line 93 of file Pins.h.
The documentation for this class was generated from the following file: