idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::button::config Struct Reference

Button configuration. More...

Public Attributes

idfxx::gpio pin = gpio::nc()
 GPIO pin (required)
 
enum mode mode = mode::poll
 Detection mode.
 
gpio::level pressed_level = gpio::level::low
 GPIO level when pressed.
 
bool enable_pull = true
 Enable internal pull resistor.
 
bool autorepeat = false
 Enable autorepeat (disables long press)
 
std::chrono::microseconds dead_time {std::chrono::milliseconds{50}}
 Debounce delay.
 
std::chrono::microseconds long_press_time {std::chrono::milliseconds{1000}}
 Long press threshold.
 
std::chrono::microseconds autorepeat_timeout {std::chrono::milliseconds{500}}
 Autorepeat start delay.
 
std::chrono::microseconds autorepeat_interval {std::chrono::milliseconds{250}}
 Autorepeat repeat interval.
 
std::chrono::microseconds poll_interval {std::chrono::milliseconds{10}}
 Polling interval.
 
std::move_only_function< void(event_type)> callback
 Event callback (required)
 

Detailed Description

Button configuration.

All fields have sensible defaults, but you must set pin and callback at minimum.

.pin = idfxx::gpio_4,
.callback = [](idfxx::button::event_type ev) {
// handle click
}
},
});
GPIO push-button with debounce, click, long press, and autorepeat support.
Definition button.hpp:38
event_type
Button event type.
Definition button.hpp:62
@ clicked
Short press completed (pressed then released)
constexpr gpio gpio_4
Definition gpio.hpp:812
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120

Definition at line 86 of file button.hpp.

Member Data Documentation

◆ autorepeat

bool idfxx::button::config::autorepeat = false

Enable autorepeat (disables long press)

Definition at line 91 of file button.hpp.

◆ autorepeat_interval

std::chrono::microseconds idfxx::button::config::autorepeat_interval {std::chrono::milliseconds{250}}

Autorepeat repeat interval.

Definition at line 95 of file button.hpp.

◆ autorepeat_timeout

std::chrono::microseconds idfxx::button::config::autorepeat_timeout {std::chrono::milliseconds{500}}

Autorepeat start delay.

Definition at line 94 of file button.hpp.

◆ callback

std::move_only_function<void(event_type)> idfxx::button::config::callback

Event callback (required)

Definition at line 97 of file button.hpp.

◆ dead_time

std::chrono::microseconds idfxx::button::config::dead_time {std::chrono::milliseconds{50}}

Debounce delay.

Definition at line 92 of file button.hpp.

◆ enable_pull

bool idfxx::button::config::enable_pull = true

Enable internal pull resistor.

Definition at line 90 of file button.hpp.

◆ long_press_time

std::chrono::microseconds idfxx::button::config::long_press_time {std::chrono::milliseconds{1000}}

Long press threshold.

Definition at line 93 of file button.hpp.

◆ mode

enum mode idfxx::button::config::mode = mode::poll

Detection mode.

Definition at line 88 of file button.hpp.

◆ pin

idfxx::gpio idfxx::button::config::pin = gpio::nc()

GPIO pin (required)

Definition at line 87 of file button.hpp.

◆ poll_interval

std::chrono::microseconds idfxx::button::config::poll_interval {std::chrono::milliseconds{10}}

Polling interval.

Definition at line 96 of file button.hpp.

◆ pressed_level

gpio::level idfxx::button::config::pressed_level = gpio::level::low

GPIO level when pressed.

Definition at line 89 of file button.hpp.


The documentation for this struct was generated from the following file: