PaulS:
Suppose you have a bicycle and a circular track. Each time you go around the track, some will hold up a board with a number on it. If the number is 1, you need to stop and do the hokey pokey. If the number if 2, you stop and chug a beer. If the number is 3, you race around the track like the hounds of hell are after you.Can you see that you need to look at the board on every pass around the track, NOT what was written on the board the first time around?
Can you see that writing something on the board is COMPLETELY independent of your reading what is on the board?
You need to do three things on EVERY pass through loop():
- See if there is IR data to read. If there is, read it.
- Collect the data to display, regardless of what data needs to be displayed
- Display the required data.
You are currently ONLY displaying data when what to display changes.
You have the right idea with svjetlost() (except for the noDisplay()/display() stuff and the delay() crap).
But, you only call the function when the remote is used to change what should be displayed.
byte whatToDisplay = 0;
void loop()
{
determineWhatToDisplay();
collectData();
displayWhatNeedsToBeDisplayed();
}
void determineWhatToDisplay()
{
if (receiver.decode(&results))
{ // Down here where it belongs
if (results.value == 0xFF30CF )
{
whatToDisplay = 1;
}
else if(results.value == 0xFF18E7)
{
whatToDisplay = 2;
}
// More else if statements here
}
}
void displayWhatNeedsToBeDisplayed()
{
switch(whatToDisplay)
{
case 1:
someFunction();
break;
case 2:
svjetlost();
break;
}
}
Now, YOU fill in the rest of the else if statement, the rest of the cases, and write the collectData() function.
Thank you very much. I have to finish this project today and you saved me. I'll try doing what you said and I hope I won't mess it up this time.Have a nice day.