From 37ae2994262a5a47ac7116cee8b843af0bcb914f Mon Sep 17 00:00:00 2001 From: Alexey Zholtikov Date: Wed, 24 Dec 2025 13:01:10 +0300 Subject: [PATCH] perf: reduced min task values --- include/zh_encoder.h | 26 +++++++++++++------------- zh_encoder.c | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/zh_encoder.h b/include/zh_encoder.h index e65b596..637a926 100644 --- a/include/zh_encoder.h +++ b/include/zh_encoder.h @@ -13,16 +13,16 @@ /** * @brief Encoder initial default values. */ -#define ZH_ENCODER_INIT_CONFIG_DEFAULT() \ - { \ - .task_priority = 10, \ - .stack_size = 3072, \ - .queue_size = 10, \ - .a_gpio_number = 0, \ - .b_gpio_number = 0, \ - .encoder_min_value = -100, \ - .encoder_max_value = 100, \ - .encoder_step = 1, \ +#define ZH_ENCODER_INIT_CONFIG_DEFAULT() \ + { \ + .task_priority = 1, \ + .stack_size = configMINIMAL_STACK_SIZE, \ + .queue_size = 1, \ + .a_gpio_number = GPIO_NUM_MAX, \ + .b_gpio_number = GPIO_NUM_MAX, \ + .encoder_min_value = -100, \ + .encoder_max_value = 100, \ + .encoder_step = 1, \ .encoder_number = 0} #ifdef __cplusplus @@ -37,9 +37,9 @@ extern "C" */ typedef struct { - uint8_t task_priority; /*!< Task priority for the encoder isr processing. @note It is not recommended to set a value less than 10. */ - uint16_t stack_size; /*!< Stack size for task for the encoder isr processing processing. @note The minimum size is 3072 bytes. */ - uint8_t queue_size; /*!< Queue size for task for the encoder processing. @note It is not recommended to set a value less than 10. */ + uint8_t task_priority; /*!< Task priority for the encoder isr processing. @note Minimum value is 1. */ + uint16_t stack_size; /*!< Stack size for task for the encoder isr processing processing. @note The minimum size is configMINIMAL_STACK_SIZE. */ + 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. */ uint8_t b_gpio_number; /*!< Encoder B GPIO number. */ int32_t encoder_min_value; /*!< Encoder min value. @note Must be less than encoder_max_value. */ diff --git a/zh_encoder.c b/zh_encoder.c index e20d4d8..7d24a92 100644 --- a/zh_encoder.c +++ b/zh_encoder.c @@ -127,8 +127,8 @@ void zh_encoder_reset_stats(void) static esp_err_t _zh_encoder_validate_config(const zh_encoder_init_config_t *config) { ZH_ERROR_CHECK(config != NULL, ESP_ERR_INVALID_ARG, NULL, "Invalid configuration."); - ZH_ERROR_CHECK(config->task_priority >= 10 && config->stack_size >= 3072, ESP_ERR_INVALID_ARG, NULL, "Invalid task settings."); - ZH_ERROR_CHECK(config->queue_size >= 10, ESP_ERR_INVALID_ARG, NULL, "Invalid queue size."); + ZH_ERROR_CHECK(config->task_priority >= 1 && config->stack_size >= configMINIMAL_STACK_SIZE, ESP_ERR_INVALID_ARG, NULL, "Invalid task settings."); + ZH_ERROR_CHECK(config->queue_size >= 1, ESP_ERR_INVALID_ARG, NULL, "Invalid queue size."); ZH_ERROR_CHECK(config->encoder_max_value > config->encoder_min_value, ESP_ERR_INVALID_ARG, NULL, "Invalid encoder min/max value."); ZH_ERROR_CHECK(config->encoder_step > 0, ESP_ERR_INVALID_ARG, NULL, "Invalid encoder step."); return ESP_OK;