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/

Dependencies:   PinDetect

Dependents:   SimplePIDBot FinalProgram VS1053Player SPK-DVIMXR ... more

Issue: Deconstructor may fail?

Hi, don't you think that you should have an "if" before deleting the pins?

mRotaryEncoder::mRotaryEncoder() { if(m_pinA) delete m_pinA; if(m_pinB) delete m_pinB; if(m_pinSW) delete m_pinSW; }

2 comments:

04 Dec 2019

And for sure initializing the variables in the constructor before assigning the pins.

mRotaryEncoder::mRotaryEncoder(PinName pinA, PinName pinB, PinName pinSW, PinMode pullMode, int debounceTime_us):m_pinA(NULL), m_pinB(NULL),  m_pinSW(NULL)

04 Dec 2019

I answer myself. You don't need if before delete.