I'm trying to create a task list which should be used in task scheduler later in main loop(). I tried to use constructor but compiler throws an error
could not covert '{doKeypad,2000,0}' from '<brace-enclosed initializer list>' to 'Task'
struct Task{
void (*proc)(); // Process callback
unsigned long dly; // delay in ms
unsigned long mls = 0; // last run in millis()
};
Task task[] = { // This is much more readable
{doKeypad, 2000, 0}, // but it does not work :)
{doPower, 10, 0},
{doDallas, 800, 0},
{doLcd, 500, 0}
};
void doKeypad(){
// some code here...
}
// rest of code follows - doPower(), doDallas() ...
What would be the simplest way of achieving this? I can do a function to fill the task array manually but it looks ugly and it is not very readable. I have seen some similar questions but they were about classes and too complicated for me :/
&functionnamejust like I would do if making a data pointer. The bare function name will decay to a pointer, but it's not as clear to a reader that you are dealing with a function pointer as opposed to a function object of some type.