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