11/*
2- * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+ * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -13,89 +13,18 @@ extern "C" {
1313#include <stdint.h>
1414#include <stdbool.h>
1515#include "esp_err.h"
16- #include "led_gpio.h"
17- #include "led_ledc.h"
18- #include "led_rgb.h"
19- #include "led_strips.h"
2016#include "led_convert.h"
21- #include "led_custom .h"
17+ #include "led_types .h"
2218
23- /**
24- * @brief LED state: 0-100, only hardware that supports to set brightness can adjust brightness.
25- *
26- */
27- enum {
28- LED_STATE_OFF = 0 , /*!< turn off the LED */
29- LED_STATE_25_PERCENT = 64 , /*!< 25% brightness, must support to set brightness */
30- LED_STATE_50_PERCENT = 128 , /*!< 50% brightness, must support to set brightness */
31- LED_STATE_75_PERCENT = 191 , /*!< 75% brightness, must support to set brightness */
32- LED_STATE_ON = UINT8_MAX , /*!< turn on the LED */
33- };
34-
35- /**
36- * @brief actions in this type
37- *
38- */
39- typedef enum {
40- LED_BLINK_STOP = -1 , /*!< stop the blink */
41- LED_BLINK_HOLD , /*!< hold the on-off state */
42- LED_BLINK_BREATHE , /*!< breathe state */
43- LED_BLINK_BRIGHTNESS , /*!< set the brightness, it will transition from the old brightness to the new brightness */
44- LED_BLINK_RGB , /*!< color change with R(0-255) G(0-255) B(0-255) */
45- LED_BLINK_RGB_RING , /*!< Gradual color transition from old color to new color in a color ring */
46- LED_BLINK_HSV , /*!< color change with H(0-360) S(0-255) V(0-255) */
47- LED_BLINK_HSV_RING , /*!< Gradual color transition from old color to new color in a color ring */
48- LED_BLINK_LOOP , /*!< loop from first step */
49- } blink_step_type_t ;
50-
51- /**
52- * @brief one blink step, a meaningful signal consists of a group of steps
53- *
54- */
55- typedef struct {
56- blink_step_type_t type ; /*!< action type in this step */
57- uint32_t value ; /*!< hold on or off, set 0 if LED_BLINK_STOP() or LED_BLINK_LOOP */
58- uint32_t hold_time_ms ; /*!< hold time(ms), set 0 if not LED_BLINK_HOLD */
59- } blink_step_t ;
19+ #define LED_INDICATOR_CHECK (a , str , action ) if(!(a)) { \
20+ ESP_LOGE(TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \
21+ action; \
22+ }
6023
61- /**
62- * @brief LED indicator blink mode, as a member of led_indicator_config_t
63- *
64- */
65- typedef enum {
66- LED_GPIO_MODE , /*!< blink with max brightness */
67- LED_LEDC_MODE , /*!< blink with LEDC driver */
68- LED_RGB_MODE , /*!< blink with RGB driver */
69- LED_STRIPS_MODE , /*!< blink with LEDC strips driver */
70- LED_CUSTOM_MODE , /*!< blink with custom driver */
71- } led_indicator_mode_t ;
72-
73- /**
74- * @brief LED indicator specified configurations, as a arg when create a new indicator
75- *
76- */
77- typedef struct {
78- led_indicator_mode_t mode ; /*!< LED work mode, eg. GPIO or pwm mode */
79- union {
80- led_indicator_gpio_config_t * led_indicator_gpio_config ; /*!< LED GPIO configuration */
81- led_indicator_ledc_config_t * led_indicator_ledc_config ; /*!< LED LEDC configuration */
82- led_indicator_rgb_config_t * led_indicator_rgb_config ; /*!< LED RGB configuration */
83- led_indicator_strips_config_t * led_indicator_strips_config ; /*!< LED LEDC rgb configuration */
84- led_indicator_custom_config_t * led_indicator_custom_config ; /*!< LED custom configuration */
85- }; /**< LED configuration */
86- blink_step_t const * * blink_lists ; /*!< user defined LED blink lists */
87- uint16_t blink_list_num ; /*!< number of blink lists */
88- } led_indicator_config_t ;
89-
90- typedef void * led_indicator_handle_t ; /*!< LED indicator operation handle */
91-
92- /**
93- * @brief create a LED indicator instance with GPIO number and configuration
94- *
95- * @param config configuration of the LED, eg. GPIO level when LED off
96- * @return led_indicator_handle_t handle of the LED indicator, NULL if create failed.
97- */
98- led_indicator_handle_t led_indicator_create (const led_indicator_config_t * config );
24+ #define LED_INDICATOR_CHECK_WARNING (a , str , action ) if(!(a)) { \
25+ ESP_LOGW(TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \
26+ action; \
27+ }
9928
10029/**
10130 * @brief delete the LED indicator and release resource
0 commit comments