1 /**
2  * @file lv_led.h
3  *
4  */
5 
6 #ifndef LV_LED_H
7 #define LV_LED_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../../../lvgl.h"
17 
18 #if LV_USE_LED
19 
20 /*********************
21  *      DEFINES
22  *********************/
23 /** Brightness when the LED if OFF */
24 #ifndef LV_LED_BRIGHT_MIN
25 # define LV_LED_BRIGHT_MIN 80
26 #endif
27 
28 /** Brightness when the LED if ON */
29 #ifndef LV_LED_BRIGHT_MAX
30 # define LV_LED_BRIGHT_MAX 255
31 #endif
32 
33 /**********************
34  *      TYPEDEFS
35  **********************/
36 
37 /*Data of led*/
38 typedef struct {
39     lv_obj_t obj;
40     lv_color_t color;
41     uint8_t bright;     /**< Current brightness of the LED (0..255)*/
42 } lv_led_t;
43 
44 extern const lv_obj_class_t lv_led_class;
45 
46 /**
47  * `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_led_class`
48  * Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
49  */
50 typedef enum {
51     LV_LED_DRAW_PART_RECTANGLE,    /**< The main rectangle*/
52 } lv_led_draw_part_type_t;
53 
54 /**********************
55  * GLOBAL PROTOTYPES
56  **********************/
57 
58 /**
59  * Create a led object
60  * @param parent pointer to an object, it will be the parent of the new led
61  * @return pointer to the created led
62  */
63 lv_obj_t * lv_led_create(lv_obj_t * parent);
64 
65 /**
66  * Set the color of the LED
67  * @param led       pointer to a LED object
68  * @param color     the color of the LED
69  */
70 void lv_led_set_color(lv_obj_t * led, lv_color_t color);
71 
72 /**
73  * Set the brightness of a LED object
74  * @param led pointer to a LED object
75  * @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light)
76  */
77 void lv_led_set_brightness(lv_obj_t * led, uint8_t bright);
78 
79 /**
80  * Light on a LED
81  * @param led pointer to a LED object
82  */
83 void lv_led_on(lv_obj_t * led);
84 
85 /**
86  * Light off a LED
87  * @param led pointer to a LED object
88  */
89 void lv_led_off(lv_obj_t * led);
90 
91 /**
92  * Toggle the state of a LED
93  * @param led pointer to a LED object
94  */
95 void lv_led_toggle(lv_obj_t * led);
96 
97 /**
98  * Get the brightness of a LEd object
99  * @param led pointer to LED object
100  * @return bright 0 (max. dark) ... 255 (max. light)
101  */
102 uint8_t lv_led_get_brightness(const lv_obj_t * obj);
103 
104 /**********************
105  *      MACROS
106  **********************/
107 
108 #endif /*LV_USE_LED*/
109 
110 #ifdef __cplusplus
111 } /*extern "C"*/
112 #endif
113 
114 #endif /*LV_LED_H*/
115