feat!: changed encoder position to float

This commit is contained in:
2026-01-27 12:26:28 +03:00
parent f2d1822ab4
commit 8b946d7576
4 changed files with 53 additions and 54 deletions

View File

@@ -42,9 +42,9 @@ extern "C"
*/
typedef struct
{
double encoder_step; /*!< Encoder step. @note Must be greater than 0. */
double encoder_min_value; /*!< Encoder min value. @note Must be less than encoder_max_value. */
double encoder_max_value; /*!< Encoder max value. @note Must be greater than encoder_min_value. */
float encoder_step; /*!< Encoder step. @note Must be greater than 0. */
float encoder_min_value; /*!< Encoder min value. @note Must be less than encoder_max_value. */
float encoder_max_value; /*!< Encoder max value. @note Must be greater than encoder_min_value. */
uint8_t task_priority; /*!< Task priority for the encoder isr processing. @note Minimum value is 1. */
uint8_t queue_size; /*!< Queue size for task for the encoder processing. @note Minimum value is 1. */
uint8_t a_gpio_number; /*!< Encoder A GPIO number. */
@@ -64,10 +64,10 @@ extern "C"
pcnt_unit_handle_t pcnt_unit_handle; /*!< Encoder unique pcnt unit handle. */
pcnt_channel_handle_t pcnt_channel_a_handle; /*!< Encoder unique pcnt channel handle. */
pcnt_channel_handle_t pcnt_channel_b_handle; /*!< Encoder unique pcnt channel handle. */
double encoder_step; /*!< Encoder step. */
double encoder_position; /*!< Encoder position. */
double encoder_min_value; /*!< Encoder min value. */
double encoder_max_value; /*!< Encoder max value. */
float encoder_step; /*!< Encoder step. */
float encoder_position; /*!< Encoder position. */
float encoder_min_value; /*!< Encoder min value. */
float encoder_max_value; /*!< Encoder max value. */
uint8_t encoder_number; /*!< Encoder unique number. */
uint8_t s_gpio_number; /*!< Encoder button GPIO number. */
uint16_t s_gpio_debounce_time; /*!< Encoder button debounce_time. */
@@ -104,7 +104,7 @@ extern "C"
*/
typedef struct
{
double encoder_position; /*!< Encoder current position. */
float encoder_position; /*!< Encoder current position. */
uint8_t encoder_number; /*!< Encoder unique number. */
} zh_encoder_event_on_isr_t;
@@ -154,7 +154,7 @@ extern "C"
*
* @return ESP_OK if success or an error code otherwise.
*/
esp_err_t zh_encoder_reinit(zh_encoder_handle_t *handle, double min, double max, double step);
esp_err_t zh_encoder_reinit(zh_encoder_handle_t *handle, float min, float max, float step);
/**
* @brief Set encoder position.
@@ -164,7 +164,7 @@ extern "C"
*
* @return ESP_OK if success or an error code otherwise.
*/
esp_err_t zh_encoder_set(zh_encoder_handle_t *handle, double position);
esp_err_t zh_encoder_set(zh_encoder_handle_t *handle, float position);
/**
* @brief Get encoder position.
@@ -174,7 +174,7 @@ extern "C"
*
* @return ESP_OK if success or an error code otherwise.
*/
esp_err_t zh_encoder_get(const zh_encoder_handle_t *handle, double *position);
esp_err_t zh_encoder_get(const zh_encoder_handle_t *handle, float *position);
/**
* @brief Reset encoder position.