diff --git a/wled00/button.cpp b/wled00/button.cpp index 39c1e4f7..aef18c77 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -299,8 +299,11 @@ void handleIO() #ifdef ESP8266 // turn off built-in LED if strip is turned off // this will break digital bus so will need to be reinitialised on On - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, HIGH); + PinOwner ledPinOwner = pinManager.getPinOwner(LED_BUILTIN); + if (!strip.isOffRefreshRequred && (ledPinOwner == PinOwner::None || ledPinOwner == PinOwner::BusDigital)) { + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, HIGH); + } #endif if (rlyPin>=0) { pinMode(rlyPin, OUTPUT); diff --git a/wled00/pin_manager.cpp b/wled00/pin_manager.cpp index 38e6e162..ece48c24 100644 --- a/wled00/pin_manager.cpp +++ b/wled00/pin_manager.cpp @@ -125,6 +125,11 @@ bool PinManagerClass::isPinOk(byte gpio, bool output) return false; } +PinOwner PinManagerClass::getPinOwner(byte gpio) { + if (!isPinOk(gpio, false)) return PinOwner::None; + return ownerTag[gpio]; +} + #ifdef ARDUINO_ARCH_ESP32 byte PinManagerClass::allocateLedc(byte channels) { diff --git a/wled00/pin_manager.h b/wled00/pin_manager.h index 63f6d95e..65d31966 100644 --- a/wled00/pin_manager.h +++ b/wled00/pin_manager.h @@ -92,6 +92,8 @@ class PinManagerClass { bool isPinAllocated(byte gpio, PinOwner tag = PinOwner::None); bool isPinOk(byte gpio, bool output = true); + PinOwner getPinOwner(byte gpio); + #ifdef ARDUINO_ARCH_ESP32 byte allocateLedc(byte channels); void deallocateLedc(byte pos, byte channels);