#include <AH/Hardware/MultiPurposeButton.hpp>
Class for detecting short/long button presses and double clicks.
Definition at line 12 of file MultiPurposeButton.hpp.
Public Types | |
enum | Event { None , PressStart , ShortPressRelease , LongPress , LongPressRelease , MultiPress , MultiPressDone } |
Public Member Functions | |
MultiPurposeButton (pin_t pin) | |
void | begin () |
Event | update () |
Read the button state and return the Event (if any). | |
uint8_t | getMultiPressCount () const |
Get the number of times the button was pressed in quick succession (after MultiPressDone), this is the final count. | |
uint8_t | getCurrentMultiPressCount () const |
Get the number of times the button was pressed in quick succession, while the button is being pressed (before MultiPressDone). | |
unsigned long | getLongPressDelay () const |
Get the number of milliseconds after which a press is considered a long press. | |
void | setLongPressDelay (unsigned long longPressDelay) |
Set the number of milliseconds after which a press is considered a long press. | |
unsigned long | getMultiPressDelay () const |
Get the number of milliseconds between multipresses. | |
void | setMultiPressDelay (unsigned long multiPressDelay) |
Set the number of milliseconds between multipresses. | |
unsigned long | previousBounceTime () const |
unsigned long | stableTime () const |
unsigned long | stableTime (unsigned long now) const |
unsigned long | getPressedTime () const |
Get the number of milliseconds the button has been pressed for. | |
unsigned long | getLongPressedTime () const |
Get the number of milliseconds the button has been pressed for. | |
Button::State | getButtonState () const |
void | invert () |
Static Public Member Functions | |
static FlashString_t | getName (Event ev) |
Return the name of the event as a string. | |
Protected Attributes | |
Button | button |
unsigned long | longPressDelay = 1000 |
unsigned long | multiPressDelay = 400 |
bool | longPress = false |
uint8_t | multiPressCountNew = 0 |
uint8_t | multiPressCount = 0 |
Definition at line 16 of file MultiPurposeButton.hpp.
|
inline |
Definition at line 14 of file MultiPurposeButton.hpp.
|
inline |
Definition at line 29 of file MultiPurposeButton.hpp.
|
inline |
Read the button state and return the Event (if any).
Definition at line 32 of file MultiPurposeButton.hpp.
|
inline |
Get the number of times the button was pressed in quick succession (after MultiPressDone), this is the final count.
Definition at line 65 of file MultiPurposeButton.hpp.
|
inline |
Get the number of times the button was pressed in quick succession, while the button is being pressed (before MultiPressDone).
The count could still increase if the user keeps on pressing the button.
Definition at line 69 of file MultiPurposeButton.hpp.
Get the number of milliseconds after which a press is considered a long press.
Definition at line 73 of file MultiPurposeButton.hpp.
Set the number of milliseconds after which a press is considered a long press.
Definition at line 76 of file MultiPurposeButton.hpp.
Get the number of milliseconds between multipresses.
Definition at line 81 of file MultiPurposeButton.hpp.
Set the number of milliseconds between multipresses.
Definition at line 83 of file MultiPurposeButton.hpp.
Definition at line 88 of file MultiPurposeButton.hpp.
Definition at line 92 of file MultiPurposeButton.hpp.
Definition at line 94 of file MultiPurposeButton.hpp.
Get the number of milliseconds the button has been pressed for.
Returns 0 if the button is not currently pressed.
Definition at line 100 of file MultiPurposeButton.hpp.
Get the number of milliseconds the button has been pressed for.
Returns 0 if the button is not currently pressed or if the current press is not a long press (yet).
Definition at line 106 of file MultiPurposeButton.hpp.
|
inlinestatic |
Return the name of the event as a string.
Definition at line 111 of file MultiPurposeButton.hpp.
|
inline |
Definition at line 114 of file MultiPurposeButton.hpp.
|
inline |
Definition at line 116 of file MultiPurposeButton.hpp.
|
protected |
Definition at line 119 of file MultiPurposeButton.hpp.
Definition at line 120 of file MultiPurposeButton.hpp.
Definition at line 121 of file MultiPurposeButton.hpp.
Definition at line 122 of file MultiPurposeButton.hpp.
|
protected |
Definition at line 123 of file MultiPurposeButton.hpp.
|
protected |
Definition at line 124 of file MultiPurposeButton.hpp.