Files
WS2812B-LED-RC-Controller/main/config.h
2026-02-14 22:06:28 +01:00

57 lines
1.7 KiB
C

/**
* @file config.h
* @brief Config module for LED controller - handles read and store of persistent data
*/
#ifndef CONFIG_H
#define CONFIG_H
#include "esp_err.h"
#include <stdint.h>
#include <stdbool.h>
#define CONFIG_HASH_LEN 32 // SHA256
/**
* @brief Configuration structure stored in NVS
*/
typedef struct
{
int8_t led_pin_strip_a; // GPIO pin for LED strip A (-1 = not configured)
int8_t led_pin_strip_b; // GPIO pin for LED strip B (-1 = not configured)
int8_t led_count_strip_a; // LED count for LED strip A (-1 = not configured)
int8_t led_count_strip_b; // LED count for LED strip B (-1 = not configured)
int8_t rc_signal_pin; // GPIO pin for RC signal input (-1 = not configured)
int8_t localBtn_pin; // GPIO pin for local btn input (-1 = not configured)
// RC Signal mode settings
bool use_sbus_mode; // true = SBUS mode, false = PWM mode
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;
/**
* @brief Initialize the config system
* Loads configuration from NVS
* @return ESP_OK on success
*/
esp_err_t config_init(void);
/**
* @brief Get current configuration
* @param Pointer to current configuration (read-only)
*/
void config_get_config(config_t *const cnf);
/**
* @brief Reset configuration to defaults
* @return ESP_OK on success
*/
esp_err_t config_reset_config(void);
#endif // CONFIG_H