1 /**
2 * @file lv_lmeter.h
3 *
4 */
5
6 #ifndef LV_LMETER_H
7 #define LV_LMETER_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_LMETER != 0
23
24 #include "../lv_core/lv_obj.h"
25
26 /*********************
27 * DEFINES
28 *********************/
29
30 /**********************
31 * TYPEDEFS
32 **********************/
33 /*Data of line meter*/
34 typedef struct
35 {
36 /*No inherited ext.*/ /*Ext. of ancestor*/
37 /*New data for this type */
38 uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/
39 uint8_t line_cnt; /*Count of lines */
40 int16_t cur_value;
41 int16_t min_value;
42 int16_t max_value;
43 } lv_lmeter_ext_t;
44
45 /*Styles*/
46 enum {
47 LV_LMETER_STYLE_MAIN,
48 };
49 typedef uint8_t lv_lmeter_style_t;
50
51 /**********************
52 * GLOBAL PROTOTYPES
53 **********************/
54
55 /**
56 * Create a line meter objects
57 * @param par pointer to an object, it will be the parent of the new line meter
58 * @param copy pointer to a line meter object, if not NULL then the new object will be copied from
59 * it
60 * @return pointer to the created line meter
61 */
62 lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy);
63
64 /*=====================
65 * Setter functions
66 *====================*/
67
68 /**
69 * Set a new value on the line meter
70 * @param lmeter pointer to a line meter object
71 * @param value new value
72 */
73 void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value);
74
75 /**
76 * Set minimum and the maximum values of a line meter
77 * @param lmeter pointer to he line meter object
78 * @param min minimum value
79 * @param max maximum value
80 */
81 void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max);
82
83 /**
84 * Set the scale settings of a line meter
85 * @param lmeter pointer to a line meter object
86 * @param angle angle of the scale (0..360)
87 * @param line_cnt number of lines
88 */
89 void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt);
90
91 /**
92 * Set the styles of a line meter
93 * @param lmeter pointer to a line meter object
94 * @param type which style should be set (can be only `LV_LMETER_STYLE_MAIN`)
95 * @param style set the style of the line meter
96 */
lv_lmeter_set_style(lv_obj_t * lmeter,lv_lmeter_style_t type,lv_style_t * style)97 static inline void lv_lmeter_set_style(lv_obj_t * lmeter, lv_lmeter_style_t type, lv_style_t * style)
98 {
99 (void)type; /*Unused*/
100 lv_obj_set_style(lmeter, style);
101 }
102
103 /*=====================
104 * Getter functions
105 *====================*/
106
107 /**
108 * Get the value of a line meter
109 * @param lmeter pointer to a line meter object
110 * @return the value of the line meter
111 */
112 int16_t lv_lmeter_get_value(const lv_obj_t * lmeter);
113
114 /**
115 * Get the minimum value of a line meter
116 * @param lmeter pointer to a line meter object
117 * @return the minimum value of the line meter
118 */
119 int16_t lv_lmeter_get_min_value(const lv_obj_t * lmeter);
120
121 /**
122 * Get the maximum value of a line meter
123 * @param lmeter pointer to a line meter object
124 * @return the maximum value of the line meter
125 */
126 int16_t lv_lmeter_get_max_value(const lv_obj_t * lmeter);
127
128 /**
129 * Get the scale number of a line meter
130 * @param lmeter pointer to a line meter object
131 * @return number of the scale units
132 */
133 uint8_t lv_lmeter_get_line_count(const lv_obj_t * lmeter);
134
135 /**
136 * Get the scale angle of a line meter
137 * @param lmeter pointer to a line meter object
138 * @return angle of the scale
139 */
140 uint16_t lv_lmeter_get_scale_angle(const lv_obj_t * lmeter);
141
142 /**
143 * Get the style of a line meter
144 * @param lmeter pointer to a line meter object
145 * @param type which style should be get (can be only `LV_LMETER_STYLE_MAIN`)
146 * @return pointer to the line meter's style
147 */
lv_lmeter_get_style(const lv_obj_t * lmeter,lv_lmeter_style_t type)148 static inline const lv_style_t * lv_lmeter_get_style(const lv_obj_t * lmeter, lv_lmeter_style_t type)
149 {
150 (void)type; /*Unused*/
151 return lv_obj_get_style(lmeter);
152 }
153
154 /**********************
155 * MACROS
156 **********************/
157
158 #endif /*LV_USE_LMETER*/
159
160 #ifdef __cplusplus
161 } /* extern "C" */
162 #endif
163
164 #endif /*LV_LMETER_H*/
165