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.h
- Revision:
- 11:24b34deae975
- Parent:
- 8:41c44b127443
--- a/mRotaryEncoder.h Fri Feb 26 20:18:57 2016 +0000 +++ b/mRotaryEncoder.h Tue Mar 03 12:20:55 2020 +0000 @@ -34,6 +34,7 @@ * First version published Thomas Raab raabinator * 26.11.2010 extended by charly - pushbutton, pullmode, debounce, callback-system * Feb2011 Changes InterruptIn to PinDetect which does the debounce of mechanical switches + * Mar2020 Configurable detection of rise/fall events to account for different types of encoders (half as much dent points) * */ class mRotaryEncoder { @@ -45,8 +46,10 @@ * @param pinSW Pin for push-button switch * @param pullmode mode for pinA pinB and pinSW like DigitalIn.mode * @param debounceTime_us time in micro-seconds to wait for bouncing of mechanical switches to end + * @param detectRise Detect rise event as new rotation + * @param detectFall Detect fall event as new rotation */ - mRotaryEncoder(PinName pinA, PinName pinB, PinName pinSW, PinMode pullMode=PullUp, int debounceTime_us=1000); + mRotaryEncoder(PinName pinA, PinName pinB, PinName pinSW, PinMode pullMode=PullUp, int debounceTime_us=1000, int detectRise=1, int detectFall=1); /** destroy object *