38 #ifndef ROTARY_ENCODER_H
39 #define ROTARY_ENCODER_H
44 #include "freertos/FreeRTOS.h"
45 #include "freertos/queue.h"
47 #include "driver/gpio.h"
53 typedef int32_t rotary_encoder_position_t;
61 ROTARY_ENCODER_DIRECTION_CLOCKWISE,
62 ROTARY_ENCODER_DIRECTION_COUNTER_CLOCKWISE,
68 typedef uint8_t table_row_t[TABLE_COLS];
172 #endif // ROTARY_ENCODER_H
volatile rotary_encoder_state_t state
Device state.
Definition: rotary_encoder.h:91
esp_err_t rotary_encoder_enable_half_steps(rotary_encoder_info_t *info, bool enable)
Enable half-stepping mode. This generates twice as many counted steps per rotation.
Definition: rotary_encoder.c:245
uint8_t table_state
Internal state.
Definition: rotary_encoder.h:90
Struct represents the current state of the device in terms of incremental position and direction of l...
Definition: rotary_encoder.h:74
const table_row_t * table
Pointer to active state transition table.
Definition: rotary_encoder.h:89
esp_err_t rotary_encoder_init(rotary_encoder_info_t *info, gpio_num_t pin_a, gpio_num_t pin_b)
Initialise the rotary encoder device with the specified GPIO pins and full step increments. This function will set up the GPIOs as needed, Note: this function assumes that gpio_install_isr_service(0) has already been called.
Definition: rotary_encoder.c:210
rotary_encoder_direction_t
Enum representing the direction of rotation.
Definition: rotary_encoder.h:58
esp_err_t rotary_encoder_reset(rotary_encoder_info_t *info)
Reset the current position of the rotary encoder to zero.
Definition: rotary_encoder.c:331
rotary_encoder_direction_t direction
Direction of last movement. Set to NOT_SET on reset.
Definition: rotary_encoder.h:77
esp_err_t rotary_encoder_set_queue(rotary_encoder_info_t *info, QueueHandle_t queue)
Set the driver to use the specified queue as an event queue. It is recommended that a queue construct...
Definition: rotary_encoder.c:299
rotary_encoder_position_t position
Numerical position since reset. This value increments on clockwise rotation, and decrements on counte...
Definition: rotary_encoder.h:76
gpio_num_t pin_b
GPIO for Signal B from the rotary encoder device.
Definition: rotary_encoder.h:87
esp_err_t rotary_encoder_flip_direction(rotary_encoder_info_t *info)
Reverse (flip) the sense of the direction. Use this if clockwise/counterclockwise are not what you ex...
Definition: rotary_encoder.c:261
esp_err_t rotary_encoder_uninit(rotary_encoder_info_t *info)
Remove the interrupt handlers installed by rotary_encoder_init. Note: GPIOs will be left in the state...
Definition: rotary_encoder.c:278
Direction not yet known (stationary since reset)
Definition: rotary_encoder.h:60
rotary_encoder_state_t state
The device state corresponding to this event.
Definition: rotary_encoder.h:99
Struct carries all the information needed by this driver to manage the rotary encoder device...
Definition: rotary_encoder.h:84
QueueHandle_t rotary_encoder_create_queue(void)
Create a queue handle suitable for use as an event queue.
Definition: rotary_encoder.c:294
gpio_num_t pin_a
GPIO for Signal A from the rotary encoder device.
Definition: rotary_encoder.h:86
QueueHandle_t queue
Handle for event queue, created by rotary_encoder_create_queue.
Definition: rotary_encoder.h:88
esp_err_t rotary_encoder_get_state(const rotary_encoder_info_t *info, rotary_encoder_state_t *state)
Get the current position of the rotary encoder.
Definition: rotary_encoder.c:314
Struct represents a queued event, used to communicate current position to a waiting task...
Definition: rotary_encoder.h:97