How the new BlynkTimer works?

Dear Sirs,
looking at the release announcement for the blynk library we see:
“Important. When BlynkTimer struggles to run multiple times (due to a blocked loop), it just skips all the missed intervals, and calls your function only once. This now differs from SimpleTimer, which could call your function multiple times in this scenario.”

What does it means and how ( if ) can we have the “normal” SimpleTimer, operation in case that the new behavior of BlynkTimer is not desired?

Thanks.

+1 :wink:

Not certain, but maybe instead of using

BlynkTimer timer;

use

#include <SimpleTimer.h>

SimpleTimer timer;

it’s not from blynk , but why not !

Certainly yes but in order to optimize the memory etc usage, now that the simpletimer became blynktimer it is better to stick with it. So I think the question still looking for an answer!

Not sure I understand what you are asking?

I was just responding to the original question of

My thought is that if you do not want the behavior of the BlynkTimer, but instead want the behavior of SimpleTimer, then use SimpleTimer instead.

I believe BlynkTimer is based off of SimpleTimer.

Understood, was just throwing a possible solution out there.

I think the Developers would have a more in depth answer.

1 Like

Sure it is. Initially blynk just include it in the “blynk library” distribution, but at the latest library release, they have changed a little bit. If you go at theirs GitHub you can see exactly what the have altered. I am not programmer though…

they say “When BlynkTimer struggles to run multiple times (due to a blocked loop)”

so there is no change for us

BlynkTimer IS based on SimpleTimer… however it is also embedded in the Blynk library, so even if adding in

#include <SimpleTimer.h>

SimpleTimer timer;

Blynk will ignore that and use BlynkTimer…

1 Like

Well, it is as clearly stated, as it can be. I hit this behaviour before (when using SimpleTimer instead of BlynkTimer) and it was quite an unpleasant “feature”: Lets Initialise some Interval timer with timer.setInterval() and then call a blocking function: Let it be Blynk.begin(). Now the SimpleTimer will trigger all the timed occurences, but because there is no multitasking, it will not execute the assigned routine, just queue them. Now as soon as our Blynk.begin() will release the task stack (or whatewer it is named) our queued tasks starts to run: one by one, ignoring the preset timer… Is it expected?? NO WAY!!. That is why I dropped SimpleTimer in some tasks and were using simple if… then
Now, as the BlynkTimer supposedly corrects this (not tried yet this specific, but not rare situation) I started to use it (yet not always :wink: )
I hope it is clear now…

3 Likes