Can some confirm that I can’t have any arguments on the Software Timer function when creating the timer? I have a work around but it’s not a clean as I would like it.
Below is sample code.
int CloudRelayInChange(String command) {
bool value = 0;
// Do stuff.......
}
void Switch4TimerFunction(){
Particle.publish("Switch4TimerFunction", "4");
CloudRelayInChange("4");
}
// This failes compiling every time Timer TimerSwitch4(50000, CloudRelayInChange("4"), true);
Timer TimerSwitch4(50000, Switch4TimerFunction, true); // This works
void setup() {
TimerSwitch4.start()
}
No, Timer TimerSwitch4(50000, CloudRelayInChange("4"), true) can’t work since the constructor for Timer expects a function pointer and not the return value of a function.
Acutally it expects a function pointer to a void fn(void) and not a function pointer to a function like this int fn(String).
But if you want a clean solution, you can subclass Timer and provide it with some kind of flag, which you can set via your own constructor or a version of start() or a dedicated setter methode.
Less clean, but a lot easier is using a global flag.