You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @brief Deinitialize the specific GPIO that works as a LED indicator
38
-
*
39
-
* @param handle GPIO handle
40
-
* @return esp_err_t
41
-
* - ESP_OK success
42
-
*/
43
-
esp_err_tled_indicator_gpio_deinit(void*handle);
44
-
45
-
/**
46
-
* @brief Set the specific GPIO's level to make the LED indicator ON or OFF
47
-
*
48
-
* @param handle GPIO handle
49
-
* @param on_off Set number to control the GPIO's level. If the LED's positive side is connected to this GPIO, then setting number greater than 0 will make the LED OFF,
50
-
* and setting 0 will make the LED ON. If the LED's negative side is connected to this GPIO, then setting 0 will make the LED OFF, and
51
-
* setting number greater than 0 will make the LED ON.
* @brief LED state: 0-100, only hardware that supports to set brightness can adjust brightness.
32
-
*
33
-
*/
34
-
enum {
35
-
LED_STATE_OFF=0, /*!< turn off the LED */
36
-
LED_STATE_25_PERCENT=64, /*!< 25% brightness, must support to set brightness */
37
-
LED_STATE_50_PERCENT=128, /*!< 50% brightness, must support to set brightness */
38
-
LED_STATE_75_PERCENT=191, /*!< 75% brightness, must support to set brightness */
39
-
LED_STATE_ON=UINT8_MAX, /*!< turn on the LED */
40
-
};
41
-
42
-
/**
43
-
* @brief actions in this type
44
-
*
45
-
*/
46
-
typedefenum {
47
-
LED_BLINK_STOP=-1, /*!< stop the blink */
48
-
LED_BLINK_HOLD, /*!< hold the on-off state */
49
-
LED_BLINK_BREATHE, /*!< breathe state */
50
-
LED_BLINK_BRIGHTNESS, /*!< set the brightness, it will transition from the old brightness to the new brightness */
51
-
LED_BLINK_RGB, /*!< color change with R(0-255) G(0-255) B(0-255) */
52
-
LED_BLINK_RGB_RING, /*!< Gradual color transition from old color to new color in a color ring */
53
-
LED_BLINK_HSV, /*!< color change with H(0-360) S(0-255) V(0-255) */
54
-
LED_BLINK_HSV_RING, /*!< Gradual color transition from old color to new color in a color ring */
55
-
LED_BLINK_LOOP, /*!< loop from first step */
56
-
} blink_step_type_t;
57
31
58
32
/**
59
-
* @brief one blink step, a meaningful signal consists of a group of steps
33
+
* @brief Creates a new LED indicator instance with the specified configuration.
60
34
*
61
-
*/
62
-
typedefstruct {
63
-
blink_step_type_ttype; /*!< action type in this step */
64
-
uint32_tvalue; /*!< hold on or off, set 0 if LED_BLINK_STOP() or LED_BLINK_LOOP */
65
-
uint32_thold_time_ms; /*!< hold time(ms), set 0 if not LED_BLINK_HOLD */
66
-
} blink_step_t;
67
-
68
-
/**
69
-
* @brief LED indicator blink mode, as a member of led_indicator_config_t
35
+
* @param cfg Pointer to a configuration structure of type _led_indicator_com_config_t
36
+
* containing initialization parameters for the LED indicator.
70
37
*
38
+
* @return Pointer to the created _led_indicator_t instance on success, or NULL on failure.
71
39
*/
72
-
typedefenum {
73
-
LED_GPIO_MODE, /*!< blink with max brightness */
74
-
LED_LEDC_MODE, /*!< blink with LEDC driver */
75
-
LED_RGB_MODE, /*!< blink with RGB driver */
76
-
LED_STRIPS_MODE, /*!< blink with LEDC strips driver */
77
-
LED_CUSTOM_MODE, /*!< blink with custom driver */
78
-
} led_indicator_mode_t;
79
-
80
-
typedefstruct {
81
-
esp_err_t (*hal_indicator_set_on_off)(void*hardware_data, boolon_off); /*!< Pointer function for setting on or off */
82
-
esp_err_t (*hal_indicator_deinit)(void*hardware_data); /*!< Pointer function for Deinitialization */
83
-
esp_err_t (*hal_indicator_set_brightness)(void*hardware_data, uint32_tbrightness); /*!< Pointer function for setting brightness, must be supported by hardware */
84
-
esp_err_t (*hal_indicator_set_rgb)(void*hardware, uint32_trgb_value); /*!< Pointer function for setting rgb, must be supported by hardware */
85
-
esp_err_t (*hal_indicator_set_hsv)(void*hardware, uint32_thsv_value); /*!< Pointer function for setting hsv, must be supported by hardware */
86
-
void*hardware_data; /*!< Hardware data of the LED indicator */
87
-
led_indicator_mode_tmode; /*!< LED work mode, eg. GPIO or pwm mode */
int*p_blink_steps; /*!< Stage of each blink list */
91
-
led_indicator_ihsv_tcurrent_fade_value; /*!< Current fade value */
92
-
led_indicator_ihsv_tlast_fade_value; /*!< Save the last value. */
93
-
uint16_tfade_value_count; /*!< Count the number of fade */
94
-
uint16_tfade_step; /*!< Step of fade */
95
-
uint16_tfade_total_step; /*!< Total step of fade */
96
-
uint32_tmax_duty; /*!< Max duty cycle from duty_resolution : 2^duty_resolution -1 */
97
-
SemaphoreHandle_tmutex; /*!< Mutex to achieve thread-safe */
98
-
TimerHandle_th_timer; /*!< LED timer handle, invalid if works in pwm mode */
99
-
blink_step_tconst**blink_lists; /*!< User defined LED blink lists */
100
-
uint16_tblink_list_num; /*!< Number of blink lists */
101
-
} _led_indicator_t;
102
-
103
-
typedefstruct_led_indicator_com_config {
104
-
esp_err_t (*hal_indicator_set_on_off)(void*hardware_data, boolon_off); /*!< Pointer function for setting on or off */
105
-
esp_err_t (*hal_indicator_deinit)(void*hardware_data); /*!< Pointer function for Deinitialization */
106
-
esp_err_t (*hal_indicator_set_brightness)(void*hardware_data, uint32_tbrightness); /*!< Pointer function for setting brightness, must be supported by hardware */
107
-
esp_err_t (*hal_indicator_set_rgb)(void*hardware, uint32_trgb_value); /*!< Pointer function for setting rgb, must be supported by hardware */
108
-
esp_err_t (*hal_indicator_set_hsv)(void*hardware, uint32_thsv_value); /*!< Pointer function for setting hsv, must be supported by hardware */
109
-
void*hardware_data; /*!< GPIO number of the LED indicator */
110
-
blink_step_tconst**blink_lists; /*!< User defined LED blink lists */
111
-
uint16_tblink_list_num; /*!< Number of blink lists */
112
-
led_indicator_duty_tduty_resolution; /*!< Resolution of duty setting in number of bits. The range of duty values is [0, (2**duty_resolution) -1]. If the brightness cannot be set, set this as 1. */
113
-
} _led_indicator_com_config_t;
114
-
115
-
typedefstruct {
116
-
blink_step_tconst**blink_lists; /*!< user defined LED blink lists */
117
-
uint16_tblink_list_num; /*!< number of blink lists */
118
-
} led_config_t;
119
-
120
-
typedefvoid*led_indicator_handle_t; /*!< LED indicator operation handle */
0 commit comments