opt/1085-optimization-and-cleanup #37
10
Kconfig
10
Kconfig
@@ -9,14 +9,14 @@ menu "Relay Channel Driver Configuration"
|
||||
starting the output. This is useful for the motors or some other
|
||||
mechanical actuators to allow them to stop and settle before
|
||||
changing the direction.
|
||||
|
||||
|
||||
config RELAY_CHN_COUNT
|
||||
int "Number of relay channels"
|
||||
range 1 8
|
||||
default 1
|
||||
help
|
||||
Number of relay channels between 1 and 8.
|
||||
|
||||
|
||||
config RELAY_CHN_ENABLE_RUN_LIMIT
|
||||
bool "Enable run limit for channels"
|
||||
default n
|
||||
@@ -32,7 +32,7 @@ menu "Relay Channel Driver Configuration"
|
||||
at a time. Tilting is specifically designed for controlling some
|
||||
types of curtains that need to be adjusted to let enter specific
|
||||
amount of day light.
|
||||
|
||||
|
||||
config RELAY_CHN_ENABLE_NVS
|
||||
bool "Enable persistent NVS storage for relay channel"
|
||||
default n
|
||||
@@ -58,7 +58,7 @@ menu "Relay Channel NVS Storage Configuration"
|
||||
If enabled, a custom NVS partition will be used for storing
|
||||
relay channel configuration. If disabled, the default NVS
|
||||
partition will be used.
|
||||
|
||||
|
||||
config RELAY_CHN_NVS_CUSTOM_PARTITION_NAME
|
||||
string "Custom NVS partition name"
|
||||
depends on RELAY_CHN_NVS_CUSTOM_PARTITION
|
||||
@@ -92,5 +92,5 @@ menu "Relay Channel Run Limit Configuration"
|
||||
default 60
|
||||
help
|
||||
Default run limit in seconds for channels.
|
||||
|
||||
|
||||
endmenu
|
||||
12
README.md
12
README.md
@@ -21,8 +21,8 @@ Each relay channel consists of 2 output relays controlled by 2 GPIO pins. The co
|
||||
|
||||
The run limit feature provides an additional layer of protection by automatically stopping channels after a configurable time period. This is particularly useful for motor-driven applications where continuous operation beyond a certain duration could cause damage or safety issues. Each channel can have its own run limit setting, and when enabled, the component will automatically stop the channel once it has been running for the specified duration.
|
||||
|
||||
It also provides an optional tilting interface per channel base. Tilting makes a channel move with a specific pattern moving with small steps at a time. Tilting is specifically designed for controlling some types of curtains that need to be adjusted to let enter specific amount of day light.
|
||||
Since it operates on relays, the switching frequency is limited to 10Hz which complies with the most of the general purpose relays' requirements. The minimum frequency is 2Hz and the duty cycle is about 10% in all ranges.
|
||||
It also provides an optional tilting interface per channel base. Tilting makes a channel move with a specific pattern moving with small steps at a time. Tilting is specifically designed for controlling some types of curtains that need to be adjusted to let enter specific amount of day light.
|
||||
Since it operates on relays, the switching frequency is limited to 10Hz which complies with the most of the general purpose relays' requirements. The minimum frequency is 2Hz and the duty cycle is about 10% in all ranges.
|
||||
|
||||
Another optional feature is NVS storage, which saves the configuration permanently across reboots of the device. These configurations are:
|
||||
|
||||
@@ -31,7 +31,7 @@ Another optional feature is NVS storage, which saves the configuration permanent
|
||||
- Tilt sensitivity
|
||||
- Last tilt position
|
||||
|
||||
### NVS Operation Details
|
||||
### NVS Operation Details
|
||||
When NVS storage is enabled (CONFIG_RELAY_CHN_ENABLE_NVS=y), the component creates a dedicated background task to manage all NVS write operations. This design has important implications for how you use the NVS-related functions:
|
||||
- **Asynchronous Writes:** All `set` operations (e.g., `relay_chn_flip_direction()`, `relay_chn_set_run_limit()`) are asynchronous. They add the write request to a queue and return immediately, preventing the calling task from being blocked.
|
||||
- **Synchronous Reads:** All get operations (e.g., `relay_chn_get_direction()`) are synchronous. They read the value directly from the NVS storage and will block the calling task until the read is complete.
|
||||
@@ -145,7 +145,7 @@ Depending on the mode, the component will be built selectively, so the signature
|
||||
```c
|
||||
relay_chn_run_forward(); // No channel ID parameter for single channel mode
|
||||
// or
|
||||
relay_chn_run_forward(2); // Channel ID parameters will be needed in multi channel mode
|
||||
relay_chn_run_forward(2); // Channel ID parameters will be needed in multi channel mode
|
||||
```
|
||||
|
||||
See the examples for further reference
|
||||
@@ -197,9 +197,9 @@ relay_chn_run_reverse(1);
|
||||
// Run all channels reverse
|
||||
relay_chn_run_reverse_all();
|
||||
|
||||
// Stop channel #1
|
||||
// Stop channel #1
|
||||
relay_chn_stop(1);
|
||||
// Stop all channels
|
||||
// Stop all channels
|
||||
relay_chn_stop_all();
|
||||
|
||||
// Flip direction of channel #0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* One relay channel consists of 2 output relays, hence 2 GPIO pins are required for each relay channel.
|
||||
* This module provides an API to control the relay channels, specifically to drive bipolar motors.
|
||||
* It also provides APIs to control the direction of the relay channel, bipolar motors in mind.
|
||||
* To prevent mechanical strain on the motor, the component automatically manages direction changes
|
||||
* To prevent mechanical strain on the motor, the component automatically manages direction changes
|
||||
* with a configurable inertia delay, protecting it from abrupt reversals.
|
||||
* The STOP command overrides any other command and clears the pending command if any.
|
||||
*/
|
||||
@@ -45,7 +45,7 @@ void relay_chn_destroy(void);
|
||||
|
||||
/**
|
||||
* @brief Register a channel state change listener.
|
||||
*
|
||||
*
|
||||
* @param listener A function that implements relay_chn_state_listener_t interface.
|
||||
*
|
||||
* @return
|
||||
@@ -58,7 +58,7 @@ esp_err_t relay_chn_register_listener(relay_chn_state_listener_t listener);
|
||||
|
||||
/**
|
||||
* @brief Unregister a channel state change listener.
|
||||
*
|
||||
*
|
||||
* @param listener A function that implements relay_chn_state_listener_t interface.
|
||||
*/
|
||||
void relay_chn_unregister_listener(relay_chn_state_listener_t listener);
|
||||
@@ -151,8 +151,8 @@ void relay_chn_ctl_run_reverse_all(void);
|
||||
/**
|
||||
* @brief Stops the relay channel specified by the channel ID.
|
||||
*
|
||||
* This function stops the operation of the relay channel identified by the
|
||||
* provided channel ID. It is typically used to turn off or disable the relay
|
||||
* This function stops the operation of the relay channel identified by the
|
||||
* provided channel ID. It is typically used to turn off or disable the relay
|
||||
* channel.
|
||||
*
|
||||
* @param chn_id The ID of the relay channel to stop.
|
||||
@@ -162,7 +162,7 @@ void relay_chn_stop(uint8_t chn_id);
|
||||
/**
|
||||
* @brief Commands all configured relay channels to stop.
|
||||
*
|
||||
* This function iterates through all configured relay channels and issues a command
|
||||
* This function iterates through all configured relay channels and issues a command
|
||||
* to each to stop any ongoing movement.
|
||||
*/
|
||||
void relay_chn_ctl_stop_all(void);
|
||||
@@ -181,7 +181,7 @@ void relay_chn_flip_direction(uint8_t chn_id);
|
||||
/**
|
||||
* @brief Flips the logical direction of all configured relay channels.
|
||||
*
|
||||
* This function iterates through all configured relay channels and swaps the
|
||||
* This function iterates through all configured relay channels and swaps the
|
||||
* physical GPIO pins assigned to the forward and reverse directions for each.
|
||||
*/
|
||||
void relay_chn_ctl_flip_direction_all(void);
|
||||
@@ -215,7 +215,7 @@ esp_err_t relay_chn_ctl_get_direction_all(relay_chn_direction_t *directions);
|
||||
* @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.
|
||||
*/
|
||||
@@ -235,8 +235,8 @@ esp_err_t relay_chn_ctl_get_run_limit_all(uint16_t *limits_sec);
|
||||
|
||||
/**
|
||||
* @brief Set the run limit for the specified channel
|
||||
*
|
||||
* Sets the time limit in seconds for the specified channel. It will not proceed
|
||||
*
|
||||
* Sets the time limit in seconds for the specified channel. It will not proceed
|
||||
* if the channel ID is invalid.
|
||||
* If the limit_sec value is lesser than the CONFIG_RELAY_CHN_RUN_LIMIT_MIN_SEC,
|
||||
* the value will be set to CONFIG_RELAY_CHN_RUN_LIMIT_MIN_SEC.
|
||||
@@ -358,8 +358,8 @@ void relay_chn_tilt_set_sensitivity(uint8_t chn_id, uint8_t sensitivity);
|
||||
* The new sensitivities are persisted in NVS if enabled.
|
||||
*
|
||||
* @param sensitivities Pointer to an array containing the desired tilt sensitivities.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - ESP_ERR_INVALID_ARG: When sensitivities parameter is NULL
|
||||
*/
|
||||
@@ -459,7 +459,7 @@ void relay_chn_flip_direction(void);
|
||||
* @brief Get the direction of the relay channel.
|
||||
*
|
||||
* This function retrieves the direction configuration of a relay channel.
|
||||
*
|
||||
*
|
||||
* @return The direction of the relay channel as a value of type
|
||||
* relay_chn_direction_t.
|
||||
*/
|
||||
@@ -468,15 +468,15 @@ relay_chn_direction_t relay_chn_get_direction(void);
|
||||
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT
|
||||
/**
|
||||
* @brief Get the run limit for the channel
|
||||
*
|
||||
*
|
||||
* @return The run limit value for the channel.
|
||||
*/
|
||||
uint16_t relay_chn_get_run_limit(void);
|
||||
|
||||
/**
|
||||
* @brief Set the run limit for the channel
|
||||
*
|
||||
* Sets the time limit in seconds for the channel. It will not proceed
|
||||
*
|
||||
* Sets the time limit in seconds for the channel. It will not proceed
|
||||
* if the channel ID is invalid.
|
||||
* If the limit_sec value is lesser than the CONFIG_RELAY_CHN_RUN_LIMIT_MIN_SEC,
|
||||
* the value will be set to CONFIG_RELAY_CHN_RUN_LIMIT_MIN_SEC.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* SPDX-FileCopyrightText: 2025 Kozmotronik Tech
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*
|
||||
* An adapter header to expose the appropriate API functions to the public API
|
||||
* depending on the CONFIG_RELAY_CHN_COUNT value which determines single or multi mode.
|
||||
*/
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief Register a channel state change listener.
|
||||
*
|
||||
*
|
||||
* @param listener A function that implements relay_chn_state_listener_t interface.
|
||||
*
|
||||
* @return
|
||||
@@ -28,7 +28,7 @@ extern esp_err_t relay_chn_notify_add_listener(relay_chn_state_listener_t listen
|
||||
|
||||
/**
|
||||
* @brief Unregister a channel state change listener.
|
||||
*
|
||||
*
|
||||
* @param listener A function that implements relay_chn_state_listener_t interface.
|
||||
*/
|
||||
extern void relay_chn_notify_remove_listener(relay_chn_state_listener_t listener);
|
||||
@@ -60,7 +60,7 @@ extern relay_chn_state_t relay_chn_ctl_get_state(uint8_t chn_id);
|
||||
* to hold `CONFIG_RELAY_CHN_COUNT` elements.
|
||||
*
|
||||
* @param states Pointer to an array where the states will be stored.
|
||||
*
|
||||
*
|
||||
* @return ESP_OK on success, ESP_ERR_INVALID_ARG if `states` is NULL.
|
||||
*/
|
||||
extern esp_err_t relay_chn_ctl_get_state_all(relay_chn_state_t *states);
|
||||
@@ -127,7 +127,7 @@ extern void relay_chn_ctl_flip_direction(uint8_t chn_id);
|
||||
/**
|
||||
* @brief Flips the logical direction of all configured relay channels.
|
||||
*
|
||||
* This function iterates through all configured relay channels and swaps the
|
||||
* This function iterates through all configured relay channels and swaps the
|
||||
* physical GPIO pins assigned to the forward and reverse directions for each.
|
||||
*/
|
||||
extern void relay_chn_ctl_flip_direction_all(void);
|
||||
@@ -222,7 +222,7 @@ static inline esp_err_t relay_chn_get_direction_all(relay_chn_direction_t *direc
|
||||
* @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.
|
||||
*/
|
||||
@@ -380,7 +380,7 @@ static inline relay_chn_direction_t relay_chn_get_direction(void)
|
||||
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT
|
||||
/**
|
||||
* @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);
|
||||
|
||||
@@ -18,10 +18,10 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief Initializes the relay channel timer.
|
||||
*
|
||||
*
|
||||
* This function creates a timer for the relay channel to handle direction change inertia.
|
||||
* Required by *_ctl_* module.
|
||||
*
|
||||
*
|
||||
* @param chn_ctl Pointer to the relay channel control structure.
|
||||
* @return esp_err_t ESP_OK on success, or an error code on failure.
|
||||
*/
|
||||
@@ -30,12 +30,12 @@ esp_err_t relay_chn_init_timer(relay_chn_ctl_t *chn_ctl);
|
||||
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT
|
||||
/**
|
||||
* @brief Initializes the relay channel run limit timer.
|
||||
*
|
||||
*
|
||||
* This function creates a timer for the relay channel to handle run time limit.
|
||||
* Required by *_ctl_* module.
|
||||
*
|
||||
*
|
||||
* @param chn_ctl Pointer to the relay channel control structure.
|
||||
*
|
||||
*
|
||||
* @return esp_err_t ESP_OK on success, or an error code on failure.
|
||||
*/
|
||||
esp_err_t relay_chn_init_run_limit_timer(relay_chn_ctl_t *chn_ctl);
|
||||
@@ -43,10 +43,10 @@ esp_err_t relay_chn_init_run_limit_timer(relay_chn_ctl_t *chn_ctl);
|
||||
|
||||
/**
|
||||
* @brief Issues a command to the relay channel.
|
||||
*
|
||||
*
|
||||
* Evaluates the current state of the relay channel and issues the command accordingly.
|
||||
* Required by *_core, *_ctl_* and *_tilt modules.
|
||||
*
|
||||
*
|
||||
* @param chn_ctl Pointer to the relay channel control structure.
|
||||
* @param cmd The command to issue.
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd);
|
||||
|
||||
/**
|
||||
* @brief Dispatches a relay channel command.
|
||||
*
|
||||
*
|
||||
* @param chn_ctl Pointer to the relay channel control structure.
|
||||
* @param cmd The command to dispatch.
|
||||
*/
|
||||
@@ -62,7 +62,7 @@ void relay_chn_dispatch_cmd(relay_chn_ctl_t *chn_ctl, relay_chn_cmd_t cmd);
|
||||
|
||||
/**
|
||||
* @brief Returns the string representation of a relay channel command.
|
||||
*
|
||||
*
|
||||
* @param cmd The relay channel command.
|
||||
* @return char* The string representation of the command.
|
||||
*/
|
||||
@@ -70,11 +70,11 @@ char *relay_chn_cmd_str(relay_chn_cmd_t cmd);
|
||||
|
||||
/**
|
||||
* @brief Starts the ESP timer once with the specified time in milliseconds.
|
||||
*
|
||||
*
|
||||
* Starts the ESP timer to run once after the specified time.
|
||||
* If the timer is already running, it stops it first and then starts it again.
|
||||
* Required by *_ctl_* and *_tilt modules.
|
||||
*
|
||||
*
|
||||
* @param esp_timer The ESP timer handle.
|
||||
* @param time_ms The time in milliseconds to wait before the timer expires.
|
||||
* @return esp_err_t ESP_OK on success, or an error code on failure.
|
||||
@@ -83,11 +83,11 @@ esp_err_t relay_chn_start_esp_timer_once(esp_timer_handle_t esp_timer, uint32_t
|
||||
|
||||
/**
|
||||
* @brief Updates the state of the relay channel and notifies listeners.
|
||||
*
|
||||
*
|
||||
* This function updates the state of the relay channel and notifies all registered listeners
|
||||
* about the state change.
|
||||
* Required by *_ctl_* and *_tilt modules.
|
||||
*
|
||||
*
|
||||
* @param chn_ctl Pointer to the relay channel control structure.
|
||||
* @param new_state The new state to set for the relay channel.
|
||||
*/
|
||||
@@ -95,7 +95,7 @@ void relay_chn_update_state(relay_chn_ctl_t *chn_ctl, relay_chn_state_t new_stat
|
||||
|
||||
/**
|
||||
* @brief Return the text presentation of an state.
|
||||
*
|
||||
*
|
||||
* @param state A state with type of relay_chn_state_t.
|
||||
* @return char* The text presentation of the state. "UNKNOWN" if the state is not known.
|
||||
*/
|
||||
@@ -104,7 +104,7 @@ char *relay_chn_state_str(relay_chn_state_t state);
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
/**
|
||||
* @brief Check if the provided channel ID is valid.
|
||||
*
|
||||
*
|
||||
* @param chn_id Channel ID to check.
|
||||
* @return true Channel ID is valid.
|
||||
* @return false Channel ID is invalid.
|
||||
|
||||
@@ -16,17 +16,17 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief Initialize the relay channel control.
|
||||
*
|
||||
*
|
||||
* @param output Pointer to the output object(s).
|
||||
* @param run_info Pointer to the runtime information object(s).
|
||||
*
|
||||
*
|
||||
* @return esp_err_t Returns ESP_OK on success, or an error code on failure.
|
||||
*/
|
||||
esp_err_t relay_chn_ctl_init(relay_chn_output_t *output, relay_chn_run_info_t *run_info);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the relay channel control.
|
||||
*
|
||||
*
|
||||
* This function cleans up resources used by the relay channel control.
|
||||
*/
|
||||
void relay_chn_ctl_deinit(void);
|
||||
@@ -34,16 +34,16 @@ void relay_chn_ctl_deinit(void);
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
/**
|
||||
* @brief Get the control structure for a specific relay channel.
|
||||
*
|
||||
*
|
||||
* @param chn_id The ID of the relay channel to retrieve.
|
||||
*
|
||||
*
|
||||
* @return relay_chn_ctl_t* Pointer to the control structure for the specified channel, or NULL if not found.
|
||||
*/
|
||||
relay_chn_ctl_t *relay_chn_ctl_get(uint8_t chn_id);
|
||||
|
||||
/**
|
||||
* @brief Get the control structures for all relay channels.
|
||||
*
|
||||
*
|
||||
* @return relay_chn_ctl_t* Pointer to the array of control structures for all channels.
|
||||
*/
|
||||
relay_chn_ctl_t *relay_chn_ctl_get_all(void);
|
||||
|
||||
@@ -16,7 +16,7 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief Init the notify module.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - ESP_ERR_NO_MEM: Not enough memory to create notify queue
|
||||
@@ -25,7 +25,7 @@ esp_err_t relay_chn_notify_init(void);
|
||||
|
||||
/**
|
||||
* @brief Deinit the notify module.
|
||||
*
|
||||
*
|
||||
* This function cleans up resources used by the notify module.
|
||||
*/
|
||||
void relay_chn_notify_deinit(void);
|
||||
|
||||
@@ -18,9 +18,9 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief Initialize NVS storage for relay channels.
|
||||
*
|
||||
* @attention Before calling this function, make sure the NVS flash is initialised
|
||||
* using either the nvs_flash_init() function for the default NVS partition or the
|
||||
*
|
||||
* @attention Before calling this function, make sure the NVS flash is initialised
|
||||
* using either the nvs_flash_init() function for the default NVS partition or the
|
||||
* nvs_flash_init_partition() function for a custom partition.
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
@@ -32,7 +32,7 @@ esp_err_t relay_chn_nvs_init(void);
|
||||
*
|
||||
* @param[in] ch Channel number.
|
||||
* @param[in] direction Direction to store.
|
||||
*
|
||||
*
|
||||
* @note This operation is asynchronous. The value is queued to be written
|
||||
* by a background task. A subsequent `get` call may not immediately
|
||||
* reflect the new value.
|
||||
@@ -56,7 +56,7 @@ esp_err_t relay_chn_nvs_get_direction(uint8_t ch, relay_chn_direction_t *directi
|
||||
*
|
||||
* @param[in] ch Channel number.
|
||||
* @param[in] limit_sec Run limit value to store.
|
||||
*
|
||||
*
|
||||
* @note This operation is asynchronous. The value is queued to be written
|
||||
* by a background task. A subsequent `get` call may not immediately
|
||||
* reflect the new value.
|
||||
@@ -81,7 +81,7 @@ esp_err_t relay_chn_nvs_get_run_limit(uint8_t ch, uint16_t *limit_sec, uint16_t
|
||||
*
|
||||
* @param[in] ch Channel number.
|
||||
* @param[in] sensitivity Sensitivity value to store.
|
||||
*
|
||||
*
|
||||
* @note This operation is asynchronous. The value is queued to be written
|
||||
* by a background task. A subsequent `get` call may not immediately
|
||||
* reflect the new value.
|
||||
@@ -104,7 +104,7 @@ esp_err_t relay_chn_nvs_get_tilt_sensitivity(uint8_t ch, uint8_t *sensitivity, u
|
||||
*
|
||||
* @param[in] ch Channel number.
|
||||
* @param[in] tilt_count Tilt count value.
|
||||
*
|
||||
*
|
||||
* @note This operation is asynchronous. The value is queued to be written
|
||||
* by a background task. A subsequent `get` call may not immediately
|
||||
* reflect the new value.
|
||||
|
||||
@@ -24,7 +24,7 @@ extern "C" {
|
||||
*
|
||||
* @param[in] gpio_map Array of GPIO pin numbers for each relay channel.
|
||||
* @param[in] gpio_count Number of GPIO pins (relay channels).
|
||||
*
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_output_init(const uint8_t* gpio_map, uint8_t gpio_count);
|
||||
@@ -41,7 +41,7 @@ void relay_chn_output_deinit(void);
|
||||
* @brief Get the relay channel output object for a specific channel.
|
||||
*
|
||||
* @param[in] chn_id Channel ID.
|
||||
*
|
||||
*
|
||||
* @return Pointer to relay channel output object, or NULL if invalid.
|
||||
*/
|
||||
relay_chn_output_t *relay_chn_output_get(uint8_t chn_id);
|
||||
@@ -67,7 +67,7 @@ relay_chn_output_t *relay_chn_output_get(void);
|
||||
* Sets the relay channel to the stop state.
|
||||
*
|
||||
* @param[in] output Pointer to relay channel output object.
|
||||
*
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_output_stop(relay_chn_output_t *output);
|
||||
@@ -76,7 +76,7 @@ esp_err_t relay_chn_output_stop(relay_chn_output_t *output);
|
||||
* @brief Set relay channel output to forward direction.
|
||||
*
|
||||
* @param[in] output Pointer to relay channel output object.
|
||||
*
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_output_forward(relay_chn_output_t *output);
|
||||
@@ -85,7 +85,7 @@ esp_err_t relay_chn_output_forward(relay_chn_output_t *output);
|
||||
* @brief Set relay channel output to reverse direction.
|
||||
*
|
||||
* @param[in] output Pointer to relay channel output object.
|
||||
*
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_output_reverse(relay_chn_output_t *output);
|
||||
@@ -103,7 +103,7 @@ void relay_chn_output_flip(relay_chn_output_t *output);
|
||||
* @brief Get the current direction of the relay channel output.
|
||||
*
|
||||
* @param[in] output Pointer to relay channel output object.
|
||||
*
|
||||
*
|
||||
* @return Current direction of the relay channel.
|
||||
*/
|
||||
relay_chn_direction_t relay_chn_output_get_direction(relay_chn_output_t *output);
|
||||
|
||||
@@ -49,7 +49,7 @@ relay_chn_run_info_t *relay_chn_run_info_get(void);
|
||||
* @brief Get the last run command for a relay channel.
|
||||
*
|
||||
* @param[in] run_info Pointer to run information structure.
|
||||
*
|
||||
*
|
||||
* @return Last command that was executed, or RELAY_CHN_CMD_NONE if invalid.
|
||||
*/
|
||||
relay_chn_cmd_t relay_chn_run_info_get_last_run_cmd(relay_chn_run_info_t *run_info);
|
||||
@@ -66,7 +66,7 @@ void relay_chn_run_info_set_last_run_cmd(relay_chn_run_info_t *run_info, relay_c
|
||||
* @brief Get the timestamp of the last run command.
|
||||
*
|
||||
* @param[in] run_info Pointer to run information structure.
|
||||
*
|
||||
*
|
||||
* @return Timestamp in milliseconds of last command, or 0 if invalid.
|
||||
*/
|
||||
uint32_t relay_chn_run_info_get_last_run_cmd_time_ms(relay_chn_run_info_t *run_info);
|
||||
|
||||
@@ -19,7 +19,7 @@ extern "C" {
|
||||
* Must be called before using any other tilt functions.
|
||||
*
|
||||
* @param[in] chn_ctls Array of relay channel control structures.
|
||||
*
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_tilt_init(relay_chn_ctl_t *chn_ctls);
|
||||
@@ -34,12 +34,12 @@ void relay_chn_tilt_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Dispatch a tilt command to a relay channel.
|
||||
*
|
||||
*
|
||||
* Queues a tilt command for execution on the specified channel.
|
||||
*
|
||||
* @param[in] tilt_ctl Pointer to tilt control structure.
|
||||
* @param[in] cmd Tilt command to execute.
|
||||
*
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_tilt_dispatch_cmd(relay_chn_tilt_ctl_t *tilt_ctl, relay_chn_tilt_cmd_t cmd);
|
||||
|
||||
@@ -28,8 +28,8 @@ static const char *TAG = "RELAY_CHN_CORE";
|
||||
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT
|
||||
/*
|
||||
* Run limit timer callback immediately dispatches a STOP command for the
|
||||
/*
|
||||
* Run limit timer callback immediately dispatches a STOP command for the
|
||||
* relevant channel as soon as the run limit time times out
|
||||
*/
|
||||
static void relay_chn_run_limit_timer_cb(void* arg)
|
||||
@@ -195,17 +195,17 @@ static void relay_chn_stop_prv(relay_chn_ctl_t *chn_ctl)
|
||||
|
||||
/**
|
||||
* @brief The command issuer function.
|
||||
*
|
||||
* This function is the deciding logic for issuing a command to a relay channel. It evaluates
|
||||
*
|
||||
* This function is the deciding logic for issuing a command to a relay channel. It evaluates
|
||||
* the current state of the channel before issuing the command. Then it decides whether to run
|
||||
* the command immediately or wait for the opposite inertia time.
|
||||
*
|
||||
*
|
||||
* The STOP command is an exception, it is always run immediately since it is safe in any case.
|
||||
*
|
||||
*
|
||||
* Another special consideration is the FLIP command. If the channel is running, the FLIP command
|
||||
* is issued after the channel is stopped. If the channel is stopped, the FLIP command is issued
|
||||
* immediately.
|
||||
*
|
||||
*
|
||||
* @param chn_ctl The relay channel to issue the command to.
|
||||
* @param cmd The command to issue.
|
||||
*/
|
||||
@@ -214,7 +214,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
|
||||
if (cmd == RELAY_CHN_CMD_NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (cmd == RELAY_CHN_CMD_STOP) {
|
||||
if (chn_ctl->state == RELAY_CHN_STATE_STOPPED) {
|
||||
return; // Do nothing if already stopped
|
||||
@@ -232,7 +232,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
|
||||
// If the channel is idle, run the command immediately
|
||||
relay_chn_dispatch_cmd(chn_ctl, cmd);
|
||||
break;
|
||||
|
||||
|
||||
case RELAY_CHN_STATE_FORWARD_PENDING:
|
||||
case RELAY_CHN_STATE_REVERSE_PENDING:
|
||||
// The channel is already waiting for the opposite inertia time,
|
||||
@@ -241,7 +241,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
|
||||
relay_chn_dispatch_cmd(chn_ctl, cmd);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case RELAY_CHN_STATE_STOPPED:
|
||||
if (last_run_cmd == cmd || last_run_cmd == RELAY_CHN_CMD_NONE) {
|
||||
// Since the state is STOPPED, the inertia timer should be running and must be invalidated
|
||||
@@ -254,7 +254,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
|
||||
relay_chn_dispatch_cmd(chn_ctl, cmd);
|
||||
}
|
||||
else {
|
||||
// If the last run command is different from the current command, calculate the time passed
|
||||
// If the last run command is different from the current command, calculate the time passed
|
||||
// since the last run command stopped and decide whether to run the command immediately or wait
|
||||
uint32_t last_run_cmd_time_ms = relay_chn_run_info_get_last_run_cmd_time_ms(chn_ctl->run_info);
|
||||
uint32_t current_time_ms = (uint32_t)(esp_timer_get_time() / 1000);
|
||||
@@ -281,7 +281,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case RELAY_CHN_STATE_FORWARD:
|
||||
case RELAY_CHN_STATE_REVERSE:
|
||||
if (cmd == RELAY_CHN_CMD_FLIP) {
|
||||
@@ -290,18 +290,18 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
|
||||
relay_chn_dispatch_cmd(chn_ctl, cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (last_run_cmd == cmd) {
|
||||
// If the last run command is the same as the current command, do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Stop the channel first before the schedule
|
||||
relay_chn_stop_prv(chn_ctl);
|
||||
|
||||
// If the last run command is different from the current command, wait for the opposite inertia time
|
||||
chn_ctl->pending_cmd = cmd;
|
||||
relay_chn_state_t new_state = cmd == RELAY_CHN_CMD_FORWARD
|
||||
relay_chn_state_t new_state = cmd == RELAY_CHN_CMD_FORWARD
|
||||
? RELAY_CHN_STATE_FORWARD_PENDING : RELAY_CHN_STATE_REVERSE_PENDING;
|
||||
relay_chn_update_state(chn_ctl, new_state);
|
||||
relay_chn_start_timer_or_idle(chn_ctl, chn_ctl->inertia_timer, CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS, "inertia");
|
||||
@@ -366,9 +366,6 @@ static void relay_chn_execute_stop(relay_chn_ctl_t *chn_ctl)
|
||||
{
|
||||
relay_chn_stop_prv(chn_ctl);
|
||||
|
||||
// If there is any pending command, cancel it since the STOP command is issued right after it
|
||||
// chn_ctl->pending_cmd = RELAY_CHN_CMD_NONE;
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT
|
||||
esp_timer_stop(chn_ctl->run_limit_timer);
|
||||
#endif
|
||||
@@ -382,8 +379,7 @@ static void relay_chn_execute_stop(relay_chn_ctl_t *chn_ctl)
|
||||
chn_ctl->pending_cmd = RELAY_CHN_CMD_IDLE;
|
||||
relay_chn_start_timer_or_idle(chn_ctl, chn_ctl->inertia_timer, CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS, "idle");
|
||||
} else {
|
||||
// If the channel was not running one of the run or fwd, issue a free command immediately
|
||||
// relay_chn_dispatch_cmd(chn_ctl, RELAY_CHN_CMD_IDLE);
|
||||
// If the channel was not running forward or reverse, issue a free command immediately
|
||||
relay_chn_execute_idle(chn_ctl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ void relay_chn_ctl_stop_all()
|
||||
void relay_chn_ctl_flip_direction(uint8_t chn_id)
|
||||
{
|
||||
if (relay_chn_is_channel_id_valid(chn_id))
|
||||
relay_chn_issue_cmd(&chn_ctls[chn_id], RELAY_CHN_CMD_FLIP);
|
||||
relay_chn_issue_cmd(&chn_ctls[chn_id], RELAY_CHN_CMD_FLIP);
|
||||
}
|
||||
|
||||
void relay_chn_ctl_flip_direction_all()
|
||||
|
||||
@@ -85,7 +85,7 @@ void relay_chn_ctl_stop()
|
||||
|
||||
void relay_chn_ctl_flip_direction()
|
||||
{
|
||||
relay_chn_issue_cmd(&chn_ctl, RELAY_CHN_CMD_FLIP);
|
||||
relay_chn_issue_cmd(&chn_ctl, RELAY_CHN_CMD_FLIP);
|
||||
}
|
||||
|
||||
relay_chn_direction_t relay_chn_ctl_get_direction()
|
||||
@@ -106,13 +106,13 @@ void relay_chn_ctl_set_run_limit(uint16_t limit_sec)
|
||||
limit_sec = CONFIG_RELAY_CHN_RUN_LIMIT_MAX_SEC;
|
||||
else if (limit_sec < CONFIG_RELAY_CHN_RUN_LIMIT_MIN_SEC)
|
||||
limit_sec = CONFIG_RELAY_CHN_RUN_LIMIT_MIN_SEC;
|
||||
|
||||
|
||||
chn_ctl.run_limit_sec = limit_sec;
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
relay_chn_nvs_set_run_limit(chn_ctl.id, limit_sec);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* relay_chn APIs */
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ static relay_chn_listener_entry_t* find_listener_entry(relay_chn_state_listener_
|
||||
for (ListItem_t *pxListItem = listGET_HEAD_ENTRY(&listeners);
|
||||
pxListItem != listGET_END_MARKER(&listeners);
|
||||
pxListItem = listGET_NEXT(pxListItem)) {
|
||||
|
||||
|
||||
relay_chn_listener_entry_t *entry = (relay_chn_listener_entry_t *) listGET_LIST_ITEM_OWNER(pxListItem);
|
||||
if (entry->listener == listener) {
|
||||
// Found the listener, return the entry
|
||||
|
||||
@@ -81,7 +81,7 @@ esp_err_t relay_chn_nvs_init()
|
||||
ESP_LOGE(TAG, "Failed to create deinit semaphore");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
|
||||
nvs_queue_handle = xQueueCreate(RELAY_CHN_NVS_QUEUE_LEN, sizeof(relay_chn_nvs_msg_t));
|
||||
if (!nvs_queue_handle) {
|
||||
ESP_LOGE(TAG, "Failed to create NVS queue");
|
||||
@@ -165,7 +165,7 @@ static esp_err_t relay_chn_nvs_task_set_direction(uint8_t ch, uint8_t direction)
|
||||
esp_err_t relay_chn_nvs_get_direction(uint8_t ch, relay_chn_direction_t *direction, relay_chn_direction_t default_val)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(direction != NULL, ESP_ERR_INVALID_ARG, TAG, "Direction pointer is NULL");
|
||||
|
||||
|
||||
uint8_t direction_val;
|
||||
esp_err_t ret = nvs_get_u8(relay_chn_nvs, RELAY_CHN_KEY_DIR, &direction_val);
|
||||
if (ret == ESP_ERR_NVS_NOT_FOUND) {
|
||||
@@ -295,7 +295,7 @@ static esp_err_t relay_chn_nvs_task_set_tilt_count(uint8_t ch, uint16_t tilt_cou
|
||||
esp_err_t relay_chn_nvs_get_tilt_count(uint8_t ch, uint16_t *tilt_count, uint16_t default_val)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(tilt_count != NULL, ESP_ERR_INVALID_ARG, TAG, "Counter pointers are NULL");
|
||||
|
||||
|
||||
esp_err_t ret;
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
char key[NVS_KEY_NAME_MAX_SIZE];
|
||||
|
||||
@@ -50,7 +50,7 @@ static esp_err_t relay_chn_output_ctl_init(relay_chn_output_t *output,
|
||||
"Invalid GPIO pin number for forward_pin: %d", forward_pin);
|
||||
ESP_RETURN_ON_FALSE(GPIO_IS_VALID_OUTPUT_GPIO(reverse_pin), ESP_ERR_INVALID_ARG, TAG,
|
||||
"Invalid GPIO pin number for reverse_pin: %d", reverse_pin);
|
||||
|
||||
|
||||
// Check if the GPIOs are valid
|
||||
esp_err_t ret;
|
||||
// Initialize the GPIOs
|
||||
@@ -58,7 +58,7 @@ static esp_err_t relay_chn_output_ctl_init(relay_chn_output_t *output,
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to reset GPIO forward pin: %d", forward_pin);
|
||||
ret = gpio_set_direction(forward_pin, GPIO_MODE_OUTPUT);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to set GPIO direction for forward pin: %d", forward_pin);
|
||||
|
||||
|
||||
ret = gpio_reset_pin(reverse_pin);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to reset GPIO reverse pin: %d", reverse_pin);
|
||||
ret = gpio_set_direction(reverse_pin, GPIO_MODE_OUTPUT);
|
||||
@@ -75,8 +75,8 @@ static esp_err_t relay_chn_output_ctl_init(relay_chn_output_t *output,
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
static esp_err_t relay_chn_output_load_direction(uint8_t ch, relay_chn_direction_t *direction)
|
||||
{
|
||||
// relay_chn_nvs_get_direction handles the NOT_FOUND case and returns the provided default value.
|
||||
esp_err_t ret = relay_chn_nvs_get_direction(ch, direction, RELAY_CHN_DIRECTION_DEFAULT);
|
||||
// relay_chn_nvs_get_direction now handles the NOT_FOUND case and returns a default value.
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to get direction from storage for channel %d: %s", ch, esp_err_to_name(ret));
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ esp_err_t relay_chn_output_init(const uint8_t* gpio_map, uint8_t gpio_count)
|
||||
esp_err_t ret;
|
||||
ret = relay_chn_output_check_gpio_capabilities(gpio_count);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Device does not support the provided GPIOs");
|
||||
|
||||
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
relay_chn_output_t* output = &outputs[i];
|
||||
@@ -185,8 +185,8 @@ void relay_chn_output_flip(relay_chn_output_t *output)
|
||||
output->forward_pin = output->reverse_pin;
|
||||
output->reverse_pin = temp;
|
||||
// Flip the direction
|
||||
output->direction = (output->direction == RELAY_CHN_DIRECTION_DEFAULT)
|
||||
? RELAY_CHN_DIRECTION_FLIPPED
|
||||
output->direction = (output->direction == RELAY_CHN_DIRECTION_DEFAULT)
|
||||
? RELAY_CHN_DIRECTION_FLIPPED
|
||||
: RELAY_CHN_DIRECTION_DEFAULT;
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
|
||||
@@ -22,7 +22,7 @@ static const char *TAG = "RELAY_CHN_TILT";
|
||||
/**@{*/
|
||||
/*
|
||||
* Tilt Pattern Timing Definitions
|
||||
*
|
||||
*
|
||||
* The min and max timing definitions as well as the default timing definitions.
|
||||
* These definitions are used to define and adjust the tilt sensitivity.
|
||||
*/
|
||||
@@ -85,7 +85,7 @@ static uint32_t relay_chn_tilt_get_required_timing_before_tilting(relay_chn_tilt
|
||||
return 0;
|
||||
else if (cmd == RELAY_CHN_TILT_CMD_REVERSE && last_run_cmd == RELAY_CHN_CMD_FORWARD)
|
||||
return 0;
|
||||
|
||||
|
||||
uint32_t last_run_cmd_time_ms = relay_chn_run_info_get_last_run_cmd_time_ms(tilt_ctl->chn_ctl->run_info);
|
||||
uint32_t inertia_time_passed_ms = (uint32_t) (esp_timer_get_time() / 1000) - last_run_cmd_time_ms;
|
||||
return CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS - inertia_time_passed_ms;
|
||||
@@ -115,13 +115,13 @@ static void relay_chn_tilt_issue_cmd(relay_chn_tilt_ctl_t *tilt_ctl, relay_chn_t
|
||||
relay_chn_tilt_dispatch_cmd(tilt_ctl, cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (relay_chn_run_info_get_last_run_cmd(tilt_ctl->chn_ctl->run_info) == RELAY_CHN_CMD_NONE) {
|
||||
// Do not tilt if the channel hasn't been run before
|
||||
ESP_LOGD(TAG, "relay_chn_tilt_issue_cmd: Tilt will not be executed since the channel hasn't been run yet");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (tilt_ctl->cmd == cmd) {
|
||||
ESP_LOGD(TAG, "relay_chn_tilt_issue_cmd: There is already a tilt command in progress!");
|
||||
return;
|
||||
@@ -134,7 +134,7 @@ static void relay_chn_tilt_issue_cmd(relay_chn_tilt_ctl_t *tilt_ctl, relay_chn_t
|
||||
// Relay channel is free, tilt can be issued immediately
|
||||
relay_chn_tilt_dispatch_cmd(tilt_ctl, cmd);
|
||||
break;
|
||||
|
||||
|
||||
case RELAY_CHN_STATE_FORWARD_PENDING:
|
||||
case RELAY_CHN_STATE_REVERSE_PENDING:
|
||||
// Issue a stop command first so that the timer and pending cmd get cleared
|
||||
@@ -322,7 +322,7 @@ static void relay_chn_tilt_compute_set_sensitivity(relay_chn_tilt_ctl_t *tilt_ct
|
||||
uint32_t tilt_run_time_ms = 0, tilt_pause_time_ms = 0;
|
||||
tilt_run_time_ms = RELAY_CHN_TILT_RUN_MIN_MS + (sensitivity * (RELAY_CHN_TILT_RUN_MAX_MS - RELAY_CHN_TILT_RUN_MIN_MS) / 100);
|
||||
tilt_pause_time_ms = RELAY_CHN_TILT_PAUSE_MIN_MS + (sensitivity * (RELAY_CHN_TILT_PAUSE_MAX_MS - RELAY_CHN_TILT_PAUSE_MIN_MS) / 100);
|
||||
|
||||
|
||||
relay_chn_tilt_set_timing_values(&tilt_ctl->tilt_timing,
|
||||
sensitivity,
|
||||
tilt_run_time_ms,
|
||||
@@ -336,7 +336,7 @@ void relay_chn_tilt_set_sensitivity(uint8_t chn_id, uint8_t sensitivity)
|
||||
if (relay_chn_is_channel_id_valid(chn_id)) {
|
||||
ADJUST_TILT_SENS_BOUNDARIES(sensitivity);
|
||||
relay_chn_tilt_compute_set_sensitivity(&tilt_ctls[chn_id], sensitivity);
|
||||
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
relay_chn_nvs_set_tilt_sensitivity(chn_id, sensitivity);
|
||||
#endif // CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
@@ -346,7 +346,7 @@ void relay_chn_tilt_set_sensitivity(uint8_t chn_id, uint8_t sensitivity)
|
||||
esp_err_t relay_chn_tilt_set_sensitivity_all(uint8_t *sensitivities)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(sensitivities != NULL, ESP_ERR_INVALID_ARG, TAG, "set_sensitivity_all: sensitivities is NULL");
|
||||
|
||||
|
||||
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
uint8_t *src_sensitivity = &sensitivities[i];
|
||||
if (src_sensitivity == NULL) {
|
||||
@@ -382,7 +382,7 @@ uint8_t relay_chn_tilt_get_sensitivity(uint8_t chn_id)
|
||||
esp_err_t relay_chn_tilt_get_sensitivity_all(uint8_t *sensitivities)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(sensitivities != NULL, ESP_ERR_INVALID_ARG, TAG, "get_sensitivity_all: sensitivities is NULL");
|
||||
|
||||
|
||||
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
uint8_t *dest_sensitivity = &sensitivities[i];
|
||||
if (dest_sensitivity == NULL) {
|
||||
@@ -400,7 +400,7 @@ void relay_chn_tilt_set_sensitivity(uint8_t sensitivity)
|
||||
{
|
||||
ADJUST_TILT_SENS_BOUNDARIES(sensitivity);
|
||||
relay_chn_tilt_compute_set_sensitivity(&tilt_ctl, sensitivity);
|
||||
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
relay_chn_nvs_set_tilt_sensitivity(0, sensitivity);
|
||||
#endif // CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
@@ -423,25 +423,25 @@ void relay_chn_tilt_reset_count(relay_chn_tilt_ctl_t *tilt_ctl)
|
||||
|
||||
/**
|
||||
* @brief Update tilt count automatically and return the current value.
|
||||
*
|
||||
*
|
||||
* This helper function updates the relevant tilt count depending on the
|
||||
* last run info and helps the tilt module in deciding whether the requested
|
||||
* tilt should execute or not.
|
||||
*
|
||||
*
|
||||
* This is useful to control reverse tilting for the same direction particularly.
|
||||
* For example:
|
||||
* - If the channel's last run was FORWARD and a TILT_FORWARD is requested,
|
||||
* then the tilt count will count up on the relay_chn_tilt_ctl_t::tilt_count
|
||||
* then the tilt count will count up on the relay_chn_tilt_ctl_t::tilt_count
|
||||
* and the function will return the actual count.
|
||||
* - If the channel's last run was FORWARD and a TILT_REVERSE is requested,
|
||||
* then the relay_chn_tilt_ctl_t::tilt_count will be checked against zero first,
|
||||
* and then it will count down and return the actual count if it is greater
|
||||
* then the relay_chn_tilt_ctl_t::tilt_count will be checked against zero first,
|
||||
* and then it will count down and return the actual count if it is greater
|
||||
* than 0, else the function will return 0.
|
||||
* - If the tilt command is irrelevant then the function will return 0.
|
||||
* - If the last run is irrelevant then the function will return 0.
|
||||
*
|
||||
*
|
||||
* @param tilt_ctl The relay channel handle.
|
||||
*
|
||||
*
|
||||
* @return The actual value of the relevant count.
|
||||
* @return 1 if the last tilt_count was 1 and decremented to 0.
|
||||
* @return 0 if:
|
||||
@@ -612,7 +612,7 @@ static void relay_chn_tilt_timer_cb(void *arg)
|
||||
{
|
||||
relay_chn_tilt_ctl_t* tilt_ctl = (relay_chn_tilt_ctl_t*) arg;
|
||||
ESP_RETURN_VOID_ON_FALSE(tilt_ctl != NULL, TAG, "relay_chn_tilt_timer_cb: timer arg is NULL");
|
||||
|
||||
|
||||
switch (tilt_ctl->step)
|
||||
{
|
||||
case RELAY_CHN_TILT_STEP_MOVE:
|
||||
@@ -632,7 +632,7 @@ static void relay_chn_tilt_timer_cb(void *arg)
|
||||
// Just dispatch the pending tilt command
|
||||
relay_chn_tilt_dispatch_cmd(tilt_ctl, tilt_ctl->cmd);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ static esp_err_t relay_chn_tilt_ctl_init(relay_chn_tilt_ctl_t *tilt_ctl,
|
||||
|
||||
tilt_ctl->chn_ctl = chn_ctl;
|
||||
tilt_ctl->chn_ctl->tilt_ctl = tilt_ctl;
|
||||
|
||||
|
||||
// Create tilt timer for the channel
|
||||
char timer_name[32];
|
||||
snprintf(timer_name, sizeof(timer_name), "relay_chn_%2d_tilt_timer", chn_ctl->id);
|
||||
@@ -694,7 +694,7 @@ esp_err_t relay_chn_tilt_init(relay_chn_ctl_t *chn_ctls)
|
||||
{
|
||||
uint8_t sensitivity;
|
||||
uint16_t tilt_count;
|
||||
|
||||
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
esp_err_t ret;
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#define RELAY_CHN_UNITY_TEST_GROUP_TAG "relay_chn"
|
||||
#endif
|
||||
|
||||
void setUp()
|
||||
void setUp()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
@@ -75,7 +75,7 @@ static void test_nvs_flash_deinit(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
void app_main(void)
|
||||
void app_main(void)
|
||||
{
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
// Init NVS once for all tests
|
||||
@@ -109,6 +109,6 @@ void app_main(void)
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TEST_TAG, "All tests complete.");
|
||||
|
||||
|
||||
esp_restart(); // Restart to invoke qemu exit
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ TEST_CASE("Run reverse does nothing if channel id is invalid", "[relay_chn][core
|
||||
TEST_CASE("Relay channels run reverse and update state", "[relay_chn][core]")
|
||||
{
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
relay_chn_run_reverse(i); // relay_chn_run_reverse returns void
|
||||
relay_chn_run_reverse(i);
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state(i));
|
||||
}
|
||||
@@ -148,7 +148,7 @@ TEST_CASE("Relay channels stop and update to FREE state", "[relay_chn][core]")
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(i));
|
||||
|
||||
// Now, issue the stop command
|
||||
relay_chn_stop(i); // relay_chn_stop returns void
|
||||
relay_chn_stop(i);
|
||||
// Immediately after stop, state should be STOPPED
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state(i));
|
||||
@@ -201,19 +201,19 @@ TEST_CASE("Multiple channels can operate independently", "[relay_chn][core]")
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(1)); // Other channel should not be affected
|
||||
|
||||
// Start Channel 1 in reverse direction
|
||||
relay_chn_run_reverse(1); // relay_chn_run_reverse returns void
|
||||
relay_chn_run_reverse(1);
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(0));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state(1));
|
||||
|
||||
// Stop Channel 0 and wait for it to become FREE
|
||||
relay_chn_stop(0); // relay_chn_stop returns void
|
||||
relay_chn_stop(0);
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(0));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state(1)); // Other channel should continue running
|
||||
|
||||
// Stop Channel 1 and wait for it to become FREE
|
||||
relay_chn_stop(1); // relay_chn_stop returns void
|
||||
relay_chn_stop(1);
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(0));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(1));
|
||||
@@ -236,15 +236,15 @@ TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][co
|
||||
TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT);
|
||||
|
||||
// 2. Issue reverse command
|
||||
relay_chn_run_reverse_all(); // relay_chn_run_reverse returns void
|
||||
relay_chn_run_reverse_all();
|
||||
// Immediately after the command, the motor should be stopped
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ESP_OK(relay_chn_get_state_all(states));
|
||||
test_set_expected_state_all(RELAY_CHN_STATE_REVERSE_PENDING);
|
||||
TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT);
|
||||
|
||||
// Wait for the inertia period (after which the reverse command will be dispatched)
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
// Should now be in reverse state
|
||||
TEST_ESP_OK(relay_chn_get_state_all(states));
|
||||
test_set_expected_state_all(RELAY_CHN_STATE_REVERSE);
|
||||
@@ -256,7 +256,7 @@ TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][co
|
||||
TEST_CASE("Reverse to Forward transition with opposite inertia", "[relay_chn][core][inertia]")
|
||||
{
|
||||
// 1. Start in reverse direction
|
||||
relay_chn_run_reverse_all(); // relay_chn_run_reverse returns void
|
||||
relay_chn_run_reverse_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ESP_OK(relay_chn_get_state_all(states));
|
||||
test_set_expected_state_all(RELAY_CHN_STATE_REVERSE);
|
||||
@@ -305,7 +305,7 @@ TEST_CASE("Direction can be flipped for each channel independently", "[relay_chn
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_DEFAULT, relay_chn_get_direction(i));
|
||||
}
|
||||
|
||||
|
||||
// 2. Flip the direction
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
relay_chn_flip_direction(i);
|
||||
@@ -339,7 +339,7 @@ TEST_CASE("All channels direction can be flipped simultaneously", "[relay_chn][c
|
||||
TEST_ESP_OK(relay_chn_get_direction_all(directions));
|
||||
test_set_expected_direction_all(RELAY_CHN_DIRECTION_FLIPPED);
|
||||
TEST_ASSERT_EQUAL_UINT_ARRAY(expect_directions, directions, CONFIG_RELAY_CHN_COUNT);
|
||||
|
||||
|
||||
// 3. Flip all back
|
||||
relay_chn_flip_direction_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
@@ -366,7 +366,7 @@ TEST_CASE("Flipping a running channel stops it and flips direction", "[relay_chn
|
||||
|
||||
// 4. Wait for the flip inertia to pass, after which it should be idle and FLIPPED
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
|
||||
|
||||
TEST_ESP_OK(relay_chn_get_state_all(states));
|
||||
test_set_expected_state_all(RELAY_CHN_STATE_IDLE);
|
||||
TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT);
|
||||
@@ -452,7 +452,7 @@ TEST_CASE("Test run limit initialization", "[relay_chn][run_limit]")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Test run limit setting boundaries", "[relay_chn][run_limit]")
|
||||
TEST_CASE("Test run limit setting boundaries", "[relay_chn][run_limit]")
|
||||
{
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
// Test minimum boundary
|
||||
@@ -482,7 +482,7 @@ TEST_CASE("Test run limit stops channel after timeout", "[relay_chn][run_limit]"
|
||||
// Check running forward
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(i));
|
||||
}
|
||||
|
||||
|
||||
// Wait for run limit timeout
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_SHORT_RUN_LIMIT_SEC * 1000 + TEST_DELAY_MARGIN_MS));
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
@@ -498,25 +498,25 @@ TEST_CASE("Test run limit reset on direction change and time out finally", "[rel
|
||||
// Wait for the NVS module task to process operations
|
||||
vTaskDelay(300 / portTICK_PERIOD_MS); // Wait 1 second
|
||||
#endif
|
||||
|
||||
|
||||
// Start running forward
|
||||
relay_chn_run_forward_all();
|
||||
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS); // Wait 1 second
|
||||
|
||||
|
||||
// Change direction before timeout
|
||||
relay_chn_run_reverse_all();
|
||||
|
||||
|
||||
// Wait for the inertia period (after which the reverse command will be dispatched)
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state(i));
|
||||
}
|
||||
|
||||
|
||||
// Timer should time out and stop the channel after the run limit time
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_SHORT_RUN_LIMIT_SEC * 1000 + TEST_DELAY_MARGIN_MS));
|
||||
|
||||
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state(i));
|
||||
}
|
||||
@@ -527,11 +527,11 @@ TEST_CASE("Test run limit persistence across stop/start", "[relay_chn][run_limit
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
// Set initial run limit
|
||||
relay_chn_set_run_limit(i, TEST_RUN_LIMIT_SEC);
|
||||
|
||||
|
||||
// Stop and start channel
|
||||
relay_chn_stop(i);
|
||||
relay_chn_run_forward(i);
|
||||
|
||||
|
||||
// Run limit should persist
|
||||
TEST_ASSERT_EQUAL(TEST_RUN_LIMIT_SEC, relay_chn_get_run_limit(i));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ TEST_CASE("Relay channels run forward and update state", "[relay_chn][core]")
|
||||
// TEST_CASE: Test that relays run in the reverse direction and update their state
|
||||
TEST_CASE("Relay channels run reverse and update state", "[relay_chn][core]")
|
||||
{
|
||||
relay_chn_run_reverse(); // relay_chn_run_reverse returns void
|
||||
relay_chn_run_reverse();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state());
|
||||
}
|
||||
@@ -60,7 +60,7 @@ TEST_CASE("Relay channels stop and update to IDLE state", "[relay_chn][core]")
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state());
|
||||
|
||||
// Now, issue the stop command
|
||||
relay_chn_stop(); // relay_chn_stop returns void
|
||||
relay_chn_stop();
|
||||
// Immediately after stop, state should be STOPPED
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state());
|
||||
@@ -85,13 +85,13 @@ TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][co
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state());
|
||||
|
||||
// 2. Issue reverse command
|
||||
relay_chn_run_reverse(); // relay_chn_run_reverse returns void
|
||||
relay_chn_run_reverse();
|
||||
// Immediately after the command, the motor should be stopped
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE_PENDING, relay_chn_get_state());
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE_PENDING, relay_chn_get_state());
|
||||
|
||||
// Wait for the inertia period (after which the reverse command will be dispatched)
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state()); // Should now be in reverse state
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][co
|
||||
TEST_CASE("Reverse to Forward transition with opposite inertia", "[relay_chn][core][inertia]")
|
||||
{
|
||||
// 1. Start in reverse direction
|
||||
relay_chn_run_reverse(); // relay_chn_run_reverse returns void
|
||||
relay_chn_run_reverse();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state());
|
||||
|
||||
@@ -127,7 +127,7 @@ TEST_CASE("Running in same direction does not incur inertia", "[relay_chn][core]
|
||||
relay_chn_run_forward();
|
||||
// As per the code, is_direction_opposite_to_current_motion should return false, so no inertia.
|
||||
// Just a short delay to check state remains the same.
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state());
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ TEST_CASE("Flipping a running channel stops it and flips direction", "[relay_chn
|
||||
// 2. Flip the direction while running
|
||||
relay_chn_flip_direction();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); // Give time for events to process
|
||||
|
||||
|
||||
// 3. The channel should stop as part of the flip process
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state());
|
||||
|
||||
@@ -197,7 +197,7 @@ TEST_CASE("Test run limit initialization", "[relay_chn][run_limit]")
|
||||
TEST_ASSERT_EQUAL(CONFIG_RELAY_CHN_RUN_LIMIT_DEFAULT_SEC, relay_chn_get_run_limit());
|
||||
}
|
||||
|
||||
TEST_CASE("Test run limit setting boundaries", "[relay_chn][run_limit]")
|
||||
TEST_CASE("Test run limit setting boundaries", "[relay_chn][run_limit]")
|
||||
{
|
||||
// Test minimum boundary
|
||||
relay_chn_set_run_limit(CONFIG_RELAY_CHN_RUN_LIMIT_MIN_SEC - 1);
|
||||
@@ -216,11 +216,11 @@ TEST_CASE("Test run limit stops channel after timeout", "[relay_chn][run_limit]"
|
||||
{
|
||||
// Set a short run limit for testing
|
||||
relay_chn_set_run_limit(TEST_SHORT_RUN_LIMIT_SEC);
|
||||
|
||||
|
||||
// Start running forward
|
||||
relay_chn_run_forward();
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state());
|
||||
|
||||
|
||||
// Wait for run limit timeout
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_SHORT_RUN_LIMIT_SEC * 1000 + TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state());
|
||||
@@ -230,22 +230,22 @@ TEST_CASE("Test run limit reset on direction change and time out finally", "[rel
|
||||
{
|
||||
// Set a short run limit
|
||||
relay_chn_set_run_limit(TEST_SHORT_RUN_LIMIT_SEC);
|
||||
|
||||
|
||||
// Start running forward
|
||||
relay_chn_run_forward();
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS); // Wait 1 second
|
||||
|
||||
|
||||
// Change direction before timeout
|
||||
relay_chn_run_reverse();
|
||||
|
||||
|
||||
// Wait for the inertia period (after which the reverse command will be dispatched)
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state());
|
||||
|
||||
|
||||
// Timer should time out and stop the channel after the run limit time
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_SHORT_RUN_LIMIT_SEC * 1000 + TEST_DELAY_MARGIN_MS));
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state());
|
||||
}
|
||||
|
||||
@@ -253,11 +253,11 @@ TEST_CASE("Test run limit persistence across stop/start", "[relay_chn][run_limit
|
||||
{
|
||||
// Set initial run limit
|
||||
relay_chn_set_run_limit(TEST_RUN_LIMIT_SEC);
|
||||
|
||||
|
||||
// Stop and start channel
|
||||
relay_chn_stop();
|
||||
relay_chn_run_forward();
|
||||
|
||||
|
||||
// Run limit should persist
|
||||
TEST_ASSERT_EQUAL(TEST_RUN_LIMIT_SEC, relay_chn_get_run_limit());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ TEST_CASE("Test direction setting and getting", "[relay_chn][nvs]")
|
||||
{
|
||||
// Test all channels
|
||||
relay_chn_direction_t dir, expect;
|
||||
|
||||
|
||||
for (int channel = 0; channel < CONFIG_RELAY_CHN_COUNT; channel++) {
|
||||
dir = channel % 2 == 0 ? RELAY_CHN_DIRECTION_DEFAULT : RELAY_CHN_DIRECTION_FLIPPED;
|
||||
TEST_ESP_OK(relay_chn_nvs_set_direction(channel, dir));
|
||||
@@ -25,7 +25,7 @@ TEST_CASE("Test direction setting and getting", "[relay_chn][nvs]")
|
||||
|
||||
// Wait for the batch commit timeout to ensure the value is written
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_NVS_TASK_TIME_OUT_MS));
|
||||
|
||||
|
||||
for (int channel = 0; channel < CONFIG_RELAY_CHN_COUNT; channel++) {
|
||||
expect = channel % 2 == 0 ? RELAY_CHN_DIRECTION_DEFAULT : RELAY_CHN_DIRECTION_FLIPPED;
|
||||
TEST_ESP_OK(relay_chn_nvs_get_direction(channel, &dir, RELAY_CHN_DIRECTION_DEFAULT));
|
||||
@@ -138,7 +138,7 @@ TEST_CASE("Test sensitivity setting and getting", "[relay_chn][nvs][tilt]")
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
test_sensitivities[i] = 70 + i; // e.g., 70, 71, 72...
|
||||
}
|
||||
|
||||
|
||||
// 1. Set all values first
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
TEST_ESP_OK(relay_chn_nvs_set_tilt_sensitivity(i, test_sensitivities[i]));
|
||||
@@ -161,7 +161,7 @@ TEST_CASE("Test tilt counter operations", "[relay_chn][nvs][tilt]")
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
test_counts[i] = 100 + i; // e.g., 100, 101, 102...
|
||||
}
|
||||
|
||||
|
||||
// 1. Set all values first
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(i, test_counts[i]));
|
||||
|
||||
@@ -21,7 +21,7 @@ TEST_CASE("Test direction setting and getting", "[relay_chn][nvs]")
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_NVS_TASK_TIME_OUT_MS)); // Allow NVS task to write and commit
|
||||
TEST_ESP_OK(relay_chn_nvs_get_direction(0, &dir, RELAY_CHN_DIRECTION_DEFAULT));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_DEFAULT, dir);
|
||||
|
||||
|
||||
// Test channel 1
|
||||
TEST_ESP_OK(relay_chn_nvs_set_direction(0, RELAY_CHN_DIRECTION_FLIPPED));
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_NVS_TASK_TIME_OUT_MS)); // Allow NVS task to write and commit
|
||||
@@ -83,7 +83,7 @@ TEST_CASE("Test run limit setting and getting", "[relay_chn][nvs][run_limit]")
|
||||
{
|
||||
const uint16_t run_limit_sec = 32;
|
||||
TEST_ESP_OK(relay_chn_nvs_set_run_limit(0, run_limit_sec));
|
||||
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_NVS_TASK_TIME_OUT_MS)); // Allow NVS task to write and commit
|
||||
uint16_t run_limit_read;
|
||||
TEST_ESP_OK(relay_chn_nvs_get_run_limit(0, &run_limit_read, CONFIG_RELAY_CHN_RUN_LIMIT_DEFAULT_SEC));
|
||||
@@ -96,7 +96,7 @@ TEST_CASE("Test sensitivity setting and getting", "[relay_chn][nvs][tilt]")
|
||||
{
|
||||
const uint8_t test_sensitivity = 75;
|
||||
TEST_ESP_OK(relay_chn_nvs_set_tilt_sensitivity(0, test_sensitivity));
|
||||
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_NVS_TASK_TIME_OUT_MS)); // Allow NVS task to write and commit
|
||||
uint8_t sensitivity;
|
||||
TEST_ESP_OK(relay_chn_nvs_get_tilt_sensitivity(0, &sensitivity, 0));
|
||||
@@ -106,10 +106,10 @@ TEST_CASE("Test sensitivity setting and getting", "[relay_chn][nvs][tilt]")
|
||||
TEST_CASE("Test tilt counter operations", "[relay_chn][nvs][tilt]")
|
||||
{
|
||||
const uint16_t tilt_count = 100;
|
||||
|
||||
|
||||
// Test setting counters
|
||||
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(0, tilt_count));
|
||||
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_NVS_TASK_TIME_OUT_MS)); // Allow NVS task to write and commit
|
||||
uint16_t tilt_count_read;
|
||||
TEST_ESP_OK(relay_chn_nvs_get_tilt_count(0, &tilt_count_read, 0));
|
||||
|
||||
@@ -30,7 +30,7 @@ void prepare_channels_for_tilt_with_mixed_runs() {
|
||||
// Ensure the channel reset tilt control
|
||||
relay_chn_tilt_stop_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
|
||||
|
||||
// Ensure the channel has had a 'last_run_cmd'
|
||||
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
if (i % 2 == 0) {
|
||||
@@ -39,7 +39,7 @@ void prepare_channels_for_tilt_with_mixed_runs() {
|
||||
relay_chn_run_reverse(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); // Allow command to process
|
||||
relay_chn_stop_all(); // Stop it to set last_run_cmd but return to FREE for next test
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
@@ -60,11 +60,11 @@ void prepare_all_channels_for_tilt(int initial_cmd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (not_idle) {
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS));
|
||||
}
|
||||
|
||||
|
||||
// Ensure the channel has had a 'last_run_cmd'
|
||||
if (initial_cmd == RELAY_CHN_CMD_FORWARD) {
|
||||
relay_chn_run_forward_all();
|
||||
@@ -74,7 +74,7 @@ void prepare_all_channels_for_tilt(int initial_cmd) {
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); // Allow command to process
|
||||
relay_chn_stop_all(); // Stop all to set last_run_cmd but return to FREE for next test
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
|
||||
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_IDLE);
|
||||
}
|
||||
|
||||
@@ -86,15 +86,15 @@ TEST_CASE("Run Forward to Tilt Forward transition with inertia", "[relay_chn][ti
|
||||
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
|
||||
|
||||
// 1. Start in forward direction
|
||||
relay_chn_run_forward_all();
|
||||
relay_chn_run_forward_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_FORWARD);
|
||||
|
||||
// 2. Issue tilt forward command
|
||||
relay_chn_tilt_forward_all();
|
||||
relay_chn_tilt_forward_all();
|
||||
// After tilt command, it should immediately stop and then trigger inertia.
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_STOPPED);
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_STOPPED);
|
||||
|
||||
// Wait for the inertia period (after which the tilt command will be dispatched)
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS));
|
||||
@@ -109,12 +109,12 @@ TEST_CASE("Run Reverse to Tilt Reverse transition with inertia", "[relay_chn][ti
|
||||
prepare_all_channels_for_tilt(RELAY_CHN_CMD_REVERSE);
|
||||
|
||||
// 1. Start in reverse direction
|
||||
relay_chn_run_reverse_all();
|
||||
relay_chn_run_reverse_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE);
|
||||
|
||||
// 2. Issue tilt reverse command
|
||||
relay_chn_tilt_reverse_all();
|
||||
relay_chn_tilt_reverse_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_STOPPED);
|
||||
|
||||
@@ -130,9 +130,9 @@ TEST_CASE("FREE to Tilt Forward transition with inertia (prepared)", "[relay_chn
|
||||
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
|
||||
|
||||
// Issue tilt forward command
|
||||
relay_chn_tilt_forward_all();
|
||||
relay_chn_tilt_forward_all();
|
||||
// From FREE state, tilt command should still incur the inertia due to the internal timer logic
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_TILT_FORWARD);
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ TEST_CASE("FREE to Tilt Reverse transition with inertia (prepared)", "[relay_chn
|
||||
prepare_all_channels_for_tilt(RELAY_CHN_CMD_REVERSE);
|
||||
|
||||
// Issue tilt reverse command
|
||||
relay_chn_tilt_reverse_all();
|
||||
relay_chn_tilt_reverse_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_TILT_REVERSE);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ TEST_CASE("Tilt Forward to Run Forward transition with inertia", "[relay_chn][ti
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_TILT_FORWARD);
|
||||
|
||||
// 2. Issue run forward command
|
||||
relay_chn_run_forward_all();
|
||||
relay_chn_run_forward_all();
|
||||
// From Tilt to Run in the same logical name but in the opposite direction, inertia is expected.
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_FORWARD_PENDING);
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
@@ -178,7 +178,7 @@ TEST_CASE("Tilt Reverse to Run Reverse transition with inertia", "[relay_chn][ti
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_TILT_REVERSE);
|
||||
|
||||
// 2. Issue run reverse command
|
||||
relay_chn_run_reverse_all();
|
||||
relay_chn_run_reverse_all();
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE_PENDING);
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE);
|
||||
@@ -195,7 +195,7 @@ TEST_CASE("Tilt Forward to Run Reverse transition without inertia", "[relay_chn]
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_TILT_FORWARD);
|
||||
|
||||
// 2. Issue run reverse command (opposite direction)
|
||||
relay_chn_run_reverse_all();
|
||||
relay_chn_run_reverse_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
check_all_channels_for_state(RELAY_CHN_STATE_REVERSE);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ TEST_CASE("tilt_stop_all stops all tilting channels", "[relay_chn][tilt][batch]"
|
||||
{
|
||||
// 1. Prepare and start all channels tilting forward
|
||||
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
|
||||
|
||||
|
||||
relay_chn_tilt_forward_all();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
|
||||
@@ -279,7 +279,7 @@ TEST_CASE("tilt_auto_all tilts channels based on last run direction", "[relay_ch
|
||||
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
relay_chn_state_t state = i % 2 == 0 ?
|
||||
RELAY_CHN_STATE_TILT_FORWARD : RELAY_CHN_STATE_TILT_REVERSE;
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(state, relay_chn_get_state(i));
|
||||
}
|
||||
}
|
||||
@@ -319,11 +319,11 @@ TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivi
|
||||
TEST_ASSERT_EQUAL_UINT8(100, relay_chn_tilt_get_sensitivity(ch));
|
||||
// Set all channels
|
||||
relay_chn_tilt_set_sensitivity_all_with(42);
|
||||
|
||||
|
||||
uint8_t vals[CONFIG_RELAY_CHN_COUNT] = {0};
|
||||
uint8_t expect[CONFIG_RELAY_CHN_COUNT];
|
||||
memset(expect, 42, CONFIG_RELAY_CHN_COUNT);
|
||||
|
||||
|
||||
TEST_ESP_OK(relay_chn_tilt_get_sensitivity_all(vals));
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY(expect, vals, CONFIG_RELAY_CHN_COUNT);
|
||||
}
|
||||
@@ -371,7 +371,6 @@ TEST_CASE("relay_chn_tilt_set_sensitivity functions handle upper boundary", "[re
|
||||
// Test tilt counter logic: forward x3, reverse x3, extra reverse fails
|
||||
TEST_CASE("tilt counter logic: forward and reverse consumption", "[relay_chn][tilt][counter]")
|
||||
{
|
||||
|
||||
// Tilt execution time at 100% sensitivity in milliseconds (10 + 90)
|
||||
#define TEST_TILT_EXECUTION_TIME_MS 100
|
||||
|
||||
|
||||
@@ -44,15 +44,15 @@ TEST_CASE("Run Forward to Tilt Forward transition with inertia", "[relay_chn][ti
|
||||
prepare_channel_for_tilt(RELAY_CHN_CMD_FORWARD);
|
||||
|
||||
// 1. Start in forward direction
|
||||
relay_chn_run_forward();
|
||||
relay_chn_run_forward();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state());
|
||||
|
||||
// 2. Issue tilt forward command
|
||||
relay_chn_tilt_forward();
|
||||
relay_chn_tilt_forward();
|
||||
// After tilt command, it should immediately stop and then trigger inertia.
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state());
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state());
|
||||
|
||||
// Wait for the inertia period (after which the tilt command will be dispatched)
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
@@ -67,12 +67,12 @@ TEST_CASE("Run Reverse to Tilt Reverse transition with inertia", "[relay_chn][ti
|
||||
prepare_channel_for_tilt(RELAY_CHN_CMD_REVERSE);
|
||||
|
||||
// 1. Start in reverse direction
|
||||
relay_chn_run_reverse();
|
||||
relay_chn_run_reverse();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state());
|
||||
|
||||
// 2. Issue tilt reverse command
|
||||
relay_chn_tilt_reverse();
|
||||
relay_chn_tilt_reverse();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state());
|
||||
|
||||
@@ -89,9 +89,9 @@ TEST_CASE("FREE to Tilt Forward transition with inertia (prepared)", "[relay_chn
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state()); // Ensure we are back to FREE
|
||||
|
||||
// Issue tilt forward command
|
||||
relay_chn_tilt_forward();
|
||||
relay_chn_tilt_forward();
|
||||
// From FREE state, tilt command should still incur the inertia due to the internal timer logic
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_TILT_FORWARD, relay_chn_get_state());
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ TEST_CASE("FREE to Tilt Reverse transition with inertia (prepared)", "[relay_chn
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state()); // Ensure we are back to FREE
|
||||
|
||||
// Issue tilt reverse command
|
||||
relay_chn_tilt_reverse();
|
||||
relay_chn_tilt_reverse();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_TILT_REVERSE, relay_chn_get_state());
|
||||
}
|
||||
@@ -120,7 +120,7 @@ TEST_CASE("Tilt Forward to Run Forward transition with inertia", "[relay_chn][ti
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_TILT_FORWARD, relay_chn_get_state());
|
||||
|
||||
// 2. Issue run forward command
|
||||
relay_chn_run_forward();
|
||||
relay_chn_run_forward();
|
||||
// From Tilt to Run in the same logical name but in the opposite direction, inertia is expected.
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD_PENDING, relay_chn_get_state());
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
@@ -138,7 +138,7 @@ TEST_CASE("Tilt Reverse to Run Reverse transition with inertia", "[relay_chn][ti
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_TILT_REVERSE, relay_chn_get_state());
|
||||
|
||||
// 2. Issue run reverse command
|
||||
relay_chn_run_reverse();
|
||||
relay_chn_run_reverse();
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE_PENDING, relay_chn_get_state());
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state());
|
||||
@@ -155,7 +155,7 @@ TEST_CASE("Tilt Forward to Run Reverse transition without inertia", "[relay_chn]
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_TILT_FORWARD, relay_chn_get_state());
|
||||
|
||||
// 2. Issue run reverse command (opposite direction)
|
||||
relay_chn_run_reverse();
|
||||
relay_chn_run_reverse();
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
|
||||
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user