Closed skorokithakis closed 4 years ago
Easy.
Define a task:
Scheduler ts;
Task tRelay (relayOnTime * TASK_SECOND, 2, &callback, &ts);
...
void callback () {
if ( tRelay.isFirstIteration() ) {
turnRelayOn();
return;
}
turnRelayOff();
}
Initiate the task with this:
tRelay.enableDelayed( initial delay );
That's it. Hope this helps.
Thank you! Also, is there a way to cancel the task that's already scheduled? Sometimes I have to turn the relay off in an emergency and would like the task (or all tasks) to cancel at that point.
tRelay.disable().There is a Wiki, you know, that you need to read :)On Jul 12, 2020 3:37 PM, Stavros Korokithakis notifications@github.com wrote: Thank you! Also, is there a way to cancel the task that's already scheduled? Sometimes I have to turn the relay off in an emergency and would like the task (or all tasks) to cancel at that point.
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.
I searched for "cancel" and "stop" and didn't find this, sorry 😟
I have a relay I need to turn on and then off after N seconds. I see the LED example, but it defines multiple tasks, and understanding the flow becomes a bit complicated. Is there an example where a single, one-off task is scheduled for N seconds, with an "on" and an "off" handler? That would be very much appreciated.