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_1.c (2366B)
1 #include "../../lv_examples.h" 2 #if LV_USE_METER && LV_BUILD_EXAMPLES 3 4 static lv_obj_t * meter; 5 6 static void set_value(void * indic, int32_t v) 7 { 8 lv_meter_set_indicator_value(meter, indic, v); 9 } 10 11 /** 12 * A simple meter 13 */ 14 void lv_example_meter_1(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 /*Add a scale first*/ 21 lv_meter_scale_t * scale = lv_meter_add_scale(meter); 22 lv_meter_set_scale_ticks(meter, scale, 41, 2, 10, lv_palette_main(LV_PALETTE_GREY)); 23 lv_meter_set_scale_major_ticks(meter, scale, 8, 4, 15, lv_color_black(), 10); 24 25 lv_meter_indicator_t * indic; 26 27 /*Add a blue arc to the start*/ 28 indic = lv_meter_add_arc(meter, scale, 3, lv_palette_main(LV_PALETTE_BLUE), 0); 29 lv_meter_set_indicator_start_value(meter, indic, 0); 30 lv_meter_set_indicator_end_value(meter, indic, 20); 31 32 /*Make the tick lines blue at the start of the scale*/ 33 indic = lv_meter_add_scale_lines(meter, scale, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_BLUE), 34 false, 0); 35 lv_meter_set_indicator_start_value(meter, indic, 0); 36 lv_meter_set_indicator_end_value(meter, indic, 20); 37 38 /*Add a red arc to the end*/ 39 indic = lv_meter_add_arc(meter, scale, 3, lv_palette_main(LV_PALETTE_RED), 0); 40 lv_meter_set_indicator_start_value(meter, indic, 80); 41 lv_meter_set_indicator_end_value(meter, indic, 100); 42 43 /*Make the tick lines red at the end of the scale*/ 44 indic = lv_meter_add_scale_lines(meter, scale, lv_palette_main(LV_PALETTE_RED), lv_palette_main(LV_PALETTE_RED), false, 45 0); 46 lv_meter_set_indicator_start_value(meter, indic, 80); 47 lv_meter_set_indicator_end_value(meter, indic, 100); 48 49 /*Add a needle line indicator*/ 50 indic = lv_meter_add_needle_line(meter, scale, 4, lv_palette_main(LV_PALETTE_GREY), -10); 51 52 /*Create an animation to set the value*/ 53 lv_anim_t a; 54 lv_anim_init(&a); 55 lv_anim_set_exec_cb(&a, set_value); 56 lv_anim_set_var(&a, indic); 57 lv_anim_set_values(&a, 0, 100); 58 lv_anim_set_time(&a, 2000); 59 lv_anim_set_repeat_delay(&a, 100); 60 lv_anim_set_playback_time(&a, 500); 61 lv_anim_set_playback_delay(&a, 100); 62 lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); 63 lv_anim_start(&a); 64 } 65 66 #endif