@@ -110,6 +110,9 @@ sfeTkError_t sfeQwiicOtos::calibrateImu(uint8_t numSamples, bool waitUntilDone)
110110 if (err != kSTkErrOk )
111111 return err;
112112
113+ // Wait 1 sample period (2.4ms) to ensure the register updates
114+ delayMs (3 );
115+
113116 // Do we need to wait until the calibration finishes?
114117 if (!waitUntilDone)
115118 return kSTkErrOk ;
@@ -119,11 +122,6 @@ sfeTkError_t sfeQwiicOtos::calibrateImu(uint8_t numSamples, bool waitUntilDone)
119122 // of read attempts
120123 for (uint8_t numAttempts = numSamples; numAttempts > 0 ; numAttempts--)
121124 {
122- // Give a short delay between reads. As of firmware v1.0, samples take
123- // 2.4ms each, so 3ms should guarantee the next sample is done. This
124- // also ensures the max attempts is not exceeded in normal operation
125- delayMs (3 );
126-
127125 // Read the gryo calibration register value
128126 uint8_t calibrationValue;
129127 err = _commBus->readRegisterByte (kRegImuCalib , calibrationValue);
@@ -133,12 +131,23 @@ sfeTkError_t sfeQwiicOtos::calibrateImu(uint8_t numSamples, bool waitUntilDone)
133131 // Check if calibration is done
134132 if (calibrationValue == 0 )
135133 return kSTkErrOk ;
134+
135+ // Give a short delay between reads. As of firmware v1.0, samples take
136+ // 2.4ms each, so 3ms should guarantee the next sample is done. This
137+ // also ensures the max attempts is not exceeded in normal operation
138+ delayMs (3 );
136139 }
137140
138141 // Max number of attempts reached, calibration failed
139142 return kSTkErrFail ;
140143}
141144
145+ sfeTkError_t sfeQwiicOtos::getImuCalibrationProgress (uint8_t &numSamples)
146+ {
147+ // Read the IMU calibration register
148+ return _commBus->readRegisterByte (kRegImuCalib , numSamples);
149+ }
150+
142151sfe_otos_linear_unit_t sfeQwiicOtos::getLinearUnit ()
143152{
144153 return _linearUnit;
0 commit comments