Skip to content

Commit 2c9cde4

Browse files
committed
I2C usermods: make sure that no Wire-begin(-1, -1) sneaks through
1 parent dae6de7 commit 2c9cde4

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

usermods/BH1750_v2/usermod_bh1750.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class Usermod_BH1750 : public Usermod
137137
if (!pinManager.allocateMultiplePins(pins, 2, po)) return;
138138

139139
#if defined(ARDUINO_ARCH_ESP32)
140+
if (pins[1].pin < 0 || pins[0].pin < 0) { sensorFound=false; return; } //WLEDMM bugfix - ensure that "final" GPIO are valid and no "-1" sneaks trough
140141
Wire.begin(pins[1].pin, pins[0].pin); // WLEDMM this might silently fail, which is OK as it just means that I2C bus is already running.
141142
#else
142143
Wire.begin(); // WLEDMM - i2c pins on 8266 are fixed.

usermods/RTC/usermod_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class RTCUsermod : public Usermod {
2222
#endif
2323
if (!pinManager.allocateMultiplePins(pins, 2, PinOwner::HW_I2C)) { disabled = true; return; }
2424
#if defined(ARDUINO_ARCH_ESP32)
25+
if (pins[1].pin < 0 || pins[0].pin < 0) { disabled=true; return; } //WLEDMM bugfix - ensure that "final" GPIO are valid and no "-1" sneaks trough
2526
Wire.begin(pins[1].pin, pins[0].pin); // WLEDMM this might silently fail, which is OK as it just means that I2C bus is already running.
2627
#else
2728
Wire.begin(); // WLEDMM - i2c pins on 8266 are fixed.

usermods/mpu6050_imu/usermod_mpu6050_imu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class MPU6050Driver : public Usermod {
139139
// join I2C bus (I2Cdev library doesn't do this automatically)
140140
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
141141
#if defined(ARDUINO_ARCH_ESP32)
142+
if (pins[1].pin < 0 || pins[0].pin < 0) { enabled=false; dmpReady = false; return; } //WLEDMM bugfix - ensure that "final" GPIO are valid and no "-1" sneaks trough
142143
Wire.begin(pins[1].pin, pins[0].pin); // WLEDMM fix - need to use proper pins, in case that Wire was not started yet. Call will silently fail if Wire is initialized already.
143144
#else
144145
Wire.begin(); // WLEDMM - i2c pins on 8266 are fixed.

0 commit comments

Comments
 (0)