LittlevGL  3.20.00.19
lv_gauge.h
Go to the documentation of this file.
1 
6 #ifndef LV_GAUGE_H
7 #define LV_GAUGE_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_GAUGE != 0
23 
24 /*Testing of dependencies*/
25 #if LV_USE_LMETER == 0
26 #error "lv_gauge: lv_lmeter is required. Enable it in lv_conf.h (LV_USE_LMETER 1) "
27 #endif
28 
29 #include "../lv_core/lv_obj.h"
30 #include "lv_lmeter.h"
31 #include "lv_label.h"
32 #include "lv_line.h"
33 
34 /*********************
35  * DEFINES
36  *********************/
37 
38 /**********************
39  * TYPEDEFS
40  **********************/
41 
42 /*Data of gauge*/
43 typedef struct
44 {
45  lv_lmeter_ext_t lmeter; /*Ext. of ancestor*/
46  /*New data for this type */
47  int16_t * values; /*Array of the set values (for needles) */
48  const lv_color_t * needle_colors; /*Color of the needles (lv_color_t my_colors[needle_num])*/
49  uint8_t needle_count; /*Number of needles*/
50  uint8_t label_count; /*Number of labels on the scale*/
51 } lv_gauge_ext_t;
52 
53 /*Styles*/
54 enum {
55  LV_GAUGE_STYLE_MAIN,
56 };
57 typedef uint8_t lv_gauge_style_t;
58 
59 /**********************
60  * GLOBAL PROTOTYPES
61  **********************/
62 
69 lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy);
70 
71 /*=====================
72  * Setter functions
73  *====================*/
74 
81 void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t colors[]);
82 
89 void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value);
90 
97 static inline void lv_gauge_set_range(lv_obj_t * gauge, int16_t min, int16_t max)
98 {
99  lv_lmeter_set_range(gauge, min, max);
100 }
101 
107 static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int16_t value)
108 {
109  lv_lmeter_set_value(gauge, value);
110 }
111 
121 void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt);
122 
129 static inline void lv_gauge_set_style(lv_obj_t * gauge, lv_gauge_style_t type, lv_style_t * style)
130 {
131  (void)type; /*Unused*/
132  lv_obj_set_style(gauge, style);
133 }
134 
135 /*=====================
136  * Getter functions
137  *====================*/
138 
145 int16_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle);
146 
152 uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge);
153 
159 static inline int16_t lv_gauge_get_min_value(const lv_obj_t * lmeter)
160 {
161  return lv_lmeter_get_min_value(lmeter);
162 }
163 
169 static inline int16_t lv_gauge_get_max_value(const lv_obj_t * lmeter)
170 {
171  return lv_lmeter_get_max_value(lmeter);
172 }
173 
179 static inline int16_t lv_gauge_get_critical_value(const lv_obj_t * gauge)
180 {
181  return lv_lmeter_get_value(gauge);
182 }
183 
189 uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge);
190 
196 static inline uint8_t lv_gauge_get_line_count(const lv_obj_t * gauge)
197 {
198  return lv_lmeter_get_line_count(gauge);
199 }
200 
206 static inline uint16_t lv_gauge_get_scale_angle(const lv_obj_t * gauge)
207 {
208  return lv_lmeter_get_scale_angle(gauge);
209 }
210 
217 static inline const lv_style_t * lv_gauge_get_style(const lv_obj_t * gauge, lv_gauge_style_t type)
218 {
219  (void)type; /*Unused*/
220  return lv_obj_get_style(gauge);
221 }
222 
223 /**********************
224  * MACROS
225  **********************/
226 
227 #endif /*LV_USE_GAUGE*/
228 
229 #ifdef __cplusplus
230 } /* extern "C" */
231 #endif
232 
233 #endif /*LV_GAUGE_H*/
Definition: lv_obj.h:184
const lv_style_t * lv_obj_get_style(const lv_obj_t *obj)
void lv_obj_set_style(lv_obj_t *obj, const lv_style_t *style)
Definition: lv_style.h:57
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale