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 #ifdef LV_CONF_INCLUDE_SIMPLE
17 #include "lv_conf.h"
18 #else
19 #include "../../lv_conf.h"
20 #endif
21 
22 #if LV_USE_LED != 0
23 
24 #include "../lv_core/lv_obj.h"
25 
26 /*********************
27  *      DEFINES
28  *********************/
29 
30 /**********************
31  *      TYPEDEFS
32  **********************/
33 
34 /*Data of led*/
35 typedef struct
36 {
37     /*No inherited ext.*/
38     /*New data for this type */
39     uint8_t bright; /*Current brightness of the LED (0..255)*/
40 } lv_led_ext_t;
41 
42 /*Styles*/
43 enum {
44     LV_LED_STYLE_MAIN,
45 };
46 typedef uint8_t lv_led_style_t;
47 
48 /**********************
49  * GLOBAL PROTOTYPES
50  **********************/
51 
52 /**
53  * Create a led objects
54  * @param par pointer to an object, it will be the parent of the new led
55  * @param copy pointer to a led object, if not NULL then the new object will be copied from it
56  * @return pointer to the created led
57  */
58 lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy);
59 
60 /**
61  * Set the brightness of a LED object
62  * @param led pointer to a LED object
63  * @param bright 0 (max. dark) ... 255 (max. light)
64  */
65 void lv_led_set_bright(lv_obj_t * led, uint8_t bright);
66 
67 /**
68  * Light on a LED
69  * @param led pointer to a LED object
70  */
71 void lv_led_on(lv_obj_t * led);
72 
73 /**
74  * Light off a LED
75  * @param led pointer to a LED object
76  */
77 void lv_led_off(lv_obj_t * led);
78 
79 /**
80  * Toggle the state of a LED
81  * @param led pointer to a LED object
82  */
83 void lv_led_toggle(lv_obj_t * led);
84 
85 /**
86  * Set the style of a led
87  * @param led pointer to a led object
88  * @param type which style should be set (can be only `LV_LED_STYLE_MAIN`)
89  * @param style pointer to a style
90  */
lv_led_set_style(lv_obj_t * led,lv_led_style_t type,const lv_style_t * style)91 static inline void lv_led_set_style(lv_obj_t * led, lv_led_style_t type, const lv_style_t * style)
92 {
93     (void)type; /*Unused*/
94     lv_obj_set_style(led, style);
95 }
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_bright(const lv_obj_t * led);
103 
104 /**
105  * Get the style of an led object
106  * @param led pointer to an led object
107  * @param type which style should be get (can be only `LV_CHART_STYLE_MAIN`)
108  * @return pointer to the led's style
109  */
lv_led_get_style(const lv_obj_t * led,lv_led_style_t type)110 static inline const lv_style_t * lv_led_get_style(const lv_obj_t * led, lv_led_style_t type)
111 {
112     (void)type; /*Unused*/
113     return lv_obj_get_style(led);
114 }
115 
116 /**********************
117  *      MACROS
118  **********************/
119 
120 #endif /*LV_USE_LED*/
121 
122 #ifdef __cplusplus
123 } /* extern "C" */
124 #endif
125 
126 #endif /*LV_LED_H*/
127