Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kounocom committed Jan 19, 2025
1 parent d00d25f commit 27d3a09
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions lib/i2cscan/i2cscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ namespace I2CSCAN
Wire.end();
#endif
// Select next port
currentSCL++;
if (currentSCL >= validPorts.size()) {
currentSCL = 0;
currentSDA++;
if (currentSDA >= validPorts.size()) {
scanState = ScanState::DONE;
return;
Expand Down Expand Up @@ -97,29 +95,26 @@ namespace I2CSCAN
currentAddress++;
if (currentAddress >= 127) {
currentAddress = 1;
while (true) {
// Select next port
currentSCL++;
if (currentSCL >= validPorts.size()) {
currentSCL = 0;
currentSDA++;
if (currentSDA >= validPorts.size()) {
if (!found) {
Serial.println("[ERR] I2C: No I2C devices found");
}
// Select next port
currentSCL++;
if (currentSCL >= validPorts.size()) {
currentSCL = 0;
currentSDA++;
if (currentSDA >= validPorts.size()) {
if (!found) {
Serial.println("[ERR] I2C: No I2C devices found");
}
#if ESP32
Wire.end();
Wire.end();
#endif
Wire.begin(static_cast<int>(PIN_IMU_SDA), static_cast<int>(PIN_IMU_SCL));
scanState = ScanState::DONE;
return;
}
Wire.begin(static_cast<int>(PIN_IMU_SDA), static_cast<int>(PIN_IMU_SCL));
scanState = ScanState::DONE;
return;
}

// Check port
Wire.begin((int)validPorts[currentSDA], (int)validPorts[currentSCL]);
break;
}

// Check port
Wire.begin((int)validPorts[currentSDA], (int)validPorts[currentSCL]);
}
}

Expand Down

0 comments on commit 27d3a09

Please sign in to comment.