PebbleOS v4.47.0-1075-g013613c8a
Loading...
Searching...
No Matches
Rotary encoder

Gray-coded quadrature encoder on two GPIOs, reporting PBL_INPUT_EV_REL steps. More...

Data Structures

struct  pbl_rotary_encoder
 Rotary encoder. More...
 

Macros

#define PBL_ROTARY_ENCODER_DEFINE(sym, _name, _a, _b, _code, _steps_per_period, _wakeup_source)
 Define and register a rotary encoder.
 

Detailed Description

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.


Data Structure Documentation

◆ pbl_rotary_encoder

struct pbl_rotary_encoder

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.

Macro Definition Documentation

◆ 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); \
PBL_DEVICE_INSTANCE_DEV(sym, struct pbl_rotary_encoder) { \
.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
Rotary encoder.
Definition rotary_encoder.h:29

Define and register a rotary encoder.

Parameters
symSymbol of the struct pbl_rotary_encoder.
_nameDevice name.
_aLine A, a PBL_GPIO.
_bLine B, a PBL_GPIO.
_codePBL_INPUT_EV_REL code.
_steps_per_periodSteps per Gray code period.
_wakeup_sourceWhether turning it wakes the system from power-off.