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

Conversation

aabadie
Copy link

@aabadie aabadie commented Mar 9, 2020

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.

@aabadie aabadie changed the title modules: use button for switch on and off the screen modules: use button for switching on and off the screen Mar 9, 2020
@FWeissenb
Copy link

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?

@FWeissenb
Copy link

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(); } }

@aabadie
Copy link
Author

aabadie commented Apr 28, 2020

Thank you @FWeissenb, I'll test your proposition. There's indeed an debouncing issue with the button.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants