librfn
An ad-hoc utility library
Data Structures | Macros | Typedefs | Functions
Rotary encoder

Utility functions to decode signals from a 2-bit rotary encoder. More...

Data Structures

struct  rotenc
 Rotary encoder click counts and state tracking. More...
 

Macros

#define ROTENC_VAR_INIT   { 0 }
 Static initializer for a rotary encoder. More...
 

Typedefs

typedef struct rotenc rotenc_t
 Rotary encoder click counts and state tracking. More...
 

Functions

void rotenc_decode (rotenc_t *r, uint8_t state)
 Handle a state update. More...
 
uint16_t rotenc_count14 (rotenc_t *r)
 Read a 14-bit count of the current knob position. More...
 

Detailed Description

Utility functions to decode signals from a 2-bit rotary encoder.

Macro Definition Documentation

#define ROTENC_VAR_INIT   { 0 }

Static initializer for a rotary encoder.

Definition at line 39 of file rotenc.h.

Typedef Documentation

typedef struct rotenc rotenc_t

Rotary encoder click counts and state tracking.

Function Documentation

uint16_t rotenc_count14 ( rotenc_t r)

Read a 14-bit count of the current knob position.

Suitable for higher resolution devices.

Definition at line 45 of file rotenc.c.

void rotenc_decode ( rotenc_t r,
uint8_t  state 
)

Handle a state update.

It is safe to call this function when there has not actually been a change of state, this allows it to be used as a polling function.

No external debounce is required.

Definition at line 16 of file rotenc.c.