Use original names for config parameters

The config parameter names defined in the relay_chn_defs.h file
have been changed back to their original names (with the CONFIG_ prefix),
so that they are not confused with application-level defines.

Refs #1085
This commit is contained in:
2025-08-25 10:24:13 +03:00
parent 9d3f8ddbff
commit 5afefc4dc0
21 changed files with 186 additions and 207 deletions

View File

@@ -12,11 +12,11 @@
#include "relay_chn_run_info.h"
#include "relay_chn_ctl.h"
#if RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
#include "relay_chn_tilt.h"
#endif
#if RELAY_CHN_ENABLE_NVS == 1
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
#include "relay_chn_nvs.h"
#endif
@@ -35,7 +35,7 @@ typedef struct relay_chn_listener_entry_type {
// The list that holds references to the registered listeners.
static List_t relay_chn_listener_list;
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
/*
* Run limit timer callback immediately dispatches a STOP command for the
* relevant channel as soon as the run limit time times out
@@ -90,7 +90,7 @@ esp_err_t relay_chn_create(const uint8_t* gpio_map, uint8_t gpio_count)
ESP_RETURN_ON_FALSE(gpio_map != NULL, ESP_ERR_INVALID_ARG, TAG, "gpio_map cannot be NULL");
esp_err_t ret;
#if RELAY_CHN_ENABLE_NVS == 1
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
ret = relay_chn_nvs_init();
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to initialize NVS for relay channel");
#endif
@@ -102,7 +102,7 @@ esp_err_t relay_chn_create(const uint8_t* gpio_map, uint8_t gpio_count)
// Initialize the run info
relay_chn_run_info_init();
#if RELAY_CHN_COUNT > 1
#if CONFIG_RELAY_CHN_COUNT > 1
relay_chn_output_t *outputs = relay_chn_output_get_all();
relay_chn_run_info_t *run_infos = relay_chn_run_info_get_all();
#else
@@ -114,13 +114,13 @@ esp_err_t relay_chn_create(const uint8_t* gpio_map, uint8_t gpio_count)
ret = relay_chn_ctl_init(outputs, run_infos);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to initialize relay channel control");
#if RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
// Initialize the tilt feature
#if RELAY_CHN_COUNT > 1
#if CONFIG_RELAY_CHN_COUNT > 1
relay_chn_ctl_t *chn_ctls = relay_chn_ctl_get_all();
#else
relay_chn_ctl_t *chn_ctls = relay_chn_ctl_get();
#endif // RELAY_CHN_COUNT > 1
#endif // CONFIG_RELAY_CHN_COUNT > 1
ret = relay_chn_tilt_init(chn_ctls); // Initialize tilt feature
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to initialize tilt feature");
#endif
@@ -133,13 +133,13 @@ esp_err_t relay_chn_create(const uint8_t* gpio_map, uint8_t gpio_count)
void relay_chn_destroy(void)
{
#if RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
relay_chn_tilt_deinit();
#endif
relay_chn_ctl_deinit();
relay_chn_output_deinit();
#if RELAY_CHN_ENABLE_NVS == 1
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
relay_chn_nvs_deinit();
#endif
@@ -328,7 +328,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
// 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 inertia_time_passed_ms = (uint32_t) (esp_timer_get_time() / 1000) - last_run_cmd_time_ms;
uint32_t inertia_time_ms = RELAY_CHN_OPPOSITE_INERTIA_MS - inertia_time_passed_ms;
uint32_t inertia_time_ms = CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS - inertia_time_passed_ms;
if (inertia_time_ms > 0) {
chn_ctl->pending_cmd = cmd;
relay_chn_state_t new_state = cmd == RELAY_CHN_CMD_FORWARD
@@ -366,10 +366,10 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
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_esp_timer_once(chn_ctl->inertia_timer, RELAY_CHN_OPPOSITE_INERTIA_MS);
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS);
break;
#if RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
case RELAY_CHN_STATE_TILT_FORWARD:
// Terminate tilting first
relay_chn_tilt_dispatch_cmd(chn_ctl->tilt_ctl, RELAY_CHN_TILT_CMD_STOP);
@@ -377,7 +377,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
// Schedule for running forward
chn_ctl->pending_cmd = cmd;
relay_chn_update_state(chn_ctl, RELAY_CHN_STATE_FORWARD_PENDING);
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, RELAY_CHN_OPPOSITE_INERTIA_MS);
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS);
} else if (cmd == RELAY_CHN_CMD_REVERSE) {
// Run directly since it is the same direction
relay_chn_dispatch_cmd(chn_ctl, cmd);
@@ -395,7 +395,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
// Schedule for running reverse
chn_ctl->pending_cmd = cmd;
relay_chn_update_state(chn_ctl, RELAY_CHN_STATE_REVERSE_PENDING);
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, RELAY_CHN_OPPOSITE_INERTIA_MS);
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS);
}
break;
#endif
@@ -404,16 +404,16 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
}
}
#if RELAY_CHN_COUNT > 1
#if CONFIG_RELAY_CHN_COUNT > 1
bool relay_chn_is_channel_id_valid(uint8_t chn_id)
{
bool valid = (chn_id < RELAY_CHN_COUNT) || chn_id == RELAY_CHN_ID_ALL;
bool valid = (chn_id < CONFIG_RELAY_CHN_COUNT) || chn_id == RELAY_CHN_ID_ALL;
if (!valid) {
ESP_LOGE(TAG, "Invalid channel ID: %d", chn_id);
}
return valid;
}
#endif // RELAY_CHN_COUNT > 1
#endif // CONFIG_RELAY_CHN_COUNT > 1
static void relay_chn_execute_idle(relay_chn_ctl_t *chn_ctl)
@@ -437,7 +437,7 @@ static void relay_chn_execute_stop(relay_chn_ctl_t *chn_ctl)
// Invalidate the channel's timer if it is active
esp_timer_stop(chn_ctl->inertia_timer);
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
esp_timer_stop(chn_ctl->run_limit_timer);
#endif
@@ -448,7 +448,7 @@ static void relay_chn_execute_stop(relay_chn_ctl_t *chn_ctl)
relay_chn_run_info_set_last_run_cmd_time_ms(chn_ctl->run_info, (uint32_t)(esp_timer_get_time() / 1000));
// Schedule a free command for the channel
chn_ctl->pending_cmd = RELAY_CHN_CMD_IDLE;
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, RELAY_CHN_OPPOSITE_INERTIA_MS);
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS);
} 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);
@@ -465,7 +465,7 @@ static void relay_chn_execute_forward(relay_chn_ctl_t *chn_ctl)
relay_chn_run_info_set_last_run_cmd(chn_ctl->run_info, RELAY_CHN_CMD_FORWARD);
relay_chn_update_state(chn_ctl, RELAY_CHN_STATE_FORWARD);
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
relay_chn_start_esp_timer_once(chn_ctl->run_limit_timer, chn_ctl->run_limit_sec * 1000);
#endif
}
@@ -479,7 +479,7 @@ static void relay_chn_execute_reverse(relay_chn_ctl_t *chn_ctl)
relay_chn_run_info_set_last_run_cmd(chn_ctl->run_info, RELAY_CHN_CMD_REVERSE);
relay_chn_update_state(chn_ctl, RELAY_CHN_STATE_REVERSE);
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
relay_chn_start_esp_timer_once(chn_ctl->run_limit_timer, chn_ctl->run_limit_sec * 1000);
#endif
}
@@ -489,7 +489,7 @@ static void relay_chn_execute_flip(relay_chn_ctl_t *chn_ctl)
relay_chn_output_flip(chn_ctl->output);
// Set an inertia on the channel to prevent any immediate movement
chn_ctl->pending_cmd = RELAY_CHN_CMD_IDLE;
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, RELAY_CHN_OPPOSITE_INERTIA_MS);
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS);
}
// Dispatch relay channel command
@@ -516,7 +516,7 @@ void relay_chn_dispatch_cmd(relay_chn_ctl_t *chn_ctl, relay_chn_cmd_t cmd) {
ESP_LOGD(TAG, "Unknown relay channel command!");
}
#if RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
// Reset the tilt counter when the command is either FORWARD or REVERSE
if (cmd == RELAY_CHN_CMD_FORWARD || cmd == RELAY_CHN_CMD_REVERSE) {
relay_chn_tilt_reset_count(chn_ctl->tilt_ctl);
@@ -557,7 +557,7 @@ char *relay_chn_state_str(relay_chn_state_t state)
return "FORWARD_PENDING";
case RELAY_CHN_STATE_REVERSE_PENDING:
return "REVERSE_PENDING";
#if RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
case RELAY_CHN_STATE_TILT_FORWARD:
return "TILT_FORWARD";
case RELAY_CHN_STATE_TILT_REVERSE: