wanek
January 22, 2017, 9:57am
1
hello!
i would like to change simple timer interval dynamically from blynk app.
in setup i have this:
autoShiftTimer = timer.setInterval(response, autoShift);
timer.enable(autoShiftTimer);
to change response time, i use this:
BLYNK_WRITE(RESPONSE) {
if (response != param.asInt() * 100) {
response = param.asInt() * 100;
EEPROM.write(17, param.asInt());
EEPROM.commit();
autoShiftTimer = timer.setInterval(response, autoShift);
}
}
is this correct method?
thanks!
Costas
January 22, 2017, 10:08am
2
wanek:
BLYNK_WRITE(RESPONSE) {
No, you can’t do that as RESPONSE has to be a fixed virtual pin that you have assigned to the slider.
wanek
January 22, 2017, 10:55am
3
no, RESPONSE is != response
RESPONSE is a virtual pin define
and response is the variable to store the millis
Costas
January 22, 2017, 10:58am
4
I see, it would have been clearer for you to include the define.
What range do you have on the slider?
AFAIK you don’t have to enable a timer after you define it, it will automatically start.
What I do when changing them dynamically is delete the running timer, change the interval and create the timer again.
1 Like
wanek
January 22, 2017, 1:22pm
5
the slider range in the app is 1-20, but this value is multiplied by 100 in the hardware, so the minimum interval is 1 x 100 = 100 millis.
i use the 1 - 10 numbering on the app side, to have cleaner values on the slider.
just tested the method you reccomend, and it works.
thank you!
Geab
January 29, 2017, 3:10pm
6
Hi guys any solution that works?
or could one simply restart the timer which than will start with the new timer interval Count_Down that has been read from eg a slider
timer.setInterval(Count_Down, Thingspeak)
timer.restartTimer(wd_timer_id);
Costas
January 29, 2017, 3:13pm
7
read the post before yours.
SimpleTimer has methods to destroy timers and you can always add another one after that. I’m not sure the restart will work, but have you tried? It’s not like you can break anything with that
1 Like
I did it and works fine:
BLYNK_WRITE(V0)
{ //slide timelapse
int pinValue = param.asInt();
timer.disable(timerid);
timerid = timer.setInterval(pinValue * 1000, myCAMSaveToSDFile);
timer.enable(timerid);
}