attachInterruptParam method

Posting it here because couldn't find any documentation on it. It is available for Arduino Nano Every, the signature is this:

void attachInterruptParam(pin_size_t interruptNumber, voidFuncPtrParam callback, PinStatus mode, void *param);

Callback signature in this case:

void callbackFunc(void *param);

Useful if you want to call static member function then you can pass your class instance as param, for example:

class MyClass
	int pin;
	volatile int count;
	static void HandleInterrupt(void* param)
	MyClass(int pin): pin(pin), count(0)
		attachInterruptParam(digitalPinToInterrupt(pin), &MyClass::HandleInterrupt, CHANGE, this);
	int GetCount()
		return count;

MyClass test1(PIN2);
MyClass test2(PIN7);

void setup()
void loop()

See here:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.