Hi,
I'm trying to write a generic
wait a certain time unless an event happens function where I can pass in the
event happens function. Here's what I've got so far (simplified).
boolean wait( unsigned long time, boolean(*u)(void))
{
return(u());
}
As an aside, I have created a class called
Input which does similar stuff to the Button class. I want to call the wait function like this example.
wait( 3000, Modeswitch.on );
Modeswitch is instantiated from
Input and
on returns true if conditions in the object are met. I get the following compilation error
error: argument of type 'boolean (Input:
()' does not match 'boolean (*)()'What am I doing wrong? I've looked at many tutorials on passing objects/functions and I can't work this out.
Thanks
Jeff