Hi,
for delayed execution of parts of the code which is non-blocking millis() can be used. I know how the basic thing works. And I'm able to add the additional code for each delay.
But I'm looking for a more elegant solution that encapsulates the details like variables for values previousMillis, DelayTime etc.
On delphi I had a solution that could be described like this:
There was a framework for n timers where each timer could be set to any delay needed and the timers worked independent of each other.
The use was
1.) call "register_a_timer" which gives back a TimerID-Number for refering to this timer
2.) call a method for starting the timer with a certain interval
3.) call a method "TimerExpired" giving back True/False
So the code for non-blocked delayed execution looks like this:
if TimerExpired(TimerIDNr) ; // if interval is over
{
StartTimer(TimerIDNr); // restart Timer for next interval
DoSomething;
}
This would reduce the coding to the lines described above
instead of adding variables at the variable-section of code
and adding the details for storing timestamps of millis() and calculating elapsed times for each "Timer"
used.
Does anybody know a library which has such a functionality?
best regards
Stefan