-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Hello,
thank you for providing this code.
You are attatching the interrupt to an helper function to call the opject read_AB. This is not necessary. Instead using
attachInterrupt(digitalPinToInterrupt(PIN_A), encoderISR, CHANGE); //call encoderISR() every high->low or low->high changes
You can use:
attachInterrupt(digitalPinToInterrupt(PIN_A), []() {
encoder.readAB();
}, CHANGE);
make sure "encoder" has been declared in this context.
This approach is called "lambda function" and is even faster.
Thank you again
Metadata
Metadata
Assignees
Labels
No labels