feat: added status enumeration

This commit is contained in:
aZholtikov committed 2026-10-29 08:11:45 +03:00
1 parent d9872c8e94
commit fb87e98189
6 files changed
+91 -69

No files matched your search

+25 -5
View File
@@ -20,6 +20,8 @@
*
* @note All public functions require a valid handle pointer obtained through zh_encoder_init().
* @note Rotation and button events are posted from task context (shared processing task and timer callback).
* @note Button state semantics: with pull-up enabled (default), the pressed level is read as 0
* (ZH_ENCODER_BUTTON_STATUS_PRESSED) and the released level as 1 (ZH_ENCODER_BUTTON_STATUS_RELEASED).
*/
#pragma once
@@ -121,6 +123,15 @@ extern "C"
ESP_EVENT_DECLARE_BASE(ZH_ENCODER);
/**
* @brief Encoder rotation direction reported in rotation events.
*/
typedef enum
{
ZH_ENCODER_STATUS_DECREASED, /*!< Encoder position decreased */
ZH_ENCODER_STATUS_INCREASED /*!< Encoder position increased */
} zh_encoder_status_t;
/**
* @brief Event data structure for encoder rotation events.
*
@@ -130,11 +141,20 @@ extern "C"
*/
typedef struct
{
float encoder_position; /*!< Encoder current position */
uint8_t encoder_number; /*!< Encoder unique number */
bool encoder_status; /*!< true if position increased, false if reduced */
float encoder_position; /*!< Encoder current position */
uint8_t encoder_number; /*!< Encoder unique number */
zh_encoder_status_t encoder_status; /*!< Rotation direction */
} zh_encoder_event_on_isr_t;
/**
* @brief Encoder push-button state reported in button events.
*/
typedef enum
{
ZH_ENCODER_BUTTON_STATUS_PRESSED, /*!< Button is pressed */
ZH_ENCODER_BUTTON_STATUS_RELEASED /*!< Button is released */
} zh_encoder_button_status_t;
/**
* @brief Event data structure for encoder button events.
*
@@ -145,8 +165,8 @@ extern "C"
*/
typedef struct
{
uint8_t encoder_number; /*!< Encoder unique number */
bool button_status; /*!< Encoder button status */
uint8_t encoder_number; /*!< Encoder unique number */
zh_encoder_button_status_t button_status; /*!< Debounced button state */
} zh_encoder_button_event_on_isr_t;
/**