uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
|
Implementation of a 3- or 4-phase rotary encoder with (optional) momentary switch. More...
Functions | |
static void | advance_3phase_encoder (struct encoder_state *const state, const bool inputA, const bool inputB) |
Interprets encoder inputs and updates the supplied encoder state. More... | |
static void | advance_4phase_encoder (struct encoder_state *const state, const bool inputA, const bool inputB) |
Interprets encoder inputs and updates the supplied encoder state. More... | |
void | init_encoder (struct encoder *const encoder) |
Initializes the encoder. More... | |
enum encoder_action | poll_encoder (struct encoder *const encoder) |
Polls the encoder inputs. More... | |
Implementation of a 3- or 4-phase rotary encoder with (optional) momentary switch.
|
static |
Interprets encoder inputs and updates the supplied encoder state.
This helper function implements a 3-phase rotary encoder "protocol".
state | the state of the encoder |
inputA | the current input on the encoder's A terminal |
inputB | the current input on the encoder's B terminal |
|
static |
Interprets encoder inputs and updates the supplied encoder state.
This helper function implements a 4-phase rotary encoder "protocol".
state | the state of the encoder |
inputA | the current input on the encoder's A terminal |
inputB | the current input on the encoder's B terminal |
void init_encoder | ( | struct encoder * | encoder | ) |
Initializes the encoder.
Configures GPIO pins and registers the callbacks.
encoder | the encoder instance to initialize |
enum encoder_action poll_encoder | ( | struct encoder * | encoder | ) |
Polls the encoder inputs.
Checks if the encoder was rotated or pushed and updates the saved state. This function also executes registered callbacks, so you can define those in the encoder configuration passed to init_encoder and register this function in a background task, discarding its return value.
encoder | the encoder to poll |