From 913218c48f381d75108c7f8366a0881e95f7c39e Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 9 Mar 2020 14:16:04 +0100 Subject: [PATCH] modules: use button for switch on and off the screen --- modules/gui/gui.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/gui/gui.c b/modules/gui/gui.c index a463d455..86561f5c 100644 --- a/modules/gui/gui.c +++ b/modules/gui/gui.c @@ -226,13 +226,18 @@ static void _gui_lvgl_trigger(void *arg) thread_flags_set((thread_t*)sched_threads[gui->pid], GUI_THREAD_FLAG_LVGL_HANDLE); } -static void _gui_screen_on(gui_t *gui) +static void _gui_screen_switch(gui_t *gui) { if (gui->display_on == false) { gui->display_on = true; _gui_lvgl_update(gui); hal_display_on(); } + else { + event_timeout_clear(&gui->screen_timeout_ev); + gui->display_on = false; + hal_display_off(); + } } static void _gui_enable_button(void *arg) @@ -255,7 +260,7 @@ static void _gui_button_irq(void *arg) static void _gui_button_event(event_t *event) { gui_t *gui = container_of(event, gui_t, button_press); - _gui_screen_on(gui); + _gui_screen_switch(gui); LOG_INFO("[gui] Button press event\n"); event_timeout_clear(&gui->screen_timeout_ev); event_timeout_set(&gui->screen_timeout_ev,