88 lines
2.0 KiB
C
88 lines
2.0 KiB
C
/**
|
|
* @file control.h
|
|
* @brief Control module for LED controller - handles initialization of LEDs, PWM, and Bluetooth
|
|
*/
|
|
|
|
#ifndef CONTROL_H
|
|
#define CONTROL_H
|
|
|
|
#include "esp_err.h"
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
/**
|
|
* @brief BLE auto-off timeout options
|
|
*/
|
|
typedef enum {
|
|
BLE_TIMEOUT_NEVER = 0,
|
|
BLE_TIMEOUT_1MIN = 60,
|
|
BLE_TIMEOUT_5MIN = 300
|
|
} ble_timeout_t;
|
|
|
|
/**
|
|
* @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 pwm_pin; // GPIO pin for PWM input (-1 = not configured)
|
|
ble_timeout_t ble_timeout; // BLE auto-off timeout
|
|
uint32_t magic; // Magic number to validate config (0xDEADBEEF)
|
|
} controller_config_t;
|
|
|
|
/**
|
|
* @brief Initialize the control system
|
|
* Loads configuration from NVS and initializes subsystems
|
|
* @return ESP_OK on success
|
|
*/
|
|
esp_err_t control_init(void);
|
|
|
|
/**
|
|
* @brief Get current configuration
|
|
* @return Pointer to current configuration (read-only)
|
|
*/
|
|
const controller_config_t* control_get_config(void);
|
|
|
|
/**
|
|
* @brief Update configuration and save to NVS
|
|
* @param config New configuration
|
|
* @return ESP_OK on success
|
|
*/
|
|
esp_err_t control_update_config(const controller_config_t* config);
|
|
|
|
/**
|
|
* @brief Reset configuration to defaults
|
|
* @return ESP_OK on success
|
|
*/
|
|
esp_err_t control_reset_config(void);
|
|
|
|
/**
|
|
* @brief Get BLE enabled status
|
|
* @return true if BLE is enabled
|
|
*/
|
|
bool control_is_ble_enabled(void);
|
|
|
|
/**
|
|
* @brief Manually disable BLE
|
|
*/
|
|
void control_disable_ble(void);
|
|
|
|
/**
|
|
* @brief Emulate PWM pulse (for web button)
|
|
*/
|
|
void control_emulate_pwm_pulse(void);
|
|
|
|
/**
|
|
* @brief Set animation mode manually
|
|
* @param mode Animation mode (0-13)
|
|
*/
|
|
void control_set_animation_mode(uint8_t mode);
|
|
|
|
/**
|
|
* @brief Get current animation mode
|
|
* @return Current mode (0-13)
|
|
*/
|
|
uint8_t control_get_animation_mode(void);
|
|
|
|
#endif // CONTROL_H
|