#include <AH/Hardware/IncrementDecrementButtons.hpp>
A class for buttons that increment and decrement some counter or setting.
It behaves the same way as a computer keyboard: when you press the increment (decrement) button, it increments (decrements) the counter once. If you keep on pressing it for longer than a certain threshold, it keeps on incrementing (decrementing) at a faster rate, until you release it.
If both the increment and the decrement button are pressed at once, it resets the counter.
Definition at line 25 of file IncrementDecrementButtons.hpp.
Public Types | |
enum | State { Nothing = 0 , IncrementShort , IncrementLong , IncrementHold , DecrementShort , DecrementLong , DecrementHold , Reset } |
An enumeration of the different actions to be performed by the counter. More... | |
Public Member Functions | |
IncrementDecrementButtons (const Button &incrementButton, const Button &decrementButton) | |
Create a IncrementDecrementButtons object. More... | |
void | begin () |
State | update () |
Update and return the state of the increment/decrement button. More... | |
State | getState () const |
Return the state of the increment/decrement button without updating it. More... | |
void | invert () |
Protected Member Functions | |
State | updateImplementation () |
Private Types | |
enum | { Initial , LongPress , AfterReset } |
Private Attributes | |
Button | incrementButton |
Button | decrementButton |
enum IncrementDecrementButtons:: { ... } | longPressState = Initial |
unsigned long | longPressRepeat |
State | state = Nothing |
enum State |
An enumeration of the different actions to be performed by the counter.
Definition at line 52 of file IncrementDecrementButtons.hpp.
|
private |
Enumerator | |
---|---|
Initial | |
LongPress | |
AfterReset |
Definition at line 89 of file IncrementDecrementButtons.hpp.
|
inline |
Create a IncrementDecrementButtons object.
incrementButton | The button to increment the counter. The button is copied. |
decrementButton | The button to decrement the counter. The button is copied. |
Definition at line 37 of file IncrementDecrementButtons.hpp.
|
inline |
Definition at line 42 of file IncrementDecrementButtons.hpp.
|
inline |
Update and return the state of the increment/decrement button.
Definition at line 66 of file IncrementDecrementButtons.hpp.
|
inline |
Return the state of the increment/decrement button without updating it.
Returns the same value as the last update call.
Definition at line 74 of file IncrementDecrementButtons.hpp.
|
inline |
Definition at line 77 of file IncrementDecrementButtons.hpp.
|
protected |
Definition at line 8 of file IncrementDecrementButtons.cpp.
|
private |
Definition at line 86 of file IncrementDecrementButtons.hpp.
|
private |
Definition at line 87 of file IncrementDecrementButtons.hpp.
enum { ... } longPressState |
|
private |
Definition at line 94 of file IncrementDecrementButtons.hpp.
Definition at line 95 of file IncrementDecrementButtons.hpp.