Skip to content

Returning correct units gyro #30

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
May 9, 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
8 changes: 5 additions & 3 deletions adafruit_lsm9ds1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@

**Hardware:**

* Adafruit `9-DOF Accel/Mag/Gyro+Temp Breakout Board - LSM9DS1
* `Adafruit 9-DOF Accel/Mag/Gyro+Temp Breakout Board - LSM9DS1
<https://www.adafruit.com/product/3387>`_ (Product ID: 3387)

**Software and Dependencies:**

* Adafruit CircuitPython firmware for the supported boards:
https://circuitpython.org/downloads

* Adafruit's Bus Device library:
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""
Expand All @@ -34,6 +35,7 @@
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1.git"

import time
from math import radians

try:
import struct
Expand Down Expand Up @@ -302,10 +304,10 @@ def read_gyro_raw(self):
@property
def gyro(self):
"""The gyroscope X, Y, Z axis values as a 3-tuple of
degrees/second values.
rad/s values.
"""
raw = self.read_gyro_raw()
return map(lambda x: x * self._gyro_dps_digit, raw)
return map(lambda x: radians(x * self._gyro_dps_digit), raw)

def read_temp_raw(self):
"""Read the raw temperature sensor value and return it as a 12-bit
Expand Down
2 changes: 1 addition & 1 deletion examples/lsm9ds1_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"Magnetometer (gauss): ({0:0.3f},{1:0.3f},{2:0.3f})".format(mag_x, mag_y, mag_z)
)
print(
"Gyroscope (degrees/sec): ({0:0.3f},{1:0.3f},{2:0.3f})".format(
"Gyroscope (rad/sec): ({0:0.3f},{1:0.3f},{2:0.3f})".format(
gyro_x, gyro_y, gyro_z
)
)
Expand Down