I just added this to the master branch on github, and it will hopefully be available with the next release (v0.5.0). The intention is to have a simpler way to create periodic actions (currently SimpleTimer/BlynkTimer method is rather unintuitive).
the idea is interesting. i have 3 observations (so far):
shorter name, like:
TIMER_SECONDS(sec) {}```
etc
these functions should be declared outside of any functions, like the BLYNK_WRITE(xx) {} and BLYNK_READ(xx) {}, this way one could have a “clean” loop.
how can one enable / disable a timer, or modify the frequency? or ms, sec, min, hour will be a standard global variable, and it is possible to change them on the fly?
I’ve read your BlynkEveryN.h briefly and have yet to understand it all
I’m just envisioning something like
BLYNK_ONCE_N_MILLIS(ms)
BLYNK_ONCE_N_SECONDS(sec)
etc
Supply the time, internally its tracked untill it has executed once then dispose. Same principle in BlynkTimer altough I can’t at the moment see how it is replicable in your class.
@Fettkeewl, however something like this (or similar) could work:
where “some_variable > 10” is the condition to (re-)start this timeout timer.
The main problem with this, as well as with BLYNK_EVERY_N_*, that it will ONLY work inside of the loop(), and not inside of any if(). Microcontroller has to step on this construction frequently so it can verify if it needs to run the timer code.