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