Skip to content

Correcting returning units gyro #17

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
13 changes: 8 additions & 5 deletions adafruit_mpu6050.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

**Hardware:**

* Adafruit `MPU-6050 6-DoF Accel and Gyro Sensor
<https://www.adafruit.com/product/3886>`_
* `Adafruit MPU-6050 6-DoF Accel and Gyro Sensor
<https://www.adafruit.com/product/3886>`_ (Product ID: 3886)

**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

* Adafruit's Register library:
https://github.com/adafruit/Adafruit_CircuitPython_Register
"""
Expand All @@ -34,6 +36,7 @@
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MPU6050.git"

from math import radians
from time import sleep
from adafruit_register.i2c_struct import UnaryStruct, ROUnaryStruct
from adafruit_register.i2c_struct_array import StructArray
Expand Down Expand Up @@ -274,9 +277,9 @@ def gyro(self):
gyro_scale = 16.4

# setup range dependant scaling
gyro_x = raw_x / gyro_scale
gyro_y = raw_y / gyro_scale
gyro_z = raw_z / gyro_scale
gyro_x = radians(raw_x / gyro_scale)
gyro_y = radians(raw_y / gyro_scale)
gyro_z = radians(raw_z / gyro_scale)

return (gyro_x, gyro_y, gyro_z)

Expand Down
2 changes: 1 addition & 1 deletion examples/mpu6050_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

while True:
print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2" % (mpu.acceleration))
print("Gyro X:%.2f, Y: %.2f, Z: %.2f degrees/s" % (mpu.gyro))
print("Gyro X:%.2f, Y: %.2f, Z: %.2f rad/s" % (mpu.gyro))
print("Temperature: %.2f C" % mpu.temperature)
print("")
time.sleep(1)