|
Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
Debounced button with edge detection and held-duration tracking. More...
#include <button.hpp>
Public Member Functions | |
| Button (const ButtonConfig &config={}) | |
| void | update (bool logical_state) |
| Feed a new logical GPIO reading. | |
| bool | pressed () const |
| Current debounced state (true = pressed) | |
| bool | raw () const |
| Last raw (unfiltered) reading. | |
| bool | just_pressed () |
| True if button was just pressed (rising edge) | |
| bool | just_released () |
| True if button was just released (falling edge) | |
| uint32_t | held_count () const |
| Ticks the button has been held down. | |
| void | reset () |
| Reset all state. | |
Debounced button with edge detection and held-duration tracking.
Definition at line 35 of file button.hpp.
|
inlineexplicit |
Definition at line 37 of file button.hpp.
|
inline |
Ticks the button has been held down.
Returns raw tick count (caller knows update rate). Resets to 0 on press, continues counting while held.
Definition at line 115 of file button.hpp.
|
inline |
True if button was just pressed (rising edge)
Resets on read — call once per update cycle.
Definition at line 92 of file button.hpp.
|
inline |
True if button was just released (falling edge)
Resets on read — call once per update cycle.
Definition at line 103 of file button.hpp.
|
inline |
Current debounced state (true = pressed)
Definition at line 82 of file button.hpp.
|
inline |
Last raw (unfiltered) reading.
Definition at line 85 of file button.hpp.
|
inline |
Reset all state.
Definition at line 118 of file button.hpp.
|
inline |
Feed a new logical GPIO reading.
Call once per update cycle. Debounce: the stable state only changes when debounce_count consecutive identical readings are seen.
| logical_state | true = pressed (Gpio::read already handles active_low) |
Definition at line 51 of file button.hpp.
Referenced by sbl::button::read().