|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Incremental rotary encoder driver. More...
Classes | |
| struct | config |
| Rotary encoder configuration. More... | |
Public Member Functions | |
| rotary_encoder (config cfg) | |
| Creates a rotary encoder and begins tracking. | |
| void | enable_acceleration (uint16_t coeff) |
| Enables acceleration on the encoder. | |
| void | disable_acceleration () |
| Disables acceleration on the encoder. | |
| ~rotary_encoder () | |
| Destroys the encoder. | |
| rotary_encoder (const rotary_encoder &)=delete | |
| rotary_encoder & | operator= (const rotary_encoder &)=delete |
| rotary_encoder (rotary_encoder &&other) noexcept | |
| rotary_encoder & | operator= (rotary_encoder &&other) noexcept |
Static Public Member Functions | |
| static result< rotary_encoder > | make (config cfg) |
| Creates a rotary encoder and begins tracking. | |
Incremental rotary encoder driver.
Tracks rotary encoder shaft rotation and delivers position change deltas via a callback. Supports acceleration for faster turning.
This type is non-copyable and move-only.
Definition at line 40 of file rotary_encoder.hpp.
|
explicit |
Creates a rotary encoder and begins tracking.
| cfg | Encoder configuration. pin_a, pin_b, and callback must be set. The pull mode field defaults to pullup as a convenience; set to gpio::pull_mode::floating when using external pull-ups (recommended), or std::nullopt if the pins have already been configured. |
| std::system_error | on failure. |
| std::system_error | with errc::invalid_arg if pin_a or pin_b is not connected, or callback is not set. |
| idfxx::rotary_encoder::~rotary_encoder | ( | ) |
Destroys the encoder.
Stops tracking and releases resources.
|
delete |
|
noexcept |
| void idfxx::rotary_encoder::disable_acceleration | ( | ) |
Disables acceleration on the encoder.
Position deltas return to reporting single steps regardless of turning speed.
Has no effect on a moved-from encoder.
Enables acceleration on the encoder.
When enabled, faster turning produces larger position deltas. The acceleration coefficient controls the sensitivity.
Has no effect on a moved-from encoder.
| coeff | Acceleration coefficient. Higher values increase acceleration. |
|
static |
Creates a rotary encoder and begins tracking.
| cfg | Encoder configuration. pin_a, pin_b, and callback must be set. The pull mode field defaults to pullup as a convenience; set to gpio::pull_mode::floating when using external pull-ups (recommended), or std::nullopt if the pins have already been configured. |
| invalid_arg | pin_a or pin_b is not connected, or callback is not set. |
|
delete |
|
noexcept |