function pointer question (callback function)

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?

Can anyone offer up suggestions to accomplish what I'm trying to do here?

Look at your constructor:

StateTimer(void (*pCallbackFunction)(StateTimer*));

It says that the function takes one argument, a StateTimer pointer, and returns nothing.

If you want the function to take more than one argument, change your constructor.

thanks Paul...

StateTimer(void (*pCallbackFunction)(StateTimer*, int myInt));
void(*pCallback)(StateTimer*, int myInt);

etcetera...

got it!

I really appreciate your help with this... I'm operating slightly above my pay grade on these callbacks... trying to build my understanding.

I'm operating slightly above my pay grade on these callbacks... trying to build my understanding.

Been there, done that, got the t-shirt.