Calling different instances of same function

Posted by Laskar01 on Thu 25 Dec 2014 06:14 PM — 2 posts, 13,121 views.

#0
Hi all I have a button debounce routine "buttonReallyPressed()"in Arduino that I am reusing for more buttons like this:

typedef int (*ButtonDebounceFunction) ( int arg1);
int buttonReallyPressed(int i);
ButtonDebounceFunction Button1Pressed = buttonReallyPressed;
ButtonDebounceFunction Button2Pressed = buttonReallyPressed;

Inside buttonReallyPressed function I have a "static" variable that remembers the state of the button between succsesive calls.

This doesn't work though because it looks like I am not getting a new instance of the function for each declaration.

Do I need to make some sort of a new() statement?
Australia Forum Administrator #1
Template:Arduino
Please post Arduino-related questions to the Arduino Forum or to StackExchange: Arduino. This saves splitting questions and answers between this forum and the Arduino ones.