|
|
hal::gpio::DigitalPin::GPIO | get_button_pin () |
| | Return the pin used for the button.
|
| |
|
int | get_button_pin_RAW () |
| | get the button pin index in system. USE WITH CAUTION
|
| |
|
ButtonStateTy | get_button_state () |
| | Get a copy of the raw internal button state.
|
| |
|
bool | is_button_pressed () |
| |
|
static bool | register_press_locked (const uint32_t pressTime) |
| | Register a button press at pressTime. Call with _buttonStateMutex held. Return true if a new click was counted.
|
| |
|
static bool | register_pending_press_locked () |
| | Register the press deferred by the interrupt, if any. Call with _buttonStateMutex held. Return true if a new click was counted.
|
| |
|
void | button_state_interrupt () |
| |
|
void | init_button_gpio () |
| | Init the button gpio to the set _buttonPin.
|
| |
|
void | set_button_pin (const hal::gpio::DigitalPin::GPIO buttonPin) |
| | Only on system start, set the pin where the button is wired.
|
| |
|
void | handle_events () |
| |
|
void | button_thread () |
| |
| void | init (const bool isSystemStartedFromButton) |
| | Start the button handler.
|
| |
|
void | shutdown () |
| | Deactivate button behavior.
|
| |
|
|
bool | canRunButtonTask = false |
| |
|
hal::gpio::DigitalPin::GPIO | _buttonPin = hal::gpio::DigitalPin::GPIO::gpio3 |
| |
|
hal::gpio::DigitalPin | _buttonGpio (_buttonPin) |
| |
|
static ButtonStateTy | buttonState = ButtonStateTy() |
| | Button pressed states. Shared by the button interrupt, the button thread and the readers (main loop): only access it under _buttonStateMutex.
|
| |
|
static hal::mutex::hal_mutex_t | _buttonStateMutex |
| | Guards buttonState. The interrupt never blocks on it, see button_state_interrupt(). Not recursive.
|
| |
|
static const bool | _isButtonStateMutexInit = (hal::mutex::hal_mutex_init(&_buttonStateMutex), true) |
| | Initialized at program start: the state is read before the button init.
|
| |
|
static std::atomic< bool > | wasButtonPressedDetected {false} |
| | Set by the interrupt on each pin change.
|
| |
|
static std::atomic< bool > | isPressPending {false} |
| | A press seen by the interrupt while buttonState was locked: registered later by the button thread.
|
| |
|
static std::atomic< uint32_t > | pendingPressTime_ms {0} |
| | Time of the pending press, valid when isPressPending is set.
|
| |
|
static constexpr uint32_t | thread_throttle_time_ms = 5 |
| | thread run frequency timing
|
| |
|
static constexpr uint32_t | RELEASE_BETWEEN_CLICKS = 50 |
| | minimum release timing (debounce)
|
| |
|
static constexpr uint32_t | RELEASE_TIMING_CLICKS_MS = 250 |
| | time to release the button after clicks stops
|
| |
|
static constexpr uint32_t | RELEASE_TIMING_HOLDS_MS = 125 |
| | time to release the button after hold stops
|
| |
|
static constexpr uint32_t | HOLD_BUTTON_MIN_MS = 500 |
| | press and hold delay (ms)
|
| |
Handle the button inputs and multiple click detection.