I have a class that I set to listen to interrupts, and when I get interrupts the method is being called right.
When this class gets interrupt I want to call a method on the main .Ino file so ,
class that gets the interrupt and try to call main Ino method :
Sleep slp;
//set the pointer to the main Ino file
void Sleep::setDelegate( float(*fp)(float,float,char*))
{
fpAction=fp;
}
void Sleep::sleepSystem()
{
...
}
void wakeOnInt()
{
detachInterrupt(digitalPinToInterrupt(interrupt_pin));
slp.callMain("INTCOM");
}
void Sleep::callMain(char *arg)
{
char *argt ="INT";
(*fpAction)(0,0,argt); //********works till this line - that cause a crash !
}
Then on the main Ino file I have :
//interrupt method declaration
float interruptDelegate(float varf,float vari,char *arg);
Sleep sleep;
void setup()
{
//set the delegate in the sleep class (works)
sleep.setDelegate(interruptDelegate);
}
//this should be called on interrupt, but it crashes before it
float interruptDelegate(float varf,float vari,char *arg)
{
//Serialr.println(" int ");
}
As you can see, the interrupt occurs, but when I try to call the main Ino with that method pointer, i get a crash.
Whats wrong with it ?