Maybe a feature Request: Cron.delay() in functions
Opened this issue · 1 comments
When i run CronAlarms_example.ino, is it possible to introduce a non blocking delay function into the function starting on line 93 ?
I am trying to control 4 relays, doing tasks at certain times a day, in intervals. I get time via NTP and create tasks as per the CronAlarms_example.ino file :)
Something like this?
void Repeats() {
Serial.println("15 second timer");
digitalWrite(relayPin04, HIGH);
Cron.delay(relayDelay04);
digitalWrite(relayPin04, LOW);
}
I would like it to run, but not block for other functions to be executed. Iv tried this, but it does not seem to work as how i hoped it would.
Am i doing something wrong or do you have a suggestion about how this could be done?
Thanks for a great project and thanks for your time.
*iv ended up using ESP32TimerInterrupt.h, but if you have a functionmality which actually makes it unnessasary, i would love to hear about it.
The library is not designed for multitasking. When an alarm goes off, it interrupts the program flow until it is completed (in the .delay() call). The call acts both, as a moment to check which alarms should "sound", and as the place where the attached functions are executed.
You should set a flag in the alarm routine, and take care of the complete part elsewhere (in example, in a task attached to a different core) when that flag is on.