Open aabadie opened 4 years ago
If I try your code it doesn't seem to work. Display is only on if I hold the button. Do we need some software delay because of the button polling?
If I increase the debounce value to 300 µsec it works.
I would also handle the screen_timeout within the switch method. Atm you make a timeout_clear within the switch method and then event_tomeout_set within the _gui_button_event.
static void _gui_screen_switch(gui_t *gui) { event_timeout_clear(&gui->screen_timeout_ev); if (gui->display_on == false) { gui->display_on = true; _gui_lvgl_update(gui); hal_display_on(); event_timeout_set(&gui->screen_timeout_ev, CONFIG_GUI_SCREEN_TIMEOUT * US_PER_MS); } else { gui->display_on = false; hal_display_off(); } }
Thank you @FWeissenb, I'll test your proposition. There's indeed an debouncing issue with the button.
This is a small PR that slightly changes the button behaviour: when the screen is on, pressing the button switches it off. This is a similar behaviour as for phones and might save some power.