implement new light mode (off/day/night/simulation)
missing: - fully connect it to the ui - setup duration in light settings Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
12
firmware/components/led-manager/include/color.h
Normal file
12
firmware/components/led-manager/include/color.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
} rgb_t;
|
||||
|
||||
void interpolate_color(const rgb_t start_color, const rgb_t end_color, float fraction, rgb_t *out_color);
|
@@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
enum
|
||||
{
|
||||
EVENT_LED_ON,
|
||||
EVENT_LED_OFF,
|
||||
EVENT_LED_DAY,
|
||||
EVENT_LED_NIGHT,
|
||||
EVENT_LED_REFRESH
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int value;
|
||||
} led_event_data_t;
|
||||
|
||||
uint64_t wled_init();
|
||||
|
||||
uint64_t register_handler();
|
||||
|
||||
uint64_t send_event(uint32_t event, led_event_data_t *payload);
|
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "color.h"
|
||||
#include "esp_check.h"
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -14,14 +15,6 @@ typedef enum
|
||||
LED_MODE_BLINK
|
||||
} led_mode_t;
|
||||
|
||||
// Structure for an RGB color
|
||||
typedef struct
|
||||
{
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} rgb_t;
|
||||
|
||||
// This is the structure you pass from the outside to define a behavior
|
||||
typedef struct
|
||||
{
|
||||
@@ -31,28 +24,23 @@ typedef struct
|
||||
uint32_t off_time_ms; // Only relevant for BLINK
|
||||
} led_behavior_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/**
|
||||
* @brief Initializes the status manager and the LED strip.
|
||||
*
|
||||
* @param gpio_num GPIO where the data line of the LEDs is connected.
|
||||
* @return esp_err_t ESP_OK on success.
|
||||
*/
|
||||
esp_err_t led_status_init(int gpio_num);
|
||||
__BEGIN_DECLS
|
||||
/**
|
||||
* @brief Initializes the status manager and the LED strip.
|
||||
*
|
||||
* @param gpio_num GPIO where the data line of the LEDs is connected.
|
||||
* @return esp_err_t ESP_OK on success.
|
||||
*/
|
||||
esp_err_t led_status_init(int gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Sets the lighting behavior for a single LED.
|
||||
*
|
||||
* This function is thread-safe.
|
||||
*
|
||||
* @param index Index of the LED (0 to STATUS_LED_COUNT - 1).
|
||||
* @param behavior The structure with the desired behavior.
|
||||
* @return esp_err_t ESP_OK on success, ESP_ERR_INVALID_ARG on invalid index.
|
||||
*/
|
||||
esp_err_t led_status_set_behavior(uint8_t index, led_behavior_t behavior);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @brief Sets the lighting behavior for a single LED.
|
||||
*
|
||||
* This function is thread-safe.
|
||||
*
|
||||
* @param index Index of the LED (0 to STATUS_LED_COUNT - 1).
|
||||
* @param behavior The structure with the desired behavior.
|
||||
* @return esp_err_t ESP_OK on success, ESP_ERR_INVALID_ARG on invalid index.
|
||||
*/
|
||||
esp_err_t led_status_set_behavior(uint8_t index, led_behavior_t behavior);
|
||||
__END_DECLS
|
||||
|
18
firmware/components/led-manager/include/led_strip_ws2812.h
Normal file
18
firmware/components/led-manager/include/led_strip_ws2812.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "color.h"
|
||||
#include <esp_check.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LED_STATE_OFF,
|
||||
LED_STATE_DAY,
|
||||
LED_STATE_NIGHT,
|
||||
LED_STATE_SIMULATION,
|
||||
} led_state_t;
|
||||
|
||||
__BEGIN_DECLS
|
||||
esp_err_t led_strip_init(void);
|
||||
esp_err_t led_strip_update(led_state_t state, rgb_t color);
|
||||
__END_DECLS
|
Reference in New Issue
Block a user