Added getPinOwner

Only disable builtin LED if bus to avoid breaking other things on the pin
This commit is contained in:
cschwinne 2021-11-17 11:13:07 +01:00
parent 4af1f62aab
commit d31e4c7815
3 changed files with 12 additions and 2 deletions

View File

@ -299,8 +299,11 @@ void handleIO()
#ifdef ESP8266 #ifdef ESP8266
// turn off built-in LED if strip is turned off // turn off built-in LED if strip is turned off
// this will break digital bus so will need to be reinitialised on On // this will break digital bus so will need to be reinitialised on On
PinOwner ledPinOwner = pinManager.getPinOwner(LED_BUILTIN);
if (!strip.isOffRefreshRequred && (ledPinOwner == PinOwner::None || ledPinOwner == PinOwner::BusDigital)) {
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(LED_BUILTIN, HIGH);
}
#endif #endif
if (rlyPin>=0) { if (rlyPin>=0) {
pinMode(rlyPin, OUTPUT); pinMode(rlyPin, OUTPUT);

View File

@ -125,6 +125,11 @@ bool PinManagerClass::isPinOk(byte gpio, bool output)
return false; return false;
} }
PinOwner PinManagerClass::getPinOwner(byte gpio) {
if (!isPinOk(gpio, false)) return PinOwner::None;
return ownerTag[gpio];
}
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
byte PinManagerClass::allocateLedc(byte channels) byte PinManagerClass::allocateLedc(byte channels)
{ {

View File

@ -92,6 +92,8 @@ class PinManagerClass {
bool isPinAllocated(byte gpio, PinOwner tag = PinOwner::None); bool isPinAllocated(byte gpio, PinOwner tag = PinOwner::None);
bool isPinOk(byte gpio, bool output = true); bool isPinOk(byte gpio, bool output = true);
PinOwner getPinOwner(byte gpio);
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
byte allocateLedc(byte channels); byte allocateLedc(byte channels);
void deallocateLedc(byte pos, byte channels); void deallocateLedc(byte pos, byte channels);