Class mRotaryEncoder for mechanical incremental rotary encoders with pushbuttons. Use debouncing and callback-functions for rotation and pressing of button. This version is for old mbed. New version for mbed-os see https://os.mbed.com/users/charly/code/mRotaryEncoder-os/
Dependents: SimplePIDBot FinalProgram VS1053Player SPK-DVIMXR ... more
Diff: mRotaryEncoder.cpp
- Revision:
- 7:ec80fd9c0c08
- Parent:
- 5:75ddffaf3721
- Child:
- 10:2502b829d452
--- a/mRotaryEncoder.cpp Wed Mar 11 21:08:31 2015 +0000 +++ b/mRotaryEncoder.cpp Wed Mar 11 21:45:46 2015 +0000 @@ -52,8 +52,10 @@ if (*m_pinA == 0) { if (*m_pinB == 1) { m_position++; + rotCWIsr.call(); } else { m_position--; + rotCCWIsr.call(); } } rotIsr.call(); // call the isr for rotation @@ -65,8 +67,10 @@ if (*m_pinA == 1) { if (*m_pinB == 1) { m_position--; + rotCCWIsr.call(); } else { m_position++; + rotCWIsr.call(); } } rotIsr.call(); // call the isr for rotation