Skip to content

Add support for function objects in attachInterrupt #1925

Closed
@igrr

Description

@igrr

Allow something like

attachInterrupt(pin, [](){
    // function body
  }, CHANGE);

and

class MyClass() {
public:
  MyClass(int pin1, int pin2) {
    attachInterrupt(pin1, std::bind(&MyClass::onPinChange, this, pin1), CHANGE);
    attachInterrupt(pin2, std::bind(&MyClass::onPinChange, this, pin2), CHANGE);
  }

protected:
  void onPinChange(int pin) {
    // handler here
  }
};

without breaking usage of attachInterrupt from C code.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions