|
56 | 56 | NDOF_FMC_OFF_MODE = const(0x0B)
|
57 | 57 | NDOF_MODE = const(0x0C)
|
58 | 58 |
|
| 59 | +ACC_2G = const(0x00) |
| 60 | +ACC_4G = const(0x01) |
| 61 | +ACC_8G = const(0x02) |
| 62 | +ACC_16G = const(0x03) |
| 63 | +ACC_7_81HZ = const(0x00) |
| 64 | +ACC_15_63HZ = const(0x04) |
| 65 | +ACC_31_25HZ = const(0x08) |
| 66 | +ACC_62_5HZ = const(0x0C) |
| 67 | +ACC_125HZ = const(0x10) |
| 68 | +ACC_250HZ = const(0x14) |
| 69 | +ACC_500HZ = const(0x18) |
| 70 | +ACC_1000HZ = const(0x1C) |
| 71 | +ACC_NORMAL_MODE = const(0x00) |
| 72 | +ACC_SUSPEND_MODE = const(0x20) |
| 73 | +ACC_LOWPOWER1_MODE = const(0x40) |
| 74 | +ACC_STANDBY_MODE = const(0x60) |
| 75 | +ACC_LOWPOWER2_MODE = const(0x80) |
| 76 | +ACC_DEEPSUSPEND_MODE = const(0xA0) |
| 77 | + |
59 | 78 | _POWER_NORMAL = const(0x00)
|
60 | 79 | _POWER_LOW = const(0x01)
|
61 | 80 | _POWER_SUSPEND = const(0x02)
|
62 | 81 |
|
63 | 82 | _MODE_REGISTER = const(0x3D)
|
64 | 83 | _PAGE_REGISTER = const(0x07)
|
| 84 | +_ACC_CONFIG_REGISTER = const(0x08) |
65 | 85 | _CALIBRATION_REGISTER = const(0x35)
|
66 | 86 | _OFFSET_ACCEL_REGISTER = const(0x55)
|
67 | 87 | _OFFSET_MAGNET_REGISTER = const(0x5B)
|
@@ -327,6 +347,15 @@ def gravity(self):
|
327 | 347 | def _gravity(self):
|
328 | 348 | raise NotImplementedError("Must be implemented.")
|
329 | 349 |
|
| 350 | + def accel_config(self, rng=ACC_4G, bandwidth=ACC_62_5HZ, acc_mode=ACC_NORMAL_MODE): |
| 351 | + """Allows you to set the settings for the accelerometer""" |
| 352 | + if self.mode not in [0x08, 0x09, 0x0A, 0x0B, 0x0C]: |
| 353 | + self._write_register(_ACC_CONFIG_REGISTER, acc_mode | bandwidth | rng) |
| 354 | + time.sleep(0.1) |
| 355 | + value = self._read_register(_ACC_CONFIG_REGISTER) |
| 356 | + return value |
| 357 | + raise RuntimeError("Mode must not be a fusion mode") |
| 358 | + |
330 | 359 | def _write_register(self, register, value):
|
331 | 360 | raise NotImplementedError("Must be implemented.")
|
332 | 361 |
|
|
0 commit comments