|
61 | 61 |
|
62 | 62 | _MODE_REGISTER = const(0x3d)
|
63 | 63 | _PAGE_REGISTER = const(0x07)
|
| 64 | +_CALIBRATION_REGISTER = const(0x35) |
64 | 65 | _TRIGGER_REGISTER = const(0x3f)
|
65 | 66 | _POWER_REGISTER = const(0x3e)
|
66 | 67 | _ID_REGISTER = const(0x00)
|
@@ -196,6 +197,22 @@ def mode(self):
|
196 | 197 | """
|
197 | 198 | return self._read_register(_MODE_REGISTER)
|
198 | 199 |
|
| 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 | + |
199 | 216 | @mode.setter
|
200 | 217 | def mode(self, new_mode):
|
201 | 218 | self._write_register(_MODE_REGISTER, new_mode)
|
|
0 commit comments