Skip to content

Commit

Permalink
Merge pull request #17 from jposada202020/correcting_returning_units_…
Browse files Browse the repository at this point in the history
…gyro

Correcting returning units gyro
  • Loading branch information
jposada202020 committed May 9, 2021
2 parents 2a25e0c + bfe5e3a commit e83f57f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
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)

0 comments on commit e83f57f

Please sign in to comment.