|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
GPIO push-button with debounce, click, long press, and autorepeat support. More...
Classes | |
| struct | config |
| Button configuration. More... | |
Public Types | |
| enum class | mode : int { poll = 0 , interrupt = 1 } |
| Button detection mode. More... | |
| enum class | event_type : int { pressed = 0 , released = 1 , clicked = 2 , long_press = 3 } |
| Button event type. More... | |
Public Member Functions | |
| button (config cfg) | |
| Creates a button and begins monitoring. | |
| ~button () | |
| Destroys the button. | |
| button (const button &)=delete | |
| button & | operator= (const button &)=delete |
| button (button &&other) noexcept | |
| button & | operator= (button &&other) noexcept |
Static Public Member Functions | |
| static result< button > | make (config cfg) |
| Creates a button and begins monitoring. | |
GPIO push-button with debounce, click, long press, and autorepeat support.
Handles push-button input events including press, release, click, long press, and autorepeat. Delivers events via a callback configured at construction time.
This type is non-copyable and move-only.
Definition at line 38 of file button.hpp.
|
strong |
Button event type.
When autorepeat is disabled, the event sequence for a short press is: pressed -> released -> clicked and for a long press: pressed -> long_press -> released
When autorepeat is enabled, long press detection is disabled. Instead, holding the button generates repeated clicked events: pressed -> clicked -> clicked -> ... -> released
| Enumerator | |
|---|---|
| pressed | Button pressed. |
| released | Button released. |
| clicked | Short press completed (pressed then released) |
| long_press | Button held beyond long-press threshold. |
Definition at line 62 of file button.hpp.
|
strong |
Button detection mode.
| Enumerator | |
|---|---|
| poll | Periodic timer polling (default) |
| interrupt | GPIO interrupt with debounce timer. |
Definition at line 44 of file button.hpp.
|
explicit |
Creates a button and begins monitoring.
| cfg | Button configuration. pin and callback must be set. |
| std::system_error | on failure. |
| std::system_error | with errc::invalid_arg if pin is not connected, or callback is not set. |
| idfxx::button::~button | ( | ) |
Destroys the button.
Stops monitoring and releases resources.
|
noexcept |
Creates a button and begins monitoring.
| cfg | Button configuration. pin and callback must be set. |
| invalid_arg | pin is not connected, or callback is not set. |