pdf-icon

Button Class

wasClicked

Syntax:

bool wasClicked(void)

Description:

  • Determine if the button has been clicked

Parameters:

  • null

Return:

  • bool:
    • true: Button click triggered
    • false: Button click not triggered

wasHold

Syntax:

bool wasHold(void)

Description:

  • Determine if the button is held down, default threshold time is 500ms

Parameters:

  • null

Return:

  • bool:
    • true: Button hold triggered
    • false: Button hold not triggered

wasSingleClicked

Syntax:

bool wasSingleClicked(void)

Description:

  • Determine if the button single click event has occurred

Parameters:

  • null

Return:

  • bool:
    • true: Button single click triggered
    • false: Button single click not triggered

wasDoubleClicked

Syntax:

bool wasDoubleClicked(void)

Description:

  • Determine if the button double click event has occurred

Parameters:

  • null

Return:

  • bool:
    • true: Button double click triggered
    • false: Button double click not triggered

wasDecideClickCount

Syntax:

bool wasDecideClickCount(void)

Description:

  • Trigger button click count, click count can be obtained through getClickCount API

Parameters:

  • null

Return:

  • bool:
    • true: Click count triggered
    • false: Click count not triggered

getClickCount

Syntax:

uint8_t getClickCount(void)

Description:

  • Get the number of button clicks

Parameters:

  • null

Return:

  • uint8_t: Number of clicks

isHolding

Syntax:

bool isHolding(void)

Description:

  • Determine if the button is currently held down

Parameters:

  • null

Return:

  • bool:
    • true: Button is currently in a held-down state
    • false: Button is not currently in a held-down state

wasChangePressed

Syntax:

bool wasChangePressed(void)

Description:

  • Determine if the button state has changed

Parameters:

  • null

Return:

  • bool:
    • true: Button state changed
    • false: No button state change

isPressed

Syntax:

bool isPressed(void)

Description:

  • Determine if the button is pressed

Parameters:

  • null

Return:

  • bool:
    • true: Button is in a pressed state
    • false: Button is not in a pressed state

isReleased

Syntax:

bool isReleased(void)

Description:

  • Determine if the button is in a released state

Parameters:

  • null

Return:

  • bool:
    • true: Button is in a released state
    • false: Button is not in a released state

wasPressed

Syntax:

bool wasPressed(void)

Description:

  • Determine if the button has changed from a released state to a pressed state

Parameters:

  • null

Return:

  • bool:
    • true: Triggered button change from released to pressed state
    • false: No trigger for button change from released to pressed state

wasReleased

Syntax:

bool wasReleased(void)

Description:

  • Determine if the button has changed from a pressed state to a released state

Parameters:

  • null

Return:

  • bool:
    • true: Triggered button change from pressed to released state
    • false: No trigger for button change from pressed to released state

wasReleasedAfterHold

Syntax:

bool wasReleasedAfterHold(void)

Description:

  • Determine if the button was pressed, held for a while, and then changed to a released state

Parameters:

  • null

Return:

  • bool:
    • true: Triggered button pressed, held, then released
    • false: No trigger for button pressed, held, then released

wasReleaseFor

Syntax:

bool wasReleaseFor(std::uint32_t ms)

Description:

  • Determine if the button was pressed and released after exceeding a specified timeout

Parameters:

  • uint32_t ms:
    • Button release timeout time in ms

Return:

  • bool:
    • true: Triggered button release after timeout
    • false: No trigger for button release after timeout

setDebounceThresh

Syntax:

void setDebounceThresh(std::uint32_t msec)

Description:

  • Set the button debounce threshold

Parameters:

  • uint32_t msec:
    • Button debounce time in ms

Return:

  • null

setHoldThresh

Syntax:

void setHoldThresh(std::uint32_t msec)

Description:

  • Set the Hold button trigger time threshold

Parameters:

  • uint32_t msec:
    • Hold trigger threshold in ms

Return:

  • null

setRawState

Syntax:

void setRawState(std::uint32_t msec, bool press);

Description:

  • Pass the current time and button level into the object to update the button event judgment

Parameters:

  • uint32_t msec:

    • Current time in ms
  • bool press:

    • Button pin level

Return:

  • null

setState

Syntax:

void setState(std::uint32_t msec, button_state_t state);

Description:

  • Pass the button state into the object to update the button event judgment

Parameters:

  • uint32_t msec:

    • Current time in ms
  • button_state_t state

    • Button state

Return:

  • null

getState

Syntax:

button_state_t getState(void)

Description:

  • Get the current button state

Parameters:

  • null

Return:

  • button_state_t:
    • state_nochange: No state update
    • state_clicked: Button clicked
    • state_hold: Button held
    • state_decide_click_count: Click count

lastChange

Syntax:

std::uint32_t lastChange(void) 

Description:

  • Get the time of the last state update

Parameters:

  • null

Return:

  • uint32_t: Time of the last state update in ms

getDebounceThresh

Syntax:

std::uint32_t getDebounceThresh(void)

Description:

  • Get the debounce time threshold

Parameters:

  • null

Return:

  • uint32_t: Debounce time threshold in ms

getHoldThresh

Syntax:

std::uint32_t getHoldThresh(void)

Description:

  • Get the current Hold trigger threshold

Parameters:

  • null

Return:

  • uint32_t: Trigger threshold in ms

getUpdateMsec

Syntax:

std::uint32_t getUpdateMsec(void)

Description:

  • Get the time of the last state check execution

Parameters:

  • null

Return:

  • uint32_t: Time of the last state check execution in ms
On This Page