-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setInterval() Bug #1
Comments
Hi Hannes, |
Fixed in the latest push in the master branch. |
Hi Anatoli, Actually Me as a user, I could perfectly live with the variant that a finished Task is disabled automatically. Particularly because you introduced the The only important thing is, that the documentation is consistent with the functionality of the code and that the promised functionality runs flawlessly. Further more, if it saves some Bytes, go for it! PS.: the good documentation was one of the reasos why I started to work with your library formerly. |
Based upon http://arduino.stackexchange.com/a/12588/10648, the extra code for _TASK_ROLLOVER_FIX should not be needed if the math is done slightly different. I updated the code and did some quick tests and it appears correct. Example arkhipenko#6 returns the same values for IDLE, but a few less ms when not compiled with IDLE. Using the setMillis() function in the SO posting, I did some quick tests with Example arkhipenko#2. using setMillis(-3000) sets the millis() value to 3 seconds before rollover. Task arkhipenko#1 gets an extra catch-up hit, but not Task arkhipenko#2. But, it works the same as the original code though when using setMillis(-3000).
over night I have been thinking about that.
We implemented the fix it by placing:
if (iEnabled) enable();
intoTask::setIterations()
.I am not sure if that is completely right and if it should not be like:
You have to decide if that makes sense . My motivation was:
enable()
resets theiPreviousMillis
value. But in the case, that the Task is still running, this would destroy the current interval.I have a Task running. Its Interval is set to 1o.ooo ms. Every 1o seconds the callback is run.
Four seconds after the callback was run, I call
Task::setIterations()
this will reset the Value ofiPreviousMillis
in a way that the task is due to run immediately. But it should wait another six seconds.I placed it before the reset of the Variables so that I have the untouched
iIterations
to compare. I think that is OK too.You wrote that you have placed the fix into
Task::set()
too. I Think that was not necessary, before I knew what the Problem was and before there wasTask::restart()
I used fullTask::set()
as workaround forTask::setIterations()
, because there it worked without any Problems. Although now, looking at the code I cannot understand why.PS.: great Library, Thank You.
The text was updated successfully, but these errors were encountered: