Skip to content

correcting_measurement_units #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions adafruit_l3gd20.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_l3gd20.git"


from math import radians
from micropython import const
from adafruit_register.i2c_struct import Struct

Expand Down Expand Up @@ -195,10 +196,10 @@ def __init__(self, rng=L3DS20_RANGE_250DPS, rate=L3DS20_RATE_100HZ):
def gyro(self):
"""
x, y, z angular momentum tuple floats, rescaled appropriately for
range selected
range selected in rad/s
"""
raw = self.gyro_raw
return tuple(self.scale * v for v in raw)
return tuple(radians(self.scale * v) for v in raw)


class L3GD20_I2C(L3GD20):
Expand Down Expand Up @@ -364,7 +365,7 @@ def read_bytes(self, register, buffer):

@property
def gyro_raw(self):
"""Gives the raw gyro readings, in units of rad/s."""
"""Gives the dynamic rate raw gyro readings, in units rad/s."""
buffer = self._spi_bytearray6
self.read_bytes(_L3GD20_REGISTER_OUT_X_L_X40, buffer)
return unpack("<hhh", buffer)
return tuple(radians(x) for x in unpack("<hhh", buffer))
2 changes: 1 addition & 1 deletion examples/l3gd20_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
# )

while True:
print("Angular Momentum (rad/s): {}".format(SENSOR.gyro))
print("Angular Velocity (rad/s): {}".format(SENSOR.gyro))
print()
time.sleep(1)