MPU9250 correctly handles a zero calibration duration.
@@ -157,6 +157,7 @@ func (m *MPU9250) ReadRaw() (T int64, G1, G2, G3, A1, A2, A3, M1, M2, M3 float64
// Calibrate kicks off a calibration for specified duration (s) and retries.
func (m *MPU9250) Calibrate(dur, retries int) (err error) {
+ if dur > 0 {
for i := 0; i < retries; i++ {
m.mpu.CCal <- dur
log.Printf("AHRS Info: Waiting for calibration result try %d of %d\n", i, retries)
@@ -168,6 +169,7 @@ func (m *MPU9250) Calibrate(dur, retries int) (err error) {
time.Sleep(time.Duration(50) * time.Millisecond)
log.Println("AHRS Info: MPU9250 wasn't inertial, retrying calibration")
}
+ }
return
}
