Skip to content

Commit 7be1e24

Browse files
committed
Fix: NAU7802 infinite loop waiting for calibration offset.
1 parent c062140 commit 7be1e24

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_NAU7802.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,16 @@ class WipperSnapper_I2C_Driver_NAU7802 : public WipperSnapper_I2C_Driver {
8989
_nau7802->read();
9090
}
9191

92-
while (!_nau7802->calibrate(NAU7802_CALMOD_INTERNAL)) {
92+
for (int retries = 0; retries < 3; retries++) {
93+
if (_nau7802->calibrate(NAU7802_CALMOD_INTERNAL)) {
94+
WS_DEBUG_PRINTLN("Calibrated internal offset");
95+
return true;
96+
}
9397
WS_DEBUG_PRINTLN("Failed to calibrate internal offset, retrying!");
9498
delay(1000);
9599
}
96-
WS_DEBUG_PRINTLN("Calibrated internal offset");
97-
98-
return true;
100+
WS_DEBUG_PRINTLN("ERROR: Failed to calibrate internal offset of NAU7802.");
101+
return false;
99102
}
100103

101104
/*******************************************************************************/

0 commit comments

Comments
 (0)