Skip to content

Commit

Permalink
Merge pull request #15 from davidskeck/patch-1
Browse files Browse the repository at this point in the history
Fix for #11
  • Loading branch information
caternuson committed Oct 9, 2018
2 parents 7a84ff7 + cf551a6 commit 9617e19
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions adafruit_bno055.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9617e19

Please sign in to comment.