ezTime
ezTime copied to clipboard
Cannot make event with function with arguments
Hi !
I cant' make an event with function who contains arguments like this :
int led = 2;
void makeAction(int pin, int action) {
digitalWrite(pin, action);
}
....
eventOnLight = Paris.setEvent(*makAction(led, HIGH), 17, 35, 0, 17, 5, 2020);
I have this error :
src\main.cpp:184:53: error: void value not ignored as it ought to be
eventOnLight = Paris.setEvent(*makeAction(led,HIGH), 18, 00, 0, 17, 5, 2020);
^
Can you help me ?
Regards,
An ezTime event can call a function, but the table that has a list of events to call and when to do that does not hold arguments. C++ is simply not ideal for storing lists of arbitrary type arguments. I would recommend you store the arguments somewhere outside of ezTime. You could have your own lookup table of time -> whatneedstohappen, and just check that whenever an event fires.
Also: you call setEvent with the name of the function, without brackets or arguments, just simply the function name.
Good luck!