diff --git a/adafruit_bno055.py b/adafruit_bno055.py index dff4500..a32e9fe 100644 --- a/adafruit_bno055.py +++ b/adafruit_bno055.py @@ -61,6 +61,7 @@ _MODE_REGISTER = const(0x3d) _PAGE_REGISTER = const(0x07) +_CALIBRATION_REGISTER = const(0x35) _TRIGGER_REGISTER = const(0x3f) _POWER_REGISTER = const(0x3e) _ID_REGISTER = const(0x00) @@ -196,6 +197,22 @@ def mode(self): """ return self._read_register(_MODE_REGISTER) + @property + def calibration_status(self): + """Tuple containing sys, gyro, accel, and mag calibration data.""" + calibration_data = self._read_register(_CALIBRATION_REGISTER) + sys = (calibration_data >> 6) & 0x03 + gyro = (calibration_data >> 4) & 0x03 + accel = (calibration_data >> 2) & 0x03 + mag = calibration_data & 0x03 + return sys, gyro, accel, mag + + @property + def calibrated(self): + """Boolean indicating calibration status.""" + sys, gyro, accel, mag = self.calibration_status + return sys == gyro == accel == mag == 0x03 + @mode.setter def mode(self, new_mode): self._write_register(_MODE_REGISTER, new_mode)