Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_objx/lv_gauge.h
1476 views
1
/**
2
* @file lv_gauge.h
3
*
4
*/
5
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 USE_LV_GAUGE != 0
23
24
/*Testing of dependencies*/
25
#if USE_LV_LMETER == 0
26
#error "lv_gauge: lv_lmeter is required. Enable it in lv_conf.h (USE_LV_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
/**********************
54
* GLOBAL PROTOTYPES
55
**********************/
56
57
/**
58
* Create a gauge objects
59
* @param par pointer to an object, it will be the parent of the new gauge
60
* @param copy pointer to a gauge object, if not NULL then the new object will be copied from it
61
* @return pointer to the created gauge
62
*/
63
lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy);
64
65
/*=====================
66
* Setter functions
67
*====================*/
68
69
/**
70
* Set the number of needles
71
* @param gauge pointer to gauge object
72
* @param needle_cnt new count of needles
73
* @param colors an array of colors for needles (with 'num' elements)
74
*/
75
void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t * colors);
76
77
/**
78
* Set the value of a needle
79
* @param gauge pointer to a gauge
80
* @param needle_id the id of the needle
81
* @param value the new value
82
*/
83
void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value);
84
85
/**
86
* Set minimum and the maximum values of a gauge
87
* @param gauge pointer to he gauge object
88
* @param min minimum value
89
* @param max maximum value
90
*/
91
static inline void lv_gauge_set_range(lv_obj_t *gauge, int16_t min, int16_t max)
92
{
93
lv_lmeter_set_range(gauge, min, max);
94
}
95
96
/**
97
* Set a critical value on the scale. After this value 'line.color' scale lines will be drawn
98
* @param gauge pointer to a gauge object
99
* @param value the critical value
100
*/
101
static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int16_t value)
102
{
103
lv_lmeter_set_value(gauge, value);
104
}
105
106
/**
107
* Set the scale settings of a gauge
108
* @param gauge pointer to a gauge object
109
* @param angle angle of the scale (0..360)
110
* @param line_cnt count of scale lines.
111
* The get a given "subdivision" lines between label, `line_cnt` = (sub_div + 1) * (label_cnt - 1) + 1
112
* @param label_cnt count of scale labels.
113
*/
114
void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt);
115
116
/**
117
* Set the styles of a gauge
118
* @param gauge pointer to a gauge object
119
* @param bg set the style of the gauge
120
* */
121
static inline void lv_gauge_set_style(lv_obj_t *gauge, lv_style_t *bg)
122
{
123
lv_obj_set_style(gauge, bg);
124
}
125
126
/*=====================
127
* Getter functions
128
*====================*/
129
130
/**
131
* Get the value of a needle
132
* @param gauge pointer to gauge object
133
* @param needle the id of the needle
134
* @return the value of the needle [min,max]
135
*/
136
int16_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle);
137
138
/**
139
* Get the count of needles on a gauge
140
* @param gauge pointer to gauge
141
* @return count of needles
142
*/
143
uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge);
144
145
/**
146
* Get the minimum value of a gauge
147
* @param gauge pointer to a gauge object
148
* @return the minimum value of the gauge
149
*/
150
static inline int16_t lv_gauge_get_min_value(const lv_obj_t * lmeter)
151
{
152
return lv_lmeter_get_min_value(lmeter);
153
}
154
155
/**
156
* Get the maximum value of a gauge
157
* @param gauge pointer to a gauge object
158
* @return the maximum value of the gauge
159
*/
160
static inline int16_t lv_gauge_get_max_value(const lv_obj_t * lmeter)
161
{
162
return lv_lmeter_get_max_value(lmeter);
163
}
164
165
/**
166
* Get a critical value on the scale.
167
* @param gauge pointer to a gauge object
168
* @return the critical value
169
*/
170
static inline int16_t lv_gauge_get_critical_value(const lv_obj_t * gauge)
171
{
172
return lv_lmeter_get_value(gauge);
173
}
174
175
/**
176
* Set the number of labels (and the thicker lines too)
177
* @param gauge pointer to a gauge object
178
* @return count of labels
179
*/
180
uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge);
181
182
/**
183
* Get the scale number of a gauge
184
* @param gauge pointer to a gauge object
185
* @return number of the scale units
186
*/
187
static inline uint8_t lv_gauge_get_line_count(const lv_obj_t * gauge)
188
{
189
return lv_lmeter_get_line_count(gauge);
190
}
191
192
/**
193
* Get the scale angle of a gauge
194
* @param gauge pointer to a gauge object
195
* @return angle of the scale
196
*/
197
static inline uint16_t lv_gauge_get_scale_angle(const lv_obj_t * gauge)
198
{
199
return lv_lmeter_get_scale_angle(gauge);
200
}
201
202
/**
203
* Get the style of a gauge
204
* @param gauge pointer to a gauge object
205
* @return pointer to the gauge's style
206
*/
207
static inline lv_style_t * lv_gauge_get_style(const lv_obj_t *gauge)
208
{
209
return lv_obj_get_style(gauge);
210
}
211
212
/**********************
213
* MACROS
214
**********************/
215
216
#endif /*USE_LV_GAUGE*/
217
218
#ifdef __cplusplus
219
} /* extern "C" */
220
#endif
221
222
#endif /*LV_GAUGE_H*/
223
224