|
Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
Debounced button with edge detection and held-time tracking. More...
Debounced button with edge detection and held-time tracking.
Definition at line 42 of file button.hpp.
#include <button.hpp>
Public Member Functions | |
| Button (const ButtonConfig &config={}) | |
| Construct a released button. | |
| void | set_debounce_ticks (uint32_t ticks) |
| uint32_t | debounce_ticks () const |
| void | update (bool logical_state, uint32_t elapsed_ticks) |
| Feed a reading and the time since the one before. | |
| bool | pressed () const |
| Current debounced state (true = pressed) | |
| bool | raw () const |
| Last raw (unfiltered) reading. | |
| bool | just_pressed () |
| True once after a press. Reading it clears it. | |
| bool | just_released () |
| True once after a release. Reading it clears it. | |
| uint32_t | held_ticks () const |
| Ticks since the press was accepted, while held. | |
| void | reset () |
| Reset all state; the debounce time stays. | |
|
inlineexplicit |
|
inline |
The debounce time, in ticks. A generated Board's buttons start at 0; the app sets it.
Definition at line 51 of file button.hpp.
|
inline |
Definition at line 52 of file button.hpp.
|
inline |
Feed a reading and the time since the one before.
The state changes once readings that differ from it have held for the debounce time: the first differing reading starts the time at 0, and each one after it adds its elapsed ticks. A reading that matches the state starts over.
| logical_state | true = pressed |
| elapsed_ticks | ticks since the previous update |
Definition at line 65 of file button.hpp.
|
inline |
Current debounced state (true = pressed)
Definition at line 91 of file button.hpp.
|
inline |
Last raw (unfiltered) reading.
Definition at line 94 of file button.hpp.
|
inline |
True once after a press. Reading it clears it.
Definition at line 97 of file button.hpp.
|
inline |
True once after a release. Reading it clears it.
Definition at line 104 of file button.hpp.
|
inline |
Ticks since the press was accepted, while held.
0 at the press, then the elapsed ticks of each update while pressed. It keeps its value after the release, until the next press. It stops at the top of its range.
Definition at line 117 of file button.hpp.
|
inline |
Reset all state; the debounce time stays.
Definition at line 120 of file button.hpp.