Skip to content

Commit b67627c

Browse files
author
Kevin Townsend
committed
Use angular momentum (rad/s) not acceleration
1 parent 987a3e9 commit b67627c

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

adafruit_l3gd20.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,12 @@ def __init__(self, rng=L3DS20_RANGE_250DPS):
188188

189189

190190
@property
191-
def acceleration(self):
191+
def gyro(self):
192192
"""
193-
x, y, z acceleration tuple floats, rescaled appropriately for range selected
193+
x, y, z angular momentum tuple floats, rescaled appropriately for
194+
range selected
194195
"""
195-
raw = self.acceleration_raw
196+
raw = self.gyro_raw
196197
return tuple(self.scale*v for v in raw)
197198

198199

@@ -206,8 +207,8 @@ class L3GD20_I2C(L3GD20):
206207
:param address: the optional device address, 0x68 is the default address
207208
"""
208209

209-
acceleration_raw = Struct(_L3GD20_REGISTER_OUT_X_L_X80, '<hhh')
210-
"""Gives the raw acceleration readings, in units of the scaled mdps."""
210+
gyro_raw = Struct(_L3GD20_REGISTER_OUT_X_L_X80, '<hhh')
211+
"""Gives the raw gyro readings, in units of rad/s."""
211212

212213
def __init__(self, i2c, rng=L3DS20_RANGE_250DPS, address=0x6B):
213214
import adafruit_bus_device.i2c_device as i2c_device
@@ -283,7 +284,7 @@ def read_register(self, register):
283284

284285
def read_bytes(self, register, buffer):
285286
"""
286-
Low level register streem reading over SPI, returns a list of values
287+
Low level register stream reading over SPI, returns a list of values
287288
288289
:param register: the register to read bytes
289290
:param bytearray buffer: buffer to fill with data from stream
@@ -295,8 +296,8 @@ def read_bytes(self, register, buffer):
295296
spi.readinto(buffer)
296297

297298
@property
298-
def acceleration_raw(self):
299-
"""Gives the raw acceleration readings, in units of the scaled mdps."""
299+
def gyro_raw(self):
300+
"""Gives the raw gyro readings, in units of rad/s."""
300301
buffer = self._spi_bytearray6
301302
self.read_bytes(_L3GD20_REGISTER_OUT_X_L_X40, buffer)
302303
return unpack('<hhh', buffer)

examples/l3gd20_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
# SENSOR = adafruit_l3gd20.L3GD20_SPI(SPIB, CS)
1515

1616
while True:
17-
print('Acceleration (m/s^2): {}'.format(SENSOR.acceleration))
17+
print('Angular Momentum (rad/s): {}'.format(SENSOR.gyro))
1818
print()
1919
time.sleep(1)

0 commit comments

Comments
 (0)