define SBUS in config
This commit is contained in:
@ -26,7 +26,11 @@ static const char *TAG = "CONFIG";
|
||||
#define HARDCODED_CONFIG_LED_STRIP_B_PIN 3U
|
||||
#define HARDCODED_CONFIG_LED_STRIP_A_COUNT 9U
|
||||
#define HARDCODED_CONFIG_LED_STRIP_B_COUNT 9U
|
||||
#define HARDCODED_CONFIG_PWM_PIN 1U
|
||||
#define HARDCODED_CONFIG_RC_SIGNAL_PIN 1U
|
||||
#define HARDCODED_CONFIG_USE_SBUS_MODE true
|
||||
#define HARDCODED_CONFIG_SBUS_TRIGGER_CHANNEL 3U // Channel 4
|
||||
#define HARDCODED_CONFIG_SBUS_THRESHOLD_LOW 800U
|
||||
#define HARDCODED_CONFIG_SBUS_THRESHOLD_HIGH 1100U
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
#define HARDCODED_CONFIG_LOCALBTN_PIN 9
|
||||
@ -44,8 +48,13 @@ static config_t current_config = {
|
||||
.led_pin_strip_b = -1,
|
||||
.led_count_strip_a = -1,
|
||||
.led_count_strip_b = -1,
|
||||
.pwm_pin = -1,
|
||||
.localBtn_pin = -1};
|
||||
.rc_signal_pin = -1,
|
||||
.localBtn_pin = -1,
|
||||
.use_sbus_mode = false,
|
||||
.sbus_trigger_channel = 3,
|
||||
.sbus_threshold_low = 800,
|
||||
.sbus_threshold_high = 1100,
|
||||
};
|
||||
|
||||
static void calculate_config_hash(const config_t *cfg, uint8_t *out_hash);
|
||||
|
||||
@ -88,7 +97,13 @@ static esp_err_t load_config_from_nvs(void)
|
||||
ESP_LOGI(TAG, " Strip B: GPIO%d", current_config.led_pin_strip_b);
|
||||
ESP_LOGI(TAG, " Strip A LED count: %d", current_config.led_count_strip_a);
|
||||
ESP_LOGI(TAG, " Strip B LED count: %d", current_config.led_count_strip_b);
|
||||
ESP_LOGI(TAG, " PWM Pin: GPIO%d", current_config.pwm_pin);
|
||||
ESP_LOGI(TAG, " RC Signal Pin: GPIO%d", current_config.rc_signal_pin);
|
||||
ESP_LOGI(TAG, " RC Signal Mode: %s", current_config.use_sbus_mode ? "SBUS" : "PWM");
|
||||
if (current_config.use_sbus_mode)
|
||||
{
|
||||
ESP_LOGI(TAG, " SBUS Trigger Channel: %d", current_config.sbus_trigger_channel + 1);
|
||||
ESP_LOGI(TAG, " SBUS Thresholds: %d / %d", current_config.sbus_threshold_low, current_config.sbus_threshold_high);
|
||||
}
|
||||
ESP_LOGI(TAG, " Local btn Pin: GPIO%d", current_config.localBtn_pin);
|
||||
|
||||
return ESP_OK;
|
||||
@ -131,8 +146,12 @@ esp_err_t config_reset_config(void)
|
||||
current_config.led_pin_strip_b = -1;
|
||||
current_config.led_count_strip_a = -1;
|
||||
current_config.led_count_strip_b = -1;
|
||||
current_config.pwm_pin = -1;
|
||||
current_config.rc_signal_pin = -1;
|
||||
current_config.localBtn_pin = -1;
|
||||
current_config.use_sbus_mode = false;
|
||||
current_config.sbus_trigger_channel = 3;
|
||||
current_config.sbus_threshold_low = 800;
|
||||
current_config.sbus_threshold_high = 1100;
|
||||
|
||||
return save_config_to_nvs();
|
||||
}
|
||||
@ -143,8 +162,12 @@ void config_get_config(config_t *const cnf)
|
||||
cnf->led_pin_strip_b = current_config.led_pin_strip_b;
|
||||
cnf->led_count_strip_a = current_config.led_count_strip_a;
|
||||
cnf->led_count_strip_b = current_config.led_count_strip_b;
|
||||
cnf->pwm_pin = current_config.pwm_pin;
|
||||
cnf->rc_signal_pin = current_config.rc_signal_pin;
|
||||
cnf->localBtn_pin = current_config.localBtn_pin;
|
||||
cnf->use_sbus_mode = current_config.use_sbus_mode;
|
||||
cnf->sbus_trigger_channel = current_config.sbus_trigger_channel;
|
||||
cnf->sbus_threshold_low = current_config.sbus_threshold_low;
|
||||
cnf->sbus_threshold_high = current_config.sbus_threshold_high;
|
||||
}
|
||||
|
||||
esp_err_t config_init(void)
|
||||
@ -168,8 +191,12 @@ esp_err_t config_init(void)
|
||||
current_config.led_pin_strip_b = HARDCODED_CONFIG_LED_STRIP_B_PIN;
|
||||
current_config.led_count_strip_a = HARDCODED_CONFIG_LED_STRIP_A_COUNT;
|
||||
current_config.led_count_strip_b = HARDCODED_CONFIG_LED_STRIP_B_COUNT;
|
||||
current_config.pwm_pin = HARDCODED_CONFIG_PWM_PIN;
|
||||
current_config.rc_signal_pin = HARDCODED_CONFIG_RC_SIGNAL_PIN;
|
||||
current_config.localBtn_pin = HARDCODED_CONFIG_LOCALBTN_PIN;
|
||||
current_config.use_sbus_mode = HARDCODED_CONFIG_USE_SBUS_MODE;
|
||||
current_config.sbus_trigger_channel = HARDCODED_CONFIG_SBUS_TRIGGER_CHANNEL;
|
||||
current_config.sbus_threshold_low = HARDCODED_CONFIG_SBUS_THRESHOLD_LOW;
|
||||
current_config.sbus_threshold_high = HARDCODED_CONFIG_SBUS_THRESHOLD_HIGH;
|
||||
|
||||
save_config_to_nvs();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user