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_get_started_3.c (1122B)
1 #include "../lv_examples.h" 2 #if LV_BUILD_EXAMPLES && LV_USE_SLIDER 3 4 static lv_obj_t * label; 5 6 static void slider_event_cb(lv_event_t * e) 7 { 8 lv_obj_t * slider = lv_event_get_target(e); 9 10 /*Refresh the text*/ 11 lv_label_set_text_fmt(label, "%"LV_PRId32, lv_slider_get_value(slider)); 12 lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align top of the slider*/ 13 } 14 15 /** 16 * Create a slider and write its value on a label. 17 */ 18 void lv_example_get_started_3(void) 19 { 20 /*Create a slider in the center of the display*/ 21 lv_obj_t * slider = lv_slider_create(lv_scr_act()); 22 lv_obj_set_width(slider, 200); /*Set the width*/ 23 lv_obj_center(slider); /*Align to the center of the parent (screen)*/ 24 lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL); /*Assign an event function*/ 25 26 /*Create a label below the slider*/ 27 label = lv_label_create(lv_scr_act()); 28 lv_label_set_text(label, "0"); 29 lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align top of the slider*/ 30 } 31 32 #endif 33