Gray-coded quadrature encoder on two GPIOs, reporting PBL_INPUT_EV_REL steps.
More...
|
| #define | PBL_ROTARY_ENCODER_DEFINE(sym, _name, _a, _b, _code, _steps_per_period, _wakeup_source) |
| | Define and register a rotary encoder.
|
| |
Gray-coded quadrature encoder on two GPIOs, reporting PBL_INPUT_EV_REL steps.
Every edge of either line is decoded in its interrupt, which wakes the system from sleep. Transitions skipping a state are ignored, so contact bounce cancels out.
◆ pbl_rotary_encoder
| struct pbl_rotary_encoder |
| Data Fields |
|
struct pbl_gpio |
a |
Line A, read active when its contact is closed. |
|
struct pbl_gpio |
b |
Line B, read active when its contact is closed. |
|
uint16_t |
code |
PBL_INPUT_EV_REL code, linux,axis. |
|
struct pbl_device |
dev |
Device. |
|
struct pbl_rotary_encoder_state * |
state |
Runtime state. |
|
uint8_t |
steps_per_period |
Steps per Gray code period (1, 2 or 4), rotary-encoder,steps-per-period. |
|
bool |
wakeup_source |
Whether turning it wakes the system from power-off, wakeup-source. |
◆ PBL_ROTARY_ENCODER_DEFINE
| #define PBL_ROTARY_ENCODER_DEFINE |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_a, |
|
|
|
_b, |
|
|
|
_code, |
|
|
|
_steps_per_period, |
|
|
|
_wakeup_source |
|
) |
| |
Value: static struct pbl_rotary_encoder_state sym##_rotary_encoder_state; \
PBL_DEVICE_STATE_DEFINE(sym); \
.dev =
PBL_DEVICE_INIT(sym, _name, pbl_rotary_encoder_init,
nullptr), .a = _a, .b = _b, \
.code = (_code), .steps_per_period = (_steps_per_period), .wakeup_source = (_wakeup_source), \
.state = &sym##_rotary_encoder_state, \
}
#define PBL_DEVICE_INIT(sym, _name, _init, _parent)
Initializer for the struct pbl_device of device instance sym.
Definition device.h:169
Define and register a rotary encoder.
- Parameters
-