sbus invertion in config
This commit is contained in:
@ -31,6 +31,7 @@ static const char *TAG = "CONFIG";
|
||||
#define HARDCODED_CONFIG_SBUS_TRIGGER_CHANNEL 3U // Channel 4
|
||||
#define HARDCODED_CONFIG_SBUS_THRESHOLD_LOW 800U
|
||||
#define HARDCODED_CONFIG_SBUS_THRESHOLD_HIGH 1100U
|
||||
#define HARDCODED_CONFIG_SBUS_INVERTED true // Set inverted RX for FrSky receivers (they output inverted SBUS)
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
#define HARDCODED_CONFIG_LOCALBTN_PIN 9
|
||||
@ -54,6 +55,7 @@ static config_t current_config = {
|
||||
.sbus_trigger_channel = 3,
|
||||
.sbus_threshold_low = 800,
|
||||
.sbus_threshold_high = 1100,
|
||||
.sbus_inverted = false,
|
||||
};
|
||||
|
||||
static void calculate_config_hash(const config_t *cfg, uint8_t *out_hash);
|
||||
@ -197,6 +199,7 @@ esp_err_t config_init(void)
|
||||
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;
|
||||
current_config.sbus_inverted = HARDCODED_CONFIG_SBUS_INVERTED;
|
||||
|
||||
save_config_to_nvs();
|
||||
#endif
|
||||
|
||||
@ -29,6 +29,7 @@ typedef struct
|
||||
uint8_t sbus_trigger_channel; // SBUS channel for mode trigger (0-15, typically 3 for CH4)
|
||||
uint16_t sbus_threshold_low; // SBUS low threshold (default 800)
|
||||
uint16_t sbus_threshold_high; // SBUS high threshold (default 1100)
|
||||
bool sbus_inverted; // true = SBUS in inverted mode (like FrSky), false = normal mode
|
||||
|
||||
uint8_t hash[CONFIG_HASH_LEN]; // SHA256 Hash of config
|
||||
} config_t;
|
||||
|
||||
@ -269,8 +269,11 @@ esp_err_t rcsignal_init(const config_t *config)
|
||||
ESP_ERROR_CHECK(uart_set_pin(UART_NUM, UART_PIN_NO_CHANGE, rcsignal.gpio_pin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
|
||||
ESP_ERROR_CHECK(uart_driver_install(UART_NUM, UART_BUF_SIZE * 2, 0, 0, NULL, 0));
|
||||
|
||||
// Set inverted RX for FrSky receivers (they output inverted SBUS)
|
||||
ESP_ERROR_CHECK(uart_set_line_inverse(UART_NUM, UART_SIGNAL_RXD_INV));
|
||||
if (config->sbus_inverted)
|
||||
{
|
||||
// Set inverted RX for FrSky receivers (they output inverted SBUS)
|
||||
ESP_ERROR_CHECK(uart_set_line_inverse(UART_NUM, UART_SIGNAL_RXD_INV));
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "SBUS UART configured with inverted RX");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user