M5Utility 0.0.3 git rev:e82ed02
|
Button status management. More...
#include <button_status.hpp>
Public Types | |
enum class | button_state_t : uint8_t { state_nochange , state_clicked , state_hold , state_decide_click_count } |
Button status. | |
Public Member Functions | |
Status (const uint16_t hold_ms=500, const uint16_t debounce_ms=10) | |
Constructor. | |
Settings | |
void | setDebounceThreshold (const uint32_t msec) |
Set debounce time(ms) | |
void | setHoldThreshold (const uint32_t msec) |
Set time to be considered hold(ms) | |
uint32_t | getDebounceThreshold (void) const |
Gets the debounce time(ms) | |
uint32_t | getHoldThreshold (void) const |
Gets the time to be considered hold(ms) | |
Button status | |
bool | isPressed (void) const |
Is pressed? | |
bool | isReleased (void) const |
Is released? | |
bool | isHolding (void) const |
Returns true if the button is currently held pressed. | |
bool | wasPressed (void) const |
Returns true if button was pressed. | |
bool | wasReleased (void) const |
Returns true if button was released. | |
bool | wasClicked (void) const |
Returns true when the button is pressed briefly and released. | |
bool | wasHold (void) const |
Returns true when the button has been held pressed for a while. | |
bool | wasSingleClicked (void) const |
Returns true when some time has passed since the button was single clicked. | |
bool | wasDoubleClicked (void) const |
Returns true when some time has passed since the button was double clicked. | |
bool | wasDecideClickCount (void) const |
Returns true when some time has passed since the button was multiple clicked. | |
uint8_t | getClickCount (void) const |
Gets the number of consecutive button clicks. | |
bool | wasChangePressed (void) const |
Has the button press state changed? | |
bool | wasReleasedAfterHold (void) const |
Pressed and released a button for more than the set hold time? | |
bool | wasReleaseFor (const uint32_t ms) const |
Was it pressed for more than the specified time? | |
bool | pressedFor (const uint32_t ms) const |
Is pressed for more than the specified time? | |
bool | releasedFor (const uint32_t ms) const |
Is released for more than the specified time? | |
Status | |
void | setRawState (const uint32_t msec, const bool press) |
void | setState (const uint32_t msec, const button_state_t state) |
button_state_t | getState (void) const |
uint32_t | lastChange (void) const |
uint32_t | getUpdateMsec (void) const |
Button status management.
|
inline |
Constructor.
hold_ms | Time to be considered hold(ms) |
debounce_ms | Debounce time(ms) |