Fix config parameters check

Unnecessary `#if CONFIG_FOO == 1` checks were removed and the
statements were simplified to` #if CONFIG_FOO`.
`#ifdef CONFIG_FOO` statements were also changed to `#if CONFIG_FOO`
to keep the style as uniform as possible.

Refs #1085
This commit is contained in:
2025-08-25 10:56:01 +03:00
parent 5afefc4dc0
commit 6ff16b5797
17 changed files with 77 additions and 77 deletions

View File

@@ -12,11 +12,11 @@
#include "relay_chn_run_info.h"
#include "relay_chn_ctl.h"
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING
#include "relay_chn_tilt.h"
#endif
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
#if CONFIG_RELAY_CHN_ENABLE_NVS
#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 CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT
/*
* 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 CONFIG_RELAY_CHN_ENABLE_NVS == 1
#if CONFIG_RELAY_CHN_ENABLE_NVS
ret = relay_chn_nvs_init();
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to initialize NVS for relay channel");
#endif
@@ -114,7 +114,7 @@ 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 CONFIG_RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING
// Initialize the tilt feature
#if CONFIG_RELAY_CHN_COUNT > 1
relay_chn_ctl_t *chn_ctls = relay_chn_ctl_get_all();
@@ -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 CONFIG_RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING
relay_chn_tilt_deinit();
#endif
relay_chn_ctl_deinit();
relay_chn_output_deinit();
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
#if CONFIG_RELAY_CHN_ENABLE_NVS
relay_chn_nvs_deinit();
#endif
@@ -369,7 +369,7 @@ void relay_chn_issue_cmd(relay_chn_ctl_t* chn_ctl, relay_chn_cmd_t cmd)
relay_chn_start_esp_timer_once(chn_ctl->inertia_timer, CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS);
break;
#if CONFIG_RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING
case RELAY_CHN_STATE_TILT_FORWARD:
// Terminate tilting first
relay_chn_tilt_dispatch_cmd(chn_ctl->tilt_ctl, RELAY_CHN_TILT_CMD_STOP);
@@ -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 CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT
esp_timer_stop(chn_ctl->run_limit_timer);
#endif
@@ -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 CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT
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 CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT
relay_chn_start_esp_timer_once(chn_ctl->run_limit_timer, chn_ctl->run_limit_sec * 1000);
#endif
}
@@ -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 CONFIG_RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING
// 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 CONFIG_RELAY_CHN_ENABLE_TILTING == 1
#if CONFIG_RELAY_CHN_ENABLE_TILTING
case RELAY_CHN_STATE_TILT_FORWARD:
return "TILT_FORWARD";
case RELAY_CHN_STATE_TILT_REVERSE: