From 06d17aa68dbb54f12d25e045395b9f9a5c264e0f Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Mon, 20 Jan 2020 15:49:02 -0600 Subject: [PATCH] samples: display: Enhance lvgl sample to support touch input Enhances the lvgl sample to support an optional touch panel input on mimxrt10{50,60,64}_evk boards. Signed-off-by: Maureen Helm --- samples/display/lvgl/README.rst | 5 ++++- samples/display/lvgl/prj.conf | 2 ++ samples/display/lvgl/src/main.c | 12 +++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/samples/display/lvgl/README.rst b/samples/display/lvgl/README.rst index 3ceb0df9439..adbd3af52e6 100644 --- a/samples/display/lvgl/README.rst +++ b/samples/display/lvgl/README.rst @@ -7,7 +7,10 @@ Overview ******** This sample application displays "Hello World" in the center of the screen -and a counter at the bottom which increments every second. +and a counter at the bottom which increments every second. If an input driver +is supported, such as the touch panel controller on mimxrt10{50,60,64}_evk +boards, "Hello World" is enclosed in a button that changes to the toggled state +when touched. Requirements ************ diff --git a/samples/display/lvgl/prj.conf b/samples/display/lvgl/prj.conf index 64efb35cb77..fb4814a9af2 100644 --- a/samples/display/lvgl/prj.conf +++ b/samples/display/lvgl/prj.conf @@ -7,3 +7,5 @@ CONFIG_LOG=y CONFIG_LVGL=y CONFIG_LVGL_OBJ_LABEL=y +CONFIG_LVGL_OBJ_CONTAINER=y +CONFIG_LVGL_OBJ_BUTTON=y diff --git a/samples/display/lvgl/src/main.c b/samples/display/lvgl/src/main.c index 9006d5e8f58..294d0be3346 100644 --- a/samples/display/lvgl/src/main.c +++ b/samples/display/lvgl/src/main.c @@ -30,7 +30,17 @@ void main(void) return; } - hello_world_label = lv_label_create(lv_scr_act(), NULL); + if (IS_ENABLED(CONFIG_LVGL_POINTER_KSCAN)) { + lv_obj_t *hello_world_button; + + hello_world_button = lv_btn_create(lv_scr_act(), NULL); + lv_obj_align(hello_world_button, NULL, LV_ALIGN_CENTER, 0, 0); + lv_btn_set_fit(hello_world_button, LV_FIT_TIGHT); + hello_world_label = lv_label_create(hello_world_button, NULL); + } else { + hello_world_label = lv_label_create(lv_scr_act(), NULL); + } + lv_label_set_text(hello_world_label, "Hello world!"); lv_obj_align(hello_world_label, NULL, LV_ALIGN_CENTER, 0, 0);