1 /**
2  * @file lv_linemeter.h
3  *
4  */
5 
6 #ifndef LV_LINEMETER_H
7 #define LV_LINEMETER_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../lv_conf_internal.h"
17 
18 #if LV_USE_LINEMETER != 0
19 
20 #include "../lv_core/lv_obj.h"
21 
22 /*********************
23  *      DEFINES
24  *********************/
25 
26 /**********************
27  *      TYPEDEFS
28  **********************/
29 /*Data of line meter*/
30 typedef struct {
31     /*No inherited ext.*/ /*Ext. of ancestor*/
32     /*New data for this type */
33     uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/
34     uint16_t angle_ofs;
35     uint16_t line_cnt;     /*Count of lines */
36     int32_t cur_value;
37     int32_t min_value;
38     int32_t max_value;
39     uint8_t mirrored : 1;
40 } lv_linemeter_ext_t;
41 
42 /*Styles*/
43 enum {
44     LV_LINEMETER_PART_MAIN,
45     _LV_LINEMETER_PART_VIRTUAL_LAST,
46     _LV_LINEMETER_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST,
47 };
48 typedef uint8_t lv_linemeter_part_t;
49 
50 /**********************
51  * GLOBAL PROTOTYPES
52  **********************/
53 
54 /**
55  * Create a line meter objects
56  * @param par pointer to an object, it will be the parent of the new line meter
57  * @param copy pointer to a line meter object, if not NULL then the new object will be copied from
58  * it
59  * @return pointer to the created line meter
60  */
61 lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy);
62 
63 /*=====================
64  * Setter functions
65  *====================*/
66 
67 /**
68  * Set a new value on the line meter
69  * @param lmeter pointer to a line meter object
70  * @param value new value
71  */
72 void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value);
73 
74 /**
75  * Set minimum and the maximum values of a line meter
76  * @param lmeter pointer to he line meter object
77  * @param min minimum value
78  * @param max maximum value
79  */
80 void lv_linemeter_set_range(lv_obj_t * lmeter, int32_t min, int32_t max);
81 
82 /**
83  * Set the scale settings of a line meter
84  * @param lmeter pointer to a line meter object
85  * @param angle angle of the scale (0..360)
86  * @param line_cnt number of lines
87  */
88 void lv_linemeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint16_t line_cnt);
89 
90 /**
91  * Set the set an offset for the line meter's angles to rotate it.
92  * @param lmeter pointer to a line meter object
93  * @param angle angle offset (0..360), rotates clockwise
94  */
95 void lv_linemeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle);
96 
97 /**
98  * Set the orientation of the meter growth, clockwise or counterclockwise (mirrored)
99  * @param lmeter pointer to a line meter object
100  * @param mirror mirror setting
101  */
102 void lv_linemeter_set_mirror(lv_obj_t * lmeter, bool mirror);
103 
104 /*=====================
105  * Getter functions
106  *====================*/
107 
108 /**
109  * Get the value of a line meter
110  * @param lmeter pointer to a line meter object
111  * @return the value of the line meter
112  */
113 int32_t lv_linemeter_get_value(const lv_obj_t * lmeter);
114 
115 /**
116  * Get the minimum value of a line meter
117  * @param lmeter pointer to a line meter object
118  * @return the minimum value of the line meter
119  */
120 int32_t lv_linemeter_get_min_value(const lv_obj_t * lmeter);
121 
122 /**
123  * Get the maximum value of a line meter
124  * @param lmeter pointer to a line meter object
125  * @return the maximum value of the line meter
126  */
127 int32_t lv_linemeter_get_max_value(const lv_obj_t * lmeter);
128 
129 /**
130  * Get the scale number of a line meter
131  * @param lmeter pointer to a line meter object
132  * @return number of the scale units
133  */
134 uint16_t lv_linemeter_get_line_count(const lv_obj_t * lmeter);
135 
136 /**
137  * Get the scale angle of a line meter
138  * @param lmeter pointer to a line meter object
139  * @return angle of the scale
140  */
141 uint16_t lv_linemeter_get_scale_angle(const lv_obj_t * lmeter);
142 
143 /**
144  * Get the offset for the line meter.
145  * @param lmeter pointer to a line meter object
146  * @return angle offset (0..360)
147  */
148 uint16_t lv_linemeter_get_angle_offset(lv_obj_t * lmeter);
149 
150 
151 void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_t part);
152 
153 /**
154  * get the mirror setting for the line meter
155  * @param lmeter pointer to a line meter object
156  * @return mirror (true or false)
157  */
158 bool lv_linemeter_get_mirror(lv_obj_t * lmeter);
159 
160 /**********************
161  *      MACROS
162  **********************/
163 
164 #endif /*LV_USE_LINEMETER*/
165 
166 #ifdef __cplusplus
167 } /* extern "C" */
168 #endif
169 
170 #endif /*LV_LINEMETER_H*/
171