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:
@@ -10,7 +10,7 @@
|
||||
#include "relay_chn_run_info.h"
|
||||
#include "relay_chn_tilt.h"
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
#include "relay_chn_nvs.h"
|
||||
|
||||
#define RELAY_CHN_TILT_FLUSH_DEBOUNCE_MS 3000
|
||||
@@ -63,7 +63,7 @@ typedef struct relay_chn_tilt_ctl {
|
||||
relay_chn_tilt_timing_t tilt_timing; /*!< Tilt timing structure */
|
||||
uint16_t tilt_count; /*!< Tilt count to manage forward and reverse tilts */
|
||||
esp_timer_handle_t tilt_timer; /*!< Tilt timer handle */
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
esp_timer_handle_t flush_timer; /*!< Flush timer to avoid frequent write of tilt counters */
|
||||
#endif
|
||||
} relay_chn_tilt_ctl_t;
|
||||
@@ -330,7 +330,7 @@ void relay_chn_tilt_set_sensitivity(uint8_t chn_id, uint8_t sensitivity)
|
||||
relay_chn_tilt_compute_set_sensitivity(&tilt_ctls[chn_id], sensitivity);
|
||||
}
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
relay_chn_nvs_set_tilt_sensitivity(chn_id, sensitivity);
|
||||
#endif // CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
}
|
||||
@@ -365,7 +365,7 @@ void relay_chn_tilt_set_sensitivity(uint8_t sensitivity)
|
||||
{
|
||||
relay_chn_tilt_compute_set_sensitivity(&tilt_ctl, sensitivity);
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
relay_chn_nvs_set_tilt_sensitivity(0, sensitivity);
|
||||
#endif // CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
}
|
||||
@@ -380,7 +380,7 @@ void relay_chn_tilt_reset_count(relay_chn_tilt_ctl_t *tilt_ctl)
|
||||
{
|
||||
tilt_ctl->tilt_count = 0;
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
esp_timer_stop(tilt_ctl->flush_timer);
|
||||
#endif
|
||||
}
|
||||
@@ -450,7 +450,7 @@ static uint16_t relay_chn_tilt_count_update(relay_chn_tilt_ctl_t *tilt_ctl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
static esp_err_t relay_chn_tilt_save_tilt_count(relay_chn_tilt_ctl_t *tilt_ctl)
|
||||
{
|
||||
// Save the tilt count to NVS storage
|
||||
@@ -486,7 +486,7 @@ static void relay_chn_tilt_execute_stop(relay_chn_tilt_ctl_t *tilt_ctl)
|
||||
}
|
||||
relay_chn_dispatch_cmd(tilt_ctl->chn_ctl, RELAY_CHN_CMD_STOP);
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
// Start the flush debounce timer
|
||||
relay_chn_start_esp_timer_once(tilt_ctl->flush_timer, RELAY_CHN_TILT_FLUSH_DEBOUNCE_MS);
|
||||
#endif
|
||||
@@ -599,7 +599,7 @@ static void relay_chn_tilt_timer_cb(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
static esp_err_t relay_chn_tilt_load_sensitivity(uint8_t ch, uint8_t *sensitivity)
|
||||
{
|
||||
esp_err_t ret = relay_chn_nvs_get_tilt_sensitivity(ch, sensitivity);
|
||||
@@ -648,7 +648,7 @@ static esp_err_t relay_chn_tilt_ctl_init(relay_chn_tilt_ctl_t *tilt_ctl,
|
||||
esp_err_t ret = esp_timer_create(&timer_args, &tilt_ctl->tilt_timer);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to create tilt timer for channel %d", chn_ctl->id);
|
||||
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
// Create flush timer for the tilt counters
|
||||
snprintf(timer_name, sizeof(timer_name), "relay_chn_%2d_tilt_flush_timer", chn_ctl->id);
|
||||
timer_args.callback = relay_chn_tilt_flush_timer_cb;
|
||||
@@ -666,7 +666,7 @@ esp_err_t relay_chn_tilt_init(relay_chn_ctl_t *chn_ctls)
|
||||
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
esp_err_t ret = relay_chn_tilt_load_sensitivity(i, &sensitivity);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load tilt sensitivity for channel %d", i);
|
||||
ret = relay_chn_tilt_load_tilt_count(i, &tilt_count);
|
||||
@@ -682,7 +682,7 @@ esp_err_t relay_chn_tilt_init(relay_chn_ctl_t *chn_ctls)
|
||||
#else
|
||||
sensitivity = RELAY_CHN_TILT_DEFAULT_SENSITIVITY;
|
||||
tilt_count = 0;
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
esp_err_t ret = relay_chn_tilt_load_sensitivity(0, &sensitivity);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load tilt sensitivity for channel %d", 0);
|
||||
ret = relay_chn_tilt_load_tilt_count(0, &tilt_count);
|
||||
@@ -698,7 +698,7 @@ void relay_chn_tilt_ctl_deinit(relay_chn_tilt_ctl_t *tilt_ctl)
|
||||
esp_timer_delete(tilt_ctl->tilt_timer);
|
||||
tilt_ctl->tilt_timer = NULL;
|
||||
}
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
if (tilt_ctl->flush_timer != NULL) {
|
||||
esp_timer_delete(tilt_ctl->flush_timer);
|
||||
tilt_ctl->flush_timer = NULL;
|
||||
|
||||
Reference in New Issue
Block a user