Hello.
I'm looking for advice about how to do the following task.
Let's pretend I have a class in my own written library that looks something like this(consider this as pseudo-code:
class actionButton
{
_attachedPin;
public:
actionButton(byte attachToPin)
{
_attachedPin = attachToPin;
pinMode(_attachedPin, INPUTPULLUP);
}
void checkForPress()
{
if(shortPress)
{
shortPressCallback();
}
else if(longPress)
{
longPressCallback();
}
}
}
The question I have is, how do I "send" a function pointer to the object of such a class which the object then would use for shortPressCallback() and longPressCallback()?
I figured this out a few years ago but that code project hit a brick-wall when I discovered that the Arduino core for the Due makes it impossible to attach a "in-sketch defined" function pointer to a external interrupt using the attachInterrupt() function inside of the objects class definiton(it had something to do with the Due's definiton of the attachInterrupt() function and it's 32-bit system, or something, I might have known too little to be able to work around it), I'm not sure if that is still true today but I can't find the code and I was hoping that there might be someone here whom right now has a firm understanding of how to do this in the simplest way possible(simple meaning straight forward from the perspective of writing the sketch and send the function pointer to the object of the relevant class).
I hope you all will have a nice day.