M5Utility 0.0.3 git rev:e82ed02
Loading...
Searching...
No Matches
m5::utility::button::Status Class Reference

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
 

Detailed Description

Button status management.

Note
Class compatible with Button_Class in M5Unified

Constructor & Destructor Documentation

◆ Status()

m5::utility::button::Status::Status ( const uint16_t hold_ms = 500,
const uint16_t debounce_ms = 10 )
inline

Constructor.

Parameters
hold_msTime to be considered hold(ms)
debounce_msDebounce time(ms)