diff --git a/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h b/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h index dc96ee52..5196f9b9 100644 --- a/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h +++ b/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h @@ -99,6 +99,12 @@ public: { DEBUG_PRINTLN(F("Usermod Rotary Encoder init.")); PinManagerPinType pins[3] = { { pinA, false }, { pinB, false }, { pinC, false } }; + if ((pinA < 0) || (pinB < 0)) { //WLEDMM catch error: [ 1839][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected + enabled = false; + DEBUG_PRINTLN(F("Invalid GPIO pins for Usermod Rotary Encoder.")); //WLEDMM add debug info + return; + } + if (!pinManager.allocateMultiplePins(pins, 3, PinOwner::UM_RotaryEncoderUI)) { // BUG: configuring this usermod with conflicting pins // will cause it to de-allocate pins it does not own @@ -116,8 +122,7 @@ public: #endif pinMode(pinA, USERMOD_ROTARY_ENCODER_GPIO); pinMode(pinB, USERMOD_ROTARY_ENCODER_GPIO); - pinMode(pinC, USERMOD_ROTARY_ENCODER_GPIO); - + if (pinC >= 0) pinMode(pinC, USERMOD_ROTARY_ENCODER_GPIO); // WLEDMM catch error currentTime = millis(); loopTime = currentTime; @@ -136,6 +141,7 @@ public: #endif initDone = true; + USER_PRINTLN(F("Rotary encoder setup completed.")); // WLEDMM inform user } /* diff --git a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h index a6dc0762..f7ee924f 100644 --- a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h +++ b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h @@ -267,6 +267,11 @@ public: { DEBUG_PRINTLN(F("Usermod Rotary Encoder init.")); PinManagerPinType pins[3] = { { pinA, false }, { pinB, false }, { pinC, false } }; + if ((pinA < 0) || (pinB < 0)) { //WLEDMM catch error: [ 1839][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected + enabled = false; + DEBUG_PRINTLN(F("Invalid GPIO pins for Usermod Rotary Encoder (ALT).")); //WLEDMM add debug info + return; + } if (!pinManager.allocateMultiplePins(pins, 3, PinOwner::UM_RotaryEncoderUI)) { // BUG: configuring this usermod with conflicting pins // will cause it to de-allocate pins it does not own @@ -284,7 +289,7 @@ public: #endif pinMode(pinA, USERMOD_ROTARY_ENCODER_GPIO); pinMode(pinB, USERMOD_ROTARY_ENCODER_GPIO); - pinMode(pinC, USERMOD_ROTARY_ENCODER_GPIO); + if (pinC >= 0) pinMode(pinC, USERMOD_ROTARY_ENCODER_GPIO); // WLEDMM catch error loopTime = millis(); @@ -305,6 +310,7 @@ public: Enc_A = digitalRead(pinA); // Read encoder pins Enc_B = digitalRead(pinB); Enc_A_prev = Enc_A; + USER_PRINTLN(F("Rotary encoder (ALT) setup completed.")); // WLEDMM inform user } /* @@ -349,7 +355,8 @@ public: { loopTime = currentTime; // Updates loopTime - bool buttonPressed = !digitalRead(pinC); //0=pressed, 1=released + bool buttonPressed = false; + if (pinC > 0) buttonPressed = !digitalRead(pinC); //0=pressed, 1=released if (buttonPressed) { if (!buttonPressedBefore) buttonPressedTime = currentTime; buttonPressedBefore = true;