Add run limit feature for relay channels with NVS support
- Introduced configuration options for enabling run limits in Kconfig. - Added APIs to get and set run limits for individual relay channels. - Implemented run limit timer functionality to automatically stop channels. - Updated NVS handling to store and retrieve run limit values. - Enhanced documentation in README and code comments to reflect new feature. Closes #1080
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
#include "relay_chn_nvs.h"
|
||||
|
||||
#define RELAY_CHN_KEY_DIR "dir" /*!< Direction key */
|
||||
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
|
||||
#define RELAY_CHN_KEY_RLIM(ch) "rlim_%d" /*!< Run limit key */
|
||||
#endif
|
||||
#ifdef RELAY_CHN_ENABLE_TILTING
|
||||
#define RELAY_CHN_KEY_TSENS(ch) "tsens_%d" /*!< Tilt sensitivity key */
|
||||
#define RELAY_CHN_KEY_TCNT(ch) "tcnt_%d" /*!< Tilt count key */
|
||||
@@ -69,6 +72,22 @@ esp_err_t relay_chn_nvs_get_direction(uint8_t ch, relay_chn_direction_t *directi
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
|
||||
esp_err_t relay_chn_nvs_set_run_limit(uint8_t ch, uint16_t time_sec)
|
||||
{
|
||||
esp_err_t ret = nvs_set_u16(relay_chn_nvs, RELAY_CHN_KEY_RLIM(ch), time_sec);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to set run limit for channel %d", ch);
|
||||
return nvs_commit(relay_chn_nvs);
|
||||
}
|
||||
|
||||
esp_err_t relay_chn_nvs_get_run_limit(uint8_t ch, uint16_t *time_sec)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(time_sec != NULL, ESP_ERR_INVALID_ARG, TAG, "Run limit value pointer is NULL");
|
||||
|
||||
return nvs_get_u16(relay_chn_nvs, RELAY_CHN_KEY_RLIM(ch), time_sec);
|
||||
}
|
||||
#endif // RELAY_CHN_ENABLE_RUN_LIMIT == 1
|
||||
|
||||
#ifdef RELAY_CHN_ENABLE_TILTING
|
||||
esp_err_t relay_chn_nvs_set_tilt_sensitivity(uint8_t ch, uint8_t sensitivity)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user