Skip to content

Commit 9617e19

Browse files
authored
Merge pull request #15 from davidskeck/patch-1
Fix for #11
2 parents 7a84ff7 + cf551a6 commit 9617e19

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

adafruit_bno055.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
_MODE_REGISTER = const(0x3d)
6363
_PAGE_REGISTER = const(0x07)
64+
_CALIBRATION_REGISTER = const(0x35)
6465
_TRIGGER_REGISTER = const(0x3f)
6566
_POWER_REGISTER = const(0x3e)
6667
_ID_REGISTER = const(0x00)
@@ -196,6 +197,22 @@ def mode(self):
196197
"""
197198
return self._read_register(_MODE_REGISTER)
198199

200+
@property
201+
def calibration_status(self):
202+
"""Tuple containing sys, gyro, accel, and mag calibration data."""
203+
calibration_data = self._read_register(_CALIBRATION_REGISTER)
204+
sys = (calibration_data >> 6) & 0x03
205+
gyro = (calibration_data >> 4) & 0x03
206+
accel = (calibration_data >> 2) & 0x03
207+
mag = calibration_data & 0x03
208+
return sys, gyro, accel, mag
209+
210+
@property
211+
def calibrated(self):
212+
"""Boolean indicating calibration status."""
213+
sys, gyro, accel, mag = self.calibration_status
214+
return sys == gyro == accel == mag == 0x03
215+
199216
@mode.setter
200217
def mode(self, new_mode):
201218
self._write_register(_MODE_REGISTER, new_mode)

0 commit comments

Comments
 (0)