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:
2025-08-22 12:29:07 +03:00
parent 19d02836dd
commit 40633e03d8
13 changed files with 384 additions and 3 deletions

View File

@@ -101,6 +101,36 @@ static inline relay_chn_direction_t relay_chn_get_direction(uint8_t chn_id)
return relay_chn_ctl_get_direction(chn_id);
}
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
/**
* @brief Get the run limit for the specified channel
*
* @param chn_id The ID of the relay channel to query.
*
* @return The run limit value for the relevant channel if the channel ID is valid.
* 0 if the channel ID is invalid.
*/
extern uint16_t relay_chn_ctl_get_run_limit(uint8_t chn_id);
/**
* @brief Set the run limit for the specified channel
*
* @param chn_id The ID of the relay channel to query.
* @param time_sec The run limit time in seconds.
*/
extern void relay_chn_ctl_set_run_limit(uint8_t chn_id, uint16_t time_sec);
static inline uint16_t relay_chn_get_run_limit(uint8_t chn_id)
{
return relay_chn_ctl_get_run_limit(chn_id);
}
static inline void relay_chn_set_run_limit(uint8_t chn_id, uint16_t time_sec)
{
relay_chn_ctl_set_run_limit(chn_id, time_sec);
}
#endif // RELAY_CHN_ENABLE_RUN_LIMIT == 1
#else
/**
@@ -179,6 +209,32 @@ static inline relay_chn_direction_t relay_chn_get_direction(void)
return relay_chn_ctl_get_direction();
}
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
/**
* @brief Get the run limit for the channel
*
* @return The run limit value for the channel.
*/
extern uint16_t relay_chn_ctl_get_run_limit(void);
/**
* @brief Set the run limit for the channel
*
* @param time_sec The run limit time in seconds.
*/
extern void relay_chn_ctl_set_run_limit(uint16_t time_sec);
static inline uint16_t relay_chn_get_run_limit(void)
{
return relay_chn_ctl_get_run_limit();
}
static inline void relay_chn_set_run_limit(uint16_t time_sec)
{
relay_chn_ctl_set_run_limit(time_sec);
}
#endif // RELAY_CHN_ENABLE_RUN_LIMIT == 1
#endif // RELAY_CHN_COUNT > 1
#ifdef __cplusplus