Skip to content

Commit

Permalink
No more while(true)
Browse files Browse the repository at this point in the history
  • Loading branch information
kounocom committed Jan 19, 2025
1 parent b2b04c0 commit d00d25f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions lib/i2cscan/i2cscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,19 @@ namespace I2CSCAN
#if ESP32
Wire.end();
#endif
while (true) {
// Select next port
currentSCL++;
if (currentSCL >= validPorts.size()) {
currentSCL = 0;
currentSDA++;
if (currentSDA >= validPorts.size()) {
scanState = ScanState::DONE;
return;
}
// Select next port
currentSCL++;
if (currentSCL >= validPorts.size()) {
currentSCL = 0;
currentSDA++;
if (currentSDA >= validPorts.size()) {
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]);
}

Wire.beginTransmission(currentAddress);
Expand Down

0 comments on commit d00d25f

Please sign in to comment.