Files
MTGcompanion/main/encoder.h

51 lines
1013 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 Return current accumulator without resetting.
*/
int32_t encoder_get_delta(void);
/**
* @brief True if the push button was pressed since last poll.
*/
bool encoder_button_pressed(void);
/**
* @brief Clear the button-pressed flag.
*/
void encoder_clear_button(void);
#ifdef __cplusplus
}
#endif