Skip to content

Commit cf551a6

Browse files
authored
Updated calibration functionality after review.
1 parent 42517d7 commit cf551a6

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

adafruit_bno055.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@ def _read_register(self, register):
145145
i2c.readinto(self.buffer, start=1)
146146
return self.buffer[1]
147147

148-
def _get_calibration_data(self):
149-
calibration_data = self._read_register(_CALIBRATION_REGISTER)
150-
sys = (calibration_data >> 6) & 0x03
151-
gyro = (calibration_data >> 4) & 0x03
152-
accel = (calibration_data >> 2) & 0x03
153-
mag = calibration_data & 0x03
154-
return sys, gyro, accel, mag
155-
156148
def reset(self):
157149
"""Resets the sensor to default settings."""
158150
self.mode = CONFIG_MODE
@@ -206,12 +198,20 @@ def mode(self):
206198
return self._read_register(_MODE_REGISTER)
207199

208200
@property
209-
def is_fully_calibrated(self):
210-
"""Returns the status of the sensor calibration."""
211-
sys, gyro, accel, mag = self._get_calibration_data()
212-
if sys < 3 or gyro < 3 or accel < 3 or mag < 3:
213-
return False
214-
return True
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
215215

216216
@mode.setter
217217
def mode(self, new_mode):

0 commit comments

Comments
 (0)