Skip to content

Commit 26083c0

Browse files
committed
Added ability to configure accelerometer
1 parent 3700bb5 commit 26083c0

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

adafruit_bno055.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,32 @@
5656
NDOF_FMC_OFF_MODE = const(0x0B)
5757
NDOF_MODE = const(0x0C)
5858

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+
5978
_POWER_NORMAL = const(0x00)
6079
_POWER_LOW = const(0x01)
6180
_POWER_SUSPEND = const(0x02)
6281

6382
_MODE_REGISTER = const(0x3D)
6483
_PAGE_REGISTER = const(0x07)
84+
_ACC_CONFIG_REGISTER = const(0x08)
6585
_CALIBRATION_REGISTER = const(0x35)
6686
_OFFSET_ACCEL_REGISTER = const(0x55)
6787
_OFFSET_MAGNET_REGISTER = const(0x5B)
@@ -327,6 +347,15 @@ def gravity(self):
327347
def _gravity(self):
328348
raise NotImplementedError("Must be implemented.")
329349

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+
330359
def _write_register(self, register, value):
331360
raise NotImplementedError("Must be implemented.")
332361

0 commit comments

Comments
 (0)