Files
MTGcompanion/main/encoder.h
2026-09-12 03:40:10 +02:00

46 lines
979 B
C

/*
* MTG RFID Companion - EC11 rotary encoder driver
*
* Phase 7 Step 7.1: Interrupt-driven quadrature decode on GPIO CLK/DT with
* a debounced push button on SW (active low).
*/
#pragma once
#include "esp_err.h"
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Install GPIO ISR service and configure encoder pins.
*/
esp_err_t encoder_init(void);
/**
* @brief True if the encoder has rotated since the last check.
*/
bool encoder_has_delta(void);
/**
* @brief Return the accumulated rotation steps and reset it.
* Positive = clockwise, negative = counter-clockwise (configurable).
*/
int32_t encoder_get_delta_and_reset(void);
/**
* @brief Get current quadrature steps per mechanical detent tick (2 or 4).
*/
int8_t encoder_get_steps_per_detent(void);
/**
* @brief Set quadrature steps per mechanical detent tick (2 or 4).
*/
void encoder_set_steps_per_detent(int8_t steps);
#ifdef __cplusplus
}
#endif