I have a class I wrote for Arduino which uses interrupts. Currently I need to create an instance of the ISR in the main Arduino sketch, then pass it to the class' initializing function, which runs "attachInterrupt". This is very bad style (why should the user know that I'm even using interrupts?), so I want the whole thing to be contained inside the class's header and source files.
I tried making the ISR a static friend function, but then it can't reach any of the class' non-static members. So now I'm a bit confused about what should and shouldn't be static for this approach to work. what I tried to do looks something like that (source and header combined here for easy reading)
class myClass{
friend void ISR();
void init(){attachInterrupt(ISR,..,..);}
}
static void ISR(){
all sort of stuff using myClass.members;
}
But the compiler yells at me for using non static members in a static function. I would really appreciate some help in understanding how I can make it work.