own config module
This commit is contained in:
52
main/config.h
Normal file
52
main/config.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @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>
|
||||
|
||||
/**
|
||||
* @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 pwm_pin; // GPIO pin for PWM input (-1 = not configured)
|
||||
uint32_t magic; // Magic number to validate config (0xDEADBEEF) //TODO: use sha256
|
||||
} config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the config system
|
||||
* Loads configuration from NVS and initializes subsystems
|
||||
* @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 Update configuration and save to NVS
|
||||
* @param config New configuration
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t config_update_config(const config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Reset configuration to defaults
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t config_reset_config(void);
|
||||
|
||||
#endif // CONFIG_H
|
||||
Reference in New Issue
Block a user