115 lines
3.2 KiB
C
115 lines
3.2 KiB
C
#ifndef LED_MANAGER_H
|
|
#define LED_MANAGER_H
|
|
|
|
#include "led_strip.h"
|
|
#include "driver/gpio.h"
|
|
#include "esp_log.h"
|
|
#include "esp_err.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
/**
|
|
* @brief LED color names available for use
|
|
*/
|
|
typedef enum
|
|
{
|
|
LED_COLOR_RED,
|
|
LED_COLOR_ORANGE,
|
|
LED_COLOR_YELLOW,
|
|
LED_COLOR_GREEN,
|
|
LED_COLOR_BLUE
|
|
} led_color_t;
|
|
|
|
/**
|
|
* @brief Initialize the LED manager with GPIO pin
|
|
*
|
|
* @param gpio_pin GPIO pin number where the LED strip is connected
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_init(int gpio_pin);
|
|
|
|
/**
|
|
* @brief Set LED color using color name with optional blinking
|
|
*
|
|
* @param color_name String name of the color (e.g., "Red", "Green", "Blue")
|
|
* @param blink Enable blinking (true) or solid color (false)
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_set_color_by_name(const char *color_name, bool blink);
|
|
|
|
/**
|
|
* @brief Set LED color using color enum with optional blinking
|
|
*
|
|
* @param color Color enum value
|
|
* @param blink Enable blinking (true) or solid color (false)
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_set_color(led_color_t color, bool blink);
|
|
|
|
/**
|
|
* @brief Set LED color using RGB values
|
|
*
|
|
* @param red Red component (0-255)
|
|
* @param green Green component (0-255)
|
|
* @param blue Blue component (0-255)
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_set_rgb(uint8_t red, uint8_t green, uint8_t blue);
|
|
|
|
/**
|
|
* @brief Set global brightness for the LED
|
|
*
|
|
* @param brightness Brightness value (0-255)
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_set_brightness(uint8_t brightness);
|
|
|
|
/**
|
|
* @brief Set LED color using HSV values
|
|
*
|
|
* @param hue Hue component (0-360)
|
|
* @param saturation Saturation component (0-255)
|
|
* @param value Value/brightness component (0-255)
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_set_hsv(uint16_t hue, uint8_t saturation, uint8_t value);
|
|
|
|
/**
|
|
* @brief Clear/turn off the LED
|
|
*
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_clear(void);
|
|
|
|
/**
|
|
* @brief Stop blinking and keep current color
|
|
*
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_stop_blinking(void);
|
|
|
|
/**
|
|
* @brief Set blink rate
|
|
*
|
|
* @param rate_ms Blink rate in milliseconds (default: 500ms)
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_set_blink_rate(uint32_t rate_ms);
|
|
|
|
/**
|
|
* @brief Deinitialize the LED manager and free resources
|
|
*
|
|
* @return esp_err_t ESP_OK on success, error code on failure
|
|
*/
|
|
esp_err_t led_manager_deinit(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // LED_MANAGER_H
|