Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

modules: use button for switching on and off the screen #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions modules/gui/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down