small change: 4LD bugfix

Initially i2c_sda and i2c_scl are set to "-1" in wled.h. This can cause a bootloop when trying to initialize I2C with pins (-1, -1).
This fix ensures that usermod initialization will fail when SDA=-1 or SCL=-1.
This commit is contained in:
Frank
2022-10-18 12:06:54 +02:00
parent 8847d47bee
commit a6dd9c737f
2 changed files with 4 additions and 0 deletions

View File

@@ -175,7 +175,9 @@ class FourLineDisplayUsermod : public Usermod {
if (!pinManager.allocateMultiplePins(pins, 5, po)) { type=NONE; return; }
} else {
isHW = (ioPin[0]==i2c_scl && ioPin[1]==i2c_sda);
//isHW = true;
if (isHW) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
if (ioPin[0] < 0 || ioPin[1] < 0) { type=NONE; return; } //WLEDSR bugfix - ensure that "final" GPIO are valid
PinManagerPinType pins[2] = { { ioPin[0], true }, { ioPin[1], true } };
if (!pinManager.allocateMultiplePins(pins, 2, po)) { type=NONE; return; }
}

View File

@@ -336,8 +336,10 @@ class FourLineDisplayUsermod : public Usermod {
ioPin[1] = hw_sda;
}
isHW = (ioPin[0]==hw_scl && ioPin[1]==hw_sda);
// isHW = true;
if (isHW) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
PinManagerPinType pins[2] = { {ioPin[0], true }, { ioPin[1], true } };
if (ioPin[0] < 0 || ioPin[1] < 0) { type=NONE; return; } //WLEDSR bugfix - ensure that "final" GPIO are valid
if (!pinManager.allocateMultiplePins(pins, 2, po)) { type=NONE; return; }
}