So, building a Class, I have the constructor:
StateTimer(void (*pCallbackFunction)(StateTimer*));
and the function prototype (a private member function):
void(*pCallback)(StateTimer*);
I want to pass an argument to the callback, pseudo code like this:
#include "StateTimer.h"
StateTimer myTimer(&myFunction);
void setup()
{
}
void loop()
{
myTimer.process();
}
void myFunction(StateTimer* stateTimer, int state) // <<<< sort of like this
{
if(state==0)
do something;
else if (state==1)
do something else;
etc...
}
and something like the StateTimer::process() function like this:
void StateTimer::process()
{
if(this->timerON())
{
pCallback(this, 1); //<<<<<< pass the argument (sort of like this) here...
}
else if(this->timerOFF())
{
pCallback(this, 0);
}
}
Can anyone offer up suggestions to accomplish what I’m trying to do here?