Skip to content

Commit

Permalink
Merge pull request #23 from jposada202020/correcting_measuremnt_units
Browse files Browse the repository at this point in the history
correcting_measurement_units
  • Loading branch information
tannewt authored Jun 3, 2021
2 parents 58ab117 + 738ffe9 commit 92155c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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)

0 comments on commit 92155c7

Please sign in to comment.