Fork of mRotaryEncoder for mdeb-os. uses newer version of PinDetect. Testprogram: https://os.mbed.com/users/charly/code/mRotaryEncoder_HelloWorld-os/
Dependents: mRotaryEncoder_HelloWorld-os TMC2209-Test2
Diff: mRotaryEncoder.cpp
- Revision:
- 12:1925aac090b7
- Parent:
- 11:24b34deae975
--- a/mRotaryEncoder.cpp Tue Mar 03 12:20:55 2020 +0000
+++ b/mRotaryEncoder.cpp Tue Mar 16 20:19:04 2021 +0000
@@ -12,10 +12,10 @@
// attach interrrupts on pinA
if (detectRise != 0){
- m_pinA->attach_asserted(this, &mRotaryEncoder::rise);
+ m_pinA->attach_asserted(callback(this, &mRotaryEncoder::rise));
}
if (detectFall != 0){
- m_pinA->attach_deasserted(this, &mRotaryEncoder::fall);
+ m_pinA->attach_deasserted(callback(this, &mRotaryEncoder::fall));
}
//start sampling pinA
@@ -56,12 +56,18 @@
if (*m_pinA == 0) {
if (*m_pinB == 1) {
m_position++;
- rotCWIsr.call();
+ if (rotCWIsr) {
+ rotCWIsr();
+ }
} else {
m_position--;
- rotCCWIsr.call();
+ if (rotCWIsr){
+ rotCCWIsr();
+ }
}
- rotIsr.call(); // call the isr for rotation
+ if (rotIsr){
+ rotIsr(); // call the isr for rotation
+ }
}
}
@@ -71,12 +77,18 @@
if (*m_pinA == 1) {
if (*m_pinB == 1) {
m_position--;
- rotCCWIsr.call();
+ if (rotCCWIsr){
+ rotCCWIsr();
+ }
} else {
m_position++;
- rotCWIsr.call();
+ if (rotCWIsr){
+ rotCWIsr();
+ }
}
- rotIsr.call(); // call the isr for rotation
+ if (rotIsr){
+ rotIsr(); // call the isr for rotation
+ }
}
}