V853 LVGL app添加slider change调节屏幕亮度回调事件
-
diff --git a/demos/widgets/lv_demo_widgets.c b/demos/widgets/lv_demo_widgets.c index 839b999c0..d2a6f4ac5 100644 --- a/demos/widgets/lv_demo_widgets.c +++ b/demos/widgets/lv_demo_widgets.c @@ -304,6 +304,8 @@ static void profile_create(lv_obj_t * parent) lv_obj_add_style(experience_label, &style_text_muted, 0); lv_obj_t * slider1 = lv_slider_create(panel3); + lv_slider_set_range(slider1, 0, 255); + lv_slider_set_value(slider1, 255, LV_ANIM_ON); lv_obj_set_width(slider1, LV_PCT(95)); lv_obj_add_event_cb(slider1, slider_event_cb, LV_EVENT_ALL, NULL); lv_obj_refresh_ext_draw_size(slider1); @@ -1275,14 +1277,24 @@ static void calendar_event_cb(lv_event_t * e) static void slider_event_cb(lv_event_t * e) { + char cmd[512]; lv_event_code_t code = lv_event_get_code(e); lv_obj_t * obj = lv_event_get_target(e); + int32_t value = lv_slider_get_value(obj); if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) { lv_coord_t * s = lv_event_get_param(e); *s = LV_MAX(*s, 60); } + else if(code == LV_EVENT_VALUE_CHANGED) + { + memset(cmd, sizeof(cmd), 0); + snprintf(cmd, sizeof(cmd)-1, "cd /sys/kernel/debug/dispdbg; echo lcd0 > name; echo setbl > command; echo %d > param; echo 1 > start\n", value); + system(cmd); + printf(cmd); + } else if(code == LV_EVENT_DRAW_PART_END) { + lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e); if(dsc->part == LV_PART_KNOB && lv_obj_has_state(obj, LV_STATE_PRESSED)) { char buf[8];
-
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号