1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
/**
* @file lv_arc.h
*
*/
#ifndef LV_ARC_H
#define LV_ARC_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_ARC != 0
#include "../../core/lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
enum _lv_arc_mode_t {
LV_ARC_MODE_NORMAL,
LV_ARC_MODE_SYMMETRICAL,
LV_ARC_MODE_REVERSE
};
#ifdef DOXYGEN
typedef _lv_arc_mode_t lv_arc_mode_t;
#else
typedef uint8_t lv_arc_mode_t;
#endif /*DOXYGEN*/
typedef struct {
lv_obj_t obj;
int32_t rotation;
lv_value_precise_t indic_angle_start;
lv_value_precise_t indic_angle_end;
lv_value_precise_t bg_angle_start;
lv_value_precise_t bg_angle_end;
int32_t value; /*Current value of the arc*/
int32_t min_value; /*Minimum value of the arc*/
int32_t max_value; /*Maximum value of the arc*/
uint32_t dragging : 1;
uint32_t type : 2;
uint32_t min_close : 1; /*1: the last pressed angle was closer to minimum end*/
uint32_t in_out : 1; /* 1: The click was within the background arc angles. 0: Click outside */
uint32_t chg_rate; /*Drag angle rate of change of the arc (degrees/sec)*/
uint32_t last_tick; /*Last dragging event timestamp of the arc*/
lv_value_precise_t last_angle; /*Last dragging angle of the arc*/
int16_t knob_offset; /*knob offset from the main arc*/
} lv_arc_t;
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_arc_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create an arc object
* @param parent pointer to an object, it will be the parent of the new arc
* @return pointer to the created arc
*/
lv_obj_t * lv_arc_create(lv_obj_t * parent);
/*======================
* Add/remove functions
*=====================*/
/*=====================
* Setter functions
*====================*/
/**
* Set the start angle of an arc. 0 deg: right, 90 bottom, etc.
* @param obj pointer to an arc object
* @param start the start angle. (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
void lv_arc_set_start_angle(lv_obj_t * obj, lv_value_precise_t start);
/**
* Set the end angle of an arc. 0 deg: right, 90 bottom, etc.
* @param obj pointer to an arc object
* @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
void lv_arc_set_end_angle(lv_obj_t * obj, lv_value_precise_t end);
/**
* Set the start and end angles
* @param obj pointer to an arc object
* @param start the start angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
* @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
void lv_arc_set_angles(lv_obj_t * obj, lv_value_precise_t start, lv_value_precise_t end);
/**
* Set the start angle of an arc background. 0 deg: right, 90 bottom, etc.
* @param obj pointer to an arc object
* @param start the start angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
void lv_arc_set_bg_start_angle(lv_obj_t * obj, lv_value_precise_t start);
/**
* Set the start angle of an arc background. 0 deg: right, 90 bottom etc.
* @param obj pointer to an arc object
* @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
void lv_arc_set_bg_end_angle(lv_obj_t * obj, lv_value_precise_t end);
/**
* Set the start and end angles of the arc background
* @param obj pointer to an arc object
* @param start the start angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
* @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
void lv_arc_set_bg_angles(lv_obj_t * obj, lv_value_precise_t start, lv_value_precise_t end);
/**
* Set the rotation for the whole arc
* @param obj pointer to an arc object
* @param rotation rotation angle
*/
void lv_arc_set_rotation(lv_obj_t * obj, int32_t rotation);
/**
* Set the type of arc.
* @param obj pointer to arc object
* @param type arc's mode
*/
void lv_arc_set_mode(lv_obj_t * obj, lv_arc_mode_t type);
/**
* Set a new value on the arc
* @param obj pointer to an arc object
* @param value new value
*/
void lv_arc_set_value(lv_obj_t * obj, int32_t value);
/**
* Set minimum and the maximum values of an arc
* @param obj pointer to the arc object
* @param min minimum value
* @param max maximum value
*/
void lv_arc_set_range(lv_obj_t * obj, int32_t min, int32_t max);
/**
* Set a change rate to limit the speed how fast the arc should reach the pressed point.
* @param obj pointer to an arc object
* @param rate the change rate
*/
void lv_arc_set_change_rate(lv_obj_t * obj, uint32_t rate);
/**
* Set an offset angle for the knob
* @param obj pointer to an arc object
* @param offset knob offset from main arc in degrees
*/
void lv_arc_set_knob_offset(lv_obj_t * obj, int32_t offset);
/*=====================
* Getter functions
*====================*/
/**
* Get the start angle of an arc.
* @param obj pointer to an arc object
* @return the start angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
lv_value_precise_t lv_arc_get_angle_start(lv_obj_t * obj);
/**
* Get the end angle of an arc.
* @param obj pointer to an arc object
* @return the end angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
lv_value_precise_t lv_arc_get_angle_end(lv_obj_t * obj);
/**
* Get the start angle of an arc background.
* @param obj pointer to an arc object
* @return the start angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
lv_value_precise_t lv_arc_get_bg_angle_start(lv_obj_t * obj);
/**
* Get the end angle of an arc background.
* @param obj pointer to an arc object
* @return the end angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.)
*/
lv_value_precise_t lv_arc_get_bg_angle_end(lv_obj_t * obj);
/**
* Get the value of an arc
* @param obj pointer to an arc object
* @return the value of the arc
*/
int32_t lv_arc_get_value(const lv_obj_t * obj);
/**
* Get the minimum value of an arc
* @param obj pointer to an arc object
* @return the minimum value of the arc
*/
int32_t lv_arc_get_min_value(const lv_obj_t * obj);
/**
* Get the maximum value of an arc
* @param obj pointer to an arc object
* @return the maximum value of the arc
*/
int32_t lv_arc_get_max_value(const lv_obj_t * obj);
/**
* Get whether the arc is type or not.
* @param obj pointer to an arc object
* @return arc's mode
*/
lv_arc_mode_t lv_arc_get_mode(const lv_obj_t * obj);
/**
* Get the rotation for the whole arc
* @param obj pointer to an arc object
* @return arc's current rotation
*/
int32_t lv_arc_get_rotation(const lv_obj_t * obj);
/**
* Get the current knob angle offset
* @param obj pointer to an arc object
* @return arc's current knob offset
*/
int32_t lv_arc_get_knob_offset(const lv_obj_t * obj);
/*=====================
* Other functions
*====================*/
/**
* Align an object to the current position of the arc (knob)
* @param obj pointer to an arc object
* @param obj_to_align pointer to an object to align
* @param r_offset consider the radius larger with this value (< 0: for smaller radius)
*/
void lv_arc_align_obj_to_angle(const lv_obj_t * obj, lv_obj_t * obj_to_align, int32_t r_offset);
/**
* Rotate an object to the current position of the arc (knob)
* @param obj pointer to an arc object
* @param obj_to_rotate pointer to an object to rotate
* @param r_offset consider the radius larger with this value (< 0: for smaller radius)
*/
void lv_arc_rotate_obj_to_angle(const lv_obj_t * obj, lv_obj_t * obj_to_rotate, int32_t r_offset);
/**********************
* MACROS
**********************/
#endif /*LV_USE_ARC*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_ARC_H*/
|