1#!//opt/bin/lv_micropython -i
2import utime as time
3import lvgl as lv
4import display_driver
5
6def set_value(indic,v):
7    meter.set_indicator_end_value(indic, v)
8
9#
10# A meter with multiple arcs
11#
12
13meter = lv.meter(lv.scr_act())
14meter.center()
15meter.set_size(200, 200)
16
17# Remove the circle from the middle
18meter.remove_style(None, lv.PART.INDICATOR)
19
20# Add a scale first
21scale = meter.add_scale()
22meter.set_scale_ticks(scale, 11, 2, 10, lv.palette_main(lv.PALETTE.GREY))
23meter.set_scale_major_ticks(scale, 1, 2, 30, lv.color_hex3(0xeee), 10)
24meter.set_scale_range(scale, 0, 100, 270, 90)
25
26# Add a three arc indicator
27indic1 = meter.add_arc(scale, 10, lv.palette_main(lv.PALETTE.RED), 0)
28indic2 = meter.add_arc(scale, 10, lv.palette_main(lv.PALETTE.GREEN), -10)
29indic3 = meter.add_arc(scale, 10, lv.palette_main(lv.PALETTE.BLUE), -20)
30
31# Create an animation to set the value
32a1 = lv.anim_t()
33a1.init()
34a1.set_values(0, 100)
35a1.set_time(2000)
36a1.set_repeat_delay(100)
37a1.set_playback_delay(100)
38a1.set_playback_time(500)
39a1.set_var(indic1)
40a1.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
41a1.set_custom_exec_cb(lambda a,val: set_value(indic1,val))
42lv.anim_t.start(a1)
43
44a2 = lv.anim_t()
45a2.init()
46a2.set_values(0, 100)
47a2.set_time(1000)
48a2.set_repeat_delay(100)
49a2.set_playback_delay(100)
50a2.set_playback_time(1000)
51a2.set_var(indic2)
52a2.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
53a2.set_custom_exec_cb(lambda a,val: set_value(indic2,val))
54lv.anim_t.start(a2)
55
56a3 = lv.anim_t()
57a3.init()
58a3.set_values(0, 100)
59a3.set_time(1000)
60a3.set_repeat_delay(100)
61a3.set_playback_delay(100)
62a3.set_playback_time(2000)
63a3.set_var(indic3)
64a3.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
65a3.set_custom_exec_cb(lambda a,val: set_value(indic3,val))
66lv.anim_t.start(a3)
67
68
69
70