Thank you for your feedback!
I removed setResetIntervalTimeSeconds and setResetCallback from the if(clicked block) as you suggested. Running the code again, it
seems that the callback is never called again.
Well, it only seems. After debugging a bit further I owe you an apology. Nothing wrong with your code. The callback is called again. My counter, however, issn't rest to 0 - which is why the splash screen isn't shown again. I have takeOverMenuCounter = 0 in my if(clicked) block but it seems that I am messing something up with all the static functions and variables.
So, sorry for bothering you and thanks for looking into it anyway!
---
Follow up question: Does anyone know a good site / tutorial which gives me some insight on how to use static methods & variables of a class properly? Any suggestions how to fix my code are, of course, welcome as well.
EDIT (a few minutes later):
Well, here we go. Its facepalm time.
Have a look at my code and closely watch the takeOverMenuCounter:
void Screen::screenSaverCallback(unsigned int encoderValue, RenderPressMode clicked) {
// in case this is the first call to the function, display the screensaver splash screen
if (takeOverMenuCounter == 0)
showScreenSaver();
// in case the A button was pressed, give control back to tcmenu and restart the screensaver intervall timer
if(clicked) {
renderer.giveBackDisplay();
takeOverMenuCounter = 0;
}
takeOverMenuCounter++;
}
Did you notice that I increase it imidiatly after it is set to zero? That means, whenever the callback is called a second time, the counter is already at 1. Hence the splash screen not appearing again. Here ist the correct code (in case someone is looking for a similar functionality) and it is working like a charm:
void Screen::screenSaverCallback(unsigned int encoderValue, RenderPressMode clicked) {
// in case this is the first call to the function, display the screensaver splash screen
if (takeOverMenuCounter == 0) {
showScreenSaver();
takeOverMenuCounter++;
}
// in case the A button was pressed, give control back to tcmenu
if(clicked) {
takeOverMenuCounter = 0;
renderer.giveBackDisplay();
}
}