first commit
This commit is contained in:
commit
e6a42e28e9
4355 changed files with 4626605 additions and 0 deletions
35
libraries/lvgl/examples/widgets/arc/lv_example_arc_1.c
Normal file
35
libraries/lvgl/examples/widgets/arc/lv_example_arc_1.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include "../../lv_examples.h"
|
||||
|
||||
#if LV_USE_ARC && LV_BUILD_EXAMPLES
|
||||
|
||||
static void value_changed_event_cb(lv_event_t * e);
|
||||
|
||||
void lv_example_arc_1(void)
|
||||
{
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
|
||||
/*Create an Arc*/
|
||||
lv_obj_t * arc = lv_arc_create(lv_scr_act());
|
||||
lv_obj_set_size(arc, 150, 150);
|
||||
lv_arc_set_rotation(arc, 135);
|
||||
lv_arc_set_bg_angles(arc, 0, 270);
|
||||
lv_arc_set_value(arc, 10);
|
||||
lv_obj_center(arc);
|
||||
lv_obj_add_event_cb(arc, value_changed_event_cb, LV_EVENT_VALUE_CHANGED, label);
|
||||
|
||||
/*Manually update the label for the first time*/
|
||||
lv_event_send(arc, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
}
|
||||
|
||||
static void value_changed_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * arc = lv_event_get_target(e);
|
||||
lv_obj_t * label = lv_event_get_user_data(e);
|
||||
|
||||
lv_label_set_text_fmt(label, "%d%%", lv_arc_get_value(arc));
|
||||
|
||||
/*Rotate the label to the current position of the arc*/
|
||||
lv_arc_rotate_obj_to_angle(arc, label, 25);
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue