Skip to content

Commit

Permalink
Merge pull request #27 from peterhinch/mode-fix
Browse files Browse the repository at this point in the history
mode setter enables changes and honors delays.
  • Loading branch information
caternuson committed May 9, 2019
2 parents 32a5a8a + 29784ae commit d48ec14
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions adafruit_bno055.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ def mode(self):
"""
return self._read_register(_MODE_REGISTER)

@mode.setter
def mode(self, new_mode):
self._write_register(_MODE_REGISTER, CONFIG_MODE) # Empirically necessary
time.sleep(0.02) # Datasheet table 3.6
if new_mode != CONFIG_MODE:
self._write_register(_MODE_REGISTER, new_mode)
time.sleep(0.01) # Table 3.6

@property
def calibration_status(self):
"""Tuple containing sys, gyro, accel, and mag calibration data."""
Expand All @@ -213,10 +221,6 @@ def calibrated(self):
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)

@property
def external_crystal(self):
"""Switches the use of external crystal on or off."""
Expand Down

0 comments on commit d48ec14

Please sign in to comment.