Add tilt feature, fix bugs, improve code.

* Add tilt feature.

* Fix the following bugs:
  * warning: comparison is always true due to limited range of data type.
  * Remove unnecessary esp_timer checks.
  * The scheduled FREE command disrupts the current command.
  * Fatal pin mapping issue.

* Make code optimizations and improvements:
  * Optimize event loop queue size depending on channel count.
  * Change the channels' starting state to FREE.
  * Remove the unnecessary relay_chn_invalidate_inertia_timer function.
  * Change the relay_chn_start_inertia_timer function as relay_chn_start_esp_timer_once and modify the function so that it be a generic esp timer start function.
  * Optimize the if statement that checks the last run cmd in the relay_chn_execute_stop.
This commit is contained in:
2025-02-21 12:43:00 +03:00
parent dcb5453522
commit a694938224
3 changed files with 443 additions and 26 deletions

View File

@@ -54,6 +54,10 @@ enum relay_chn_state_enum {
RELAY_CHN_STATE_REVERSE, ///< The relay channel is running in the reverse direction.
RELAY_CHN_STATE_FORWARD_PENDING, ///< The relay channel is pending to run in the forward direction.
RELAY_CHN_STATE_REVERSE_PENDING, ///< The relay channel is pending to run in the reverse direction.
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
RELAY_CHN_STATE_TILT_FORWARD, ///< The relay channel is tilting for forward.
RELAY_CHN_STATE_TILT_REVERSE, ///< The relay channel is tilting for reverse.
#endif
};
/**
@@ -198,6 +202,23 @@ void relay_chn_flip_direction(uint8_t chn_id);
*/
relay_chn_direction_t relay_chn_get_direction(uint8_t chn_id);
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
void relay_chn_tilt_auto(uint8_t chn_id);
void relay_chn_tilt_forward(uint8_t chn_id);
void relay_chn_tilt_reverse(uint8_t chn_id);
void relay_chn_tilt_stop(uint8_t chn_id);
void relay_chn_tilt_sensitivity_set(uint8_t chn_id, uint8_t sensitivity);
uint8_t relay_chn_tilt_sensitivity_get(uint8_t chn_id);
#endif
#ifdef __cplusplus
}
#endif