diff --git a/src/ESP32RotaryEncoder.cpp b/src/ESP32RotaryEncoder.cpp index 6a60177..3ac1a35 100644 --- a/src/ESP32RotaryEncoder.cpp +++ b/src/ESP32RotaryEncoder.cpp @@ -238,8 +238,10 @@ bool RotaryEncoder::buttonPressed() { portENTER_CRITICAL( &mux ); - if( !_isEnabled ) + if( !_isEnabled ) { + portEXIT_CRITICAL( &mux ); return false; + } if( buttonPressedFlag ) ESP_LOGD( LOG_TAG, "Button pressed for %lu ms", buttonPressedDuration ); @@ -257,8 +259,10 @@ bool RotaryEncoder::encoderChanged() { portENTER_CRITICAL( &mux ); - if( !_isEnabled ) + if( !_isEnabled ) { + portEXIT_CRITICAL( &mux ); return false; + } if( encoderChangedFlag ) ESP_LOGD( LOG_TAG, "Knob turned; value: %ld", getEncoderValue() );