Skip to content

Commit 72de328

Browse files
authored
Merge pull request #30 from jposada202020/returning_correct_units_gyro
Returning correct units gyro
2 parents 23070d5 + e327712 commit 72de328

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

adafruit_lsm9ds1.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
2020
**Hardware:**
2121
22-
* Adafruit `9-DOF Accel/Mag/Gyro+Temp Breakout Board - LSM9DS1
22+
* `Adafruit 9-DOF Accel/Mag/Gyro+Temp Breakout Board - LSM9DS1
2323
<https://www.adafruit.com/product/3387>`_ (Product ID: 3387)
2424
2525
**Software and Dependencies:**
2626
2727
* Adafruit CircuitPython firmware for the supported boards:
2828
https://circuitpython.org/downloads
29+
2930
* Adafruit's Bus Device library:
3031
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
3132
"""
@@ -34,6 +35,7 @@
3435
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1.git"
3536

3637
import time
38+
from math import radians
3739

3840
try:
3941
import struct
@@ -302,10 +304,10 @@ def read_gyro_raw(self):
302304
@property
303305
def gyro(self):
304306
"""The gyroscope X, Y, Z axis values as a 3-tuple of
305-
degrees/second values.
307+
rad/s values.
306308
"""
307309
raw = self.read_gyro_raw()
308-
return map(lambda x: x * self._gyro_dps_digit, raw)
310+
return map(lambda x: radians(x * self._gyro_dps_digit), raw)
309311

310312
def read_temp_raw(self):
311313
"""Read the raw temperature sensor value and return it as a 12-bit

examples/lsm9ds1_simpletest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"Magnetometer (gauss): ({0:0.3f},{1:0.3f},{2:0.3f})".format(mag_x, mag_y, mag_z)
4141
)
4242
print(
43-
"Gyroscope (degrees/sec): ({0:0.3f},{1:0.3f},{2:0.3f})".format(
43+
"Gyroscope (rad/sec): ({0:0.3f},{1:0.3f},{2:0.3f})".format(
4444
gyro_x, gyro_y, gyro_z
4545
)
4646
)

0 commit comments

Comments
 (0)