Serial Wombat Arduino Library
|
A class that runs on top of SerialWombaAbstractButton to increment or decrement a variable based on a button. More...
#include <SerialWombatDebouncedInput.h>
Public Member Functions | |
SerialWombatButtonCounter (SerialWombatAbstractButton &serialWombatDebouncedInput) | |
Constructor for SerialWombatButtonCounter. More... | |
void | begin (long *variableToIncrement, long slowIncrement=1, unsigned long slow_mS_betweenIncrements=250, uint16_t slowToMediumTransition_mS=1000, long mediumIncrement=1, unsigned long medium_mS_betweenIncrements=100, uint16_t mediumToFastTransition_mS=1000, long fastIncrement=1, unsigned long fast_mS_betweenIncrements=50) |
bool | update () |
Called periodically to query the SerialWombatDebouncedInput and update the variable. More... | |
Public Attributes | |
long | highLimit = LONG_MAX |
The variable will not increment above this limit. More... | |
long | lowLimit = LONG_MIN |
The variable will not decrement below this limit. More... | |
A class that runs on top of SerialWombaAbstractButton to increment or decrement a variable based on a button.
This class runs on top of a SerialWombaAbstractButton input. It is passed a variable reference in its begin call. The update() method is then called periodically. This method will look at how many times the debounced input has transitioned since the last call, and also if the input is currently pressed and for how long.
A high limit and low limit can be set which keeps the variable from exceeing those bounds.
Times can be specified for button hold that allows the variable to be incremented at varying rates for short, medium, and long holds.
See the example sw4b_ard_Debounce2 distributed with the Serial Wombat Arduino Library and in the video
for an example.
|
inline |
Constructor for SerialWombatButtonCounter.
serialWombatDebouncedInput | A pointer to an already initialized SerialWombatDebouncedInput, SerialWombatMatrixButton or digitally configured SerialWombat18CapTouch |
|
inline |
Initializes the SerialWombatButtonCounter
variableToIncrement | A pointer to a signed long integer |
slowIncrement | the amount that the variable should increment (or decrement if negative) per increment |
slow_mS_betweenIncrements | how often an increment should happen in slow mode |
slowToMediumTransition_mS | how long to stay in slow mode before switching to medium mode |
mediumIncrement | the amount that the variable should increment (or decrement if negative) per increment |
medium_mS_betweenIncrements | how often an increment should happen in medium mode |
mediumToFastTransition_mS | how long after the initail button press start until switching to Fast mode |
fastIncrement | the amount that the variable should increment (or decrement if negative) per increment |
fast_mS_betweenIncrements | how often an increment should happen in fast mode |
|
inline |
Called periodically to query the SerialWombatDebouncedInput and update the variable.
long SerialWombatButtonCounter::highLimit = LONG_MAX |
The variable will not increment above this limit.
long SerialWombatButtonCounter::lowLimit = LONG_MIN |
The variable will not decrement below this limit.