1 #include "../../lv_examples.h"
2 #if LV_USE_METER && LV_BUILD_EXAMPLES
3
4 static lv_obj_t * meter;
5
set_value(void * indic,int32_t v)6 static void set_value(void * indic, int32_t v)
7 {
8 lv_meter_set_indicator_end_value(meter, indic, v);
9 }
10
11 /**
12 * A meter with multiple arcs
13 */
lv_example_meter_2(void)14 void lv_example_meter_2(void)
15 {
16 meter = lv_meter_create(lv_scr_act());
17 lv_obj_center(meter);
18 lv_obj_set_size(meter, 200, 200);
19
20 /*Remove the circle from the middle*/
21 lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR);
22
23 /*Add a scale first*/
24 lv_meter_scale_t * scale = lv_meter_add_scale(meter);
25 lv_meter_set_scale_ticks(meter, scale, 11, 2, 10, lv_palette_main(LV_PALETTE_GREY));
26 lv_meter_set_scale_major_ticks(meter, scale, 1, 2, 30, lv_color_hex3(0xeee), 15);
27 lv_meter_set_scale_range(meter, scale, 0, 100, 270, 90);
28
29 /*Add a three arc indicator*/
30 lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_RED), 0);
31 lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_GREEN), -10);
32 lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_BLUE), -20);
33
34 /*Create an animation to set the value*/
35 lv_anim_t a;
36 lv_anim_init(&a);
37 lv_anim_set_exec_cb(&a, set_value);
38 lv_anim_set_values(&a, 0, 100);
39 lv_anim_set_repeat_delay(&a, 100);
40 lv_anim_set_playback_delay(&a, 100);
41 lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
42
43 lv_anim_set_time(&a, 2000);
44 lv_anim_set_playback_time(&a, 500);
45 lv_anim_set_var(&a, indic1);
46 lv_anim_start(&a);
47
48 lv_anim_set_time(&a, 1000);
49 lv_anim_set_playback_time(&a, 1000);
50 lv_anim_set_var(&a, indic2);
51 lv_anim_start(&a);
52
53 lv_anim_set_time(&a, 1000);
54 lv_anim_set_playback_time(&a, 2000);
55 lv_anim_set_var(&a, indic3);
56 lv_anim_start(&a);
57 }
58
59 #endif
60