Текст оригинала на английском языке находится [[https://docs.m5stack.com/en/arduino/m5unified/button_class|здесь]]
====== M5Unified Button Class ======
===== wasClicked =====
**Синтаксис:**
bool wasClicked(void)
**Описание:**
* Determine if the button has been clicked
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Button click triggered
* false: Button click not triggered
===== wasHold =====
**Синтаксис:**
bool wasHold(void)
**Описание:**
* Determine if the button is held down, default threshold time is 500ms
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Button hold triggered
* false: Button hold not triggered
===== wasSingleClicked =====
**Синтаксис:**
bool wasSingleClicked(void)
**Описание:**
* Determine if the button single click event has occurred
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Button single click triggered
* false: Button single click not triggered
===== wasDoubleClicked =====
**Синтаксис:**
bool wasDoubleClicked(void)
**Описание:**
* Determine if the button double click event has occurred
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Button double click triggered
* false: Button double click not triggered
===== wasDecideClickCount =====
**Синтаксис:**
bool wasDecideClickCount(void)
**Описание:**
* Trigger button click count, click count can be obtained through getClickCount API
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Click count triggered
* false: Click count not triggered
===== getClickCount =====
**Синтаксис:**
uint8_t getClickCount(void)
**Описание:**
* Get the number of button clicks
**Параметры:**
* null
**Возвращает:**
* uint8_t: Number of clicks
===== isHolding =====
**Синтаксис:**
bool isHolding(void)
**Описание:**
* Determine if the button is currently held down
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Button is currently in a held-down state
* false: Button is not currently in a held-down state
===== wasChangePressed =====
**Синтаксис:**
bool wasChangePressed(void)
**Описание:**
* Determine if the button state has changed
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Button state changed
* false: No button state change
===== isPressed =====
**Синтаксис:**
bool isPressed(void)
**Описание:**
* Determine if the button is pressed
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Button is in a pressed state
* false: Button is not in a pressed state
===== isReleased =====
**Синтаксис:**
bool isReleased(void)
**Описание:**
* Determine if the button is in a released state
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Button is in a released state
* false: Button is not in a released state
===== wasPressed =====
**Синтаксис:**
bool wasPressed(void)
**Описание:**
* Determine if the button has changed from a released state to a pressed state
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Triggered button change from released to pressed state
* false: No trigger for button change from released to pressed state
===== wasReleased =====
**Синтаксис:**
bool wasReleased(void)
**Описание:**
* Determine if the button has changed from a pressed state to a released state
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Triggered button change from pressed to released state
* false: No trigger for button change from pressed to released state
===== wasReleasedAfterHold =====
**Синтаксис:**
bool wasReleasedAfterHold(void)
**Описание:**
* Determine if the button was pressed, held for a while, and then changed to a released state
**Параметры:**
* null
**Возвращает:**
* bool:
* true: Triggered button pressed, held, then released
* false: No trigger for button pressed, held, then released
===== wasReleaseFor =====
**Синтаксис:**
bool wasReleaseFor(std::uint32_t ms)
**Описание:**
* Determine if the button was pressed and released after exceeding a specified timeout
**Параметры:**
* uint32_t ms:
* Button release timeout time in ms
**Возвращает:**
* bool:
* true: Triggered button release after timeout
* false: No trigger for button release after timeout
===== setDebounceThresh =====
**Синтаксис:**
void setDebounceThresh(std::uint32_t msec)
**Описание:**
* Set the button debounce threshold
**Параметры:**
* uint32_t msec:
* Button debounce time in ms
**Возвращает:**
* null
===== setHoldThresh =====
**Синтаксис:**
void setHoldThresh(std::uint32_t msec)
**Описание:**
* Set the Hold button trigger time threshold
**Параметры:**
* uint32_t msec:
* Hold trigger threshold in ms
**Возвращает:**
* null
===== setRawState =====
**Синтаксис:**
void setRawState(std::uint32_t msec, bool press);
**Описание:**
* Pass the current time and button level into the object to update the button event judgment
**Параметры:**
* uint32_t msec:
* Current time in ms
* bool press:
* Button pin level
**Возвращает:**
* null
===== setState =====
**Синтаксис:**
void setState(std::uint32_t msec, button_state_t state);
**Описание:**
* Pass the button state into the object to update the button event judgment
**Параметры:**
* uint32_t msec:
* Current time in ms
* button_state_t state
* Button state
**Возвращает:**
* null
===== getState =====
**Синтаксис:**
button_state_t getState(void)
**Описание:**
* Get the current button state
**Параметры:**
* null
**Возвращает:**
* button_state_t:
* state_nochange: No state update
* state_clicked: Button clicked
* state_hold: Button held
* state_decide_click_count: Click count
===== lastChange =====
**Синтаксис:**
std::uint32_t lastChange(void)
**Описание:**
* Get the time of the last state update
**Параметры:**
* null
**Возвращает:**
* uint32_t: Time of the last state update in ms
===== getDebounceThresh =====
**Синтаксис:**
std::uint32_t getDebounceThresh(void)
**Описание:**
* Get the debounce time threshold
**Параметры:**
* null
**Возвращает:**
* uint32_t: Debounce time threshold in ms
===== getHoldThresh =====
**Синтаксис:**
std::uint32_t getHoldThresh(void)
**Описание:**
* Get the current Hold trigger threshold
**Параметры:**
* null
**Возвращает:**
* uint32_t: Trigger threshold in ms
===== getUpdateMsec =====
**Синтаксис:**
std::uint32_t getUpdateMsec(void)
**Описание:**
* Get the time of the last state check execution
**Параметры:**
* null
**Возвращает:**
* uint32_t: Time of the last state check execution in ms
----
{{section>.includes#articles-footer&noheader}}