I\'m writing a simple library for an ultrasonic distance sensor and thought i\'d try using interrupts.
However i can\'t set my functions in the attachCallback<
Arduino interrupt handlers can only be functions. You are trying make method of an object an interrupt handler. Hence the compiler complains.
To be more precise about it, object methods are like functions, but it is as if they take a "hidden" parameter, which specifies the object instance. Therefore, they actually have different type signatures from plain functions. This disallows one to pass a method pointer when what a function is looking for is a plain function pointer.
The solution is to move your echoHigh()
and echoLow()
out of the HCSR04Interrupt
class, and make them plain functions.