Skip to content

Commit 855c4d8

Browse files
committed
Pushing for review, not sure why it's not working
1 parent d3edbc3 commit 855c4d8

File tree

1 file changed

+64
-32
lines changed

1 file changed

+64
-32
lines changed

adafruit_bno055.py

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -91,38 +91,6 @@ class BNO055:
9191
Driver for the BNO055 9DOF IMU sensor.
9292
"""
9393

94-
temperature = _ReadOnlyUnaryStruct(0x34, 'b')
95-
"""Measures the temperature of the chip in degrees Celsius."""
96-
accelerometer = _ScaledReadOnlyStruct(0x08, '<hhh', 1/100)
97-
"""Gives the raw accelerometer readings, in m/s.
98-
99-
.. warning:: This is deprecated. Use ``acceleration`` instead. It'll work
100-
with other drivers too."""
101-
acceleration = _ScaledReadOnlyStruct(0x08, '<hhh', 1/100)
102-
"""Gives the raw accelerometer readings, in m/s."""
103-
magnetometer = _ScaledReadOnlyStruct(0x0e, '<hhh', 1/16)
104-
"""Gives the raw magnetometer readings in microteslas.
105-
106-
.. warning:: This is deprecated. Use ``magnetic`` instead. It'll work with
107-
other drivers too."""
108-
magnetic = _ScaledReadOnlyStruct(0x0e, '<hhh', 1/16)
109-
"""Gives the raw magnetometer readings in microteslas."""
110-
gyroscope = _ScaledReadOnlyStruct(0x14, '<hhh', 1/16)
111-
"""Gives the raw gyroscope reading in degrees per second.
112-
113-
.. warning:: This is deprecated. Use ``gyro`` instead. It'll work with
114-
other drivers too."""
115-
gyro = _ScaledReadOnlyStruct(0x14, '<hhh', 0.001090830782496456)
116-
"""Gives the raw gyroscope reading in radians per second."""
117-
euler = _ScaledReadOnlyStruct(0x1a, '<hhh', 1/16)
118-
"""Gives the calculated orientation angles, in degrees."""
119-
quaternion = _ScaledReadOnlyStruct(0x20, '<hhhh', 1/(1<<14))
120-
"""Gives the calculated orientation as a quaternion."""
121-
linear_acceleration = _ScaledReadOnlyStruct(0x28, '<hhh', 1/100)
122-
"""Returns the linear acceleration, without gravity, in m/s."""
123-
gravity = _ScaledReadOnlyStruct(0x2e, '<hhh', 1/100)
124-
"""Returns the gravity vector, without acceleration in m/s."""
125-
12694
def __init__(self, i2c, address=0x28):
12795
self.i2c_device = I2CDevice(i2c, address)
12896
self.buffer = bytearray(2)
@@ -244,3 +212,67 @@ def use_external_crystal(self, value):
244212
self._write_register(_TRIGGER_REGISTER, 0x80 if value else 0x00)
245213
self.mode = last_mode
246214
time.sleep(0.01)
215+
216+
217+
@property
218+
def temperature(self):
219+
"""Measures the temperature of the chip in degrees Celsius."""
220+
return _ReadOnlyUnaryStruct(0x34, 'b')
221+
222+
@property
223+
def acceleration(self):
224+
"""Gives the raw accelerometer readings, in m/s."""
225+
if self.mode not in [0, 2, 3, 6]:
226+
return _ScaledReadOnlyStruct(0x08, '<hhh', 1/100)
227+
else:
228+
return (None, None, None)
229+
230+
@property
231+
def magnetic(self):
232+
"""Gives the raw magnetometer readings in microteslas."""
233+
if self.mode not in [0, 3, 5, 8]:
234+
return _ScaledReadOnlyStruct(0x0e, '<hhh', 1/16)
235+
else:
236+
return (None, None, None)
237+
238+
@property
239+
def gyro(self):
240+
"""Gives the raw gyroscope reading in radians per second."""
241+
if self.mode not in [0, 1, 2, 4, 9, 10]:
242+
return _ScaledReadOnlyStruct(0x14, '<hhh', 0.001090830782496456)
243+
244+
else:
245+
return (None, None, None)
246+
247+
@property
248+
def euler(self):
249+
"""Gives the calculated orientation angles, in degrees."""
250+
if self.mode in [9, 11, 12, 0x0c]:
251+
252+
return _ScaledReadOnlyStruct(0x1a, '<hhh', 1/16)
253+
else:
254+
return (None, None, None)
255+
256+
@property
257+
def quaternion(self):
258+
"""Gives the calculated orientation as a quaternion."""
259+
if self.mode in [9, 11, 12]:
260+
return _ScaledReadOnlyStruct(0x20, '<hhhh', 1/(1<<14))
261+
else:
262+
return (None, None, None, None)
263+
264+
@property
265+
def linear_acceleration(self):
266+
"""Returns the linear acceleration, without gravity, in m/s."""
267+
if self.mode in [9, 11, 12]:
268+
return _ScaledReadOnlyStruct(0x28, '<hhh', 1/100)
269+
else:
270+
return (None, None, None)
271+
272+
@property
273+
def gravity(self):
274+
"""Returns the gravity vector, without acceleration in m/s."""
275+
if self.mode in [9, 11, 12]:
276+
return _ScaledReadOnlyStruct(0x2e, '<hhh', 1/100)
277+
else:
278+
return (None, None, None)

0 commit comments

Comments
 (0)