2020-09-04 04:22 AM
Could you please provide some advice or example code on how best to create a screensaver using TouchGFX?
I am looking for the classic screensaver functionality: if someone touched the display with their finger whatsoever, then the screensaver counter should reset.
When the counter reaches a threshold, then there is a transition to some kind of "screensaver screen". This could even be a Modal Box. After touching the device again, increase again the screen brightness and enter some password if necessary, to go back to the screen where the user was at previously.
I have not found a way to insert some kind of callback function into some kind of "has the screen been touched?" function. Where can I find this "has the screen been touched?" function in the TouchGFX stack, and how can I add some user level code to this?
Would appreciate any answers or tips.
Cheers!
Solved! Go to Solution.
2020-09-04 08:50 AM
For anyone reading this later trying to do something like this. Peter's answer won't work because that flex button "absorbs" all of the events and you cannot click on anything. Use this instead, this will give you the "has the screen been touched?" event which you can use to reset any kind of counters you have before transitioning to some Screensaver screen you may have.
void xxxView::handleClickEvent(const ClickEvent& evt)
{
// xxxx Your user code
// Execute default behavior
Screen::handleClickEvent(evt);
// xxxx Your user code
}
2020-09-04 04:34 AM
Your idea of a "has the screen been touched?" can easily be realized by adding a flex button covering the whole screen and setting its alpha value to 0, so it appears translucent/invisible. Then add an interaction to that button and do whatever you want.
Good luck!
/Peter
2020-09-04 04:55 AM
Thank you Peter, will try that right now. Definitely simpler than anything I was thinking, thank you for your feedback!
2020-09-04 08:50 AM
For anyone reading this later trying to do something like this. Peter's answer won't work because that flex button "absorbs" all of the events and you cannot click on anything. Use this instead, this will give you the "has the screen been touched?" event which you can use to reset any kind of counters you have before transitioning to some Screensaver screen you may have.
void xxxView::handleClickEvent(const ClickEvent& evt)
{
// xxxx Your user code
// Execute default behavior
Screen::handleClickEvent(evt);
// xxxx Your user code
}