I have a working sketch that I want to split up in a state machine part and a separate class.
The class makes use of an external interrupt which, when triggered, calls a function using attachInterrupt(). I want that function to be private to the class, but I guess my syntax is wrong because the compiler says:
path/OpTh/OpTh.cpp: In member function 'void OpTh::measure_ot_period()':
path/OpTh/OpTh.cpp:79: error: argument of type 'void (OpTh::)()' does not match 'void (*)()'
Line 79 is the line where attachInterrupt is, see code below.
The relevant code looks like this:
In OpTh.h:
class OpTh {
public:
OpTh();
void init(); // initialise timer and input pin
void measure_ot_period(); // measure the signal period
private:
void _ISRsync();
};
And in OpTh.cpp:
void OpTh::measure_ot_period() {
/* attach _ISR sync() to INT0, digital pin 2 */
attachInterrupt(0, _ISRsync, RISING);
}
void OpTh::_ISRsync() {
// do stuff
}
Can someone tell me what I'm doing wrong?
TIA,
Martijn