1 #include "../../lv_examples.h" 2 #if LV_USE_OBSERVER && LV_USE_SLIDER && LV_USE_LABEL && LV_BUILD_EXAMPLES 3 4 static lv_subject_t temperature_subject; 5 6 /** 7 * A slider sends a message on value change and a label display's that value 8 */ lv_example_observer_1(void)9void lv_example_observer_1(void) 10 { 11 lv_subject_init_int(&temperature_subject, 28); 12 13 /*Create a slider in the center of the display*/ 14 lv_obj_t * slider = lv_slider_create(lv_screen_active()); 15 lv_obj_center(slider); 16 lv_slider_bind_value(slider, &temperature_subject); 17 18 /*Create a label below the slider*/ 19 lv_obj_t * label = lv_label_create(lv_screen_active()); 20 lv_obj_align(label, LV_ALIGN_CENTER, 0, 30); 21 lv_label_bind_text(label, &temperature_subject, "%d °C"); 22 } 23 24 #endif 25