Skip to content

Commit 8aff47f

Browse files
committed
fix filename. Adding comments explaining the functions and a link to leaarn guide page.
1 parent 22b4c24 commit 8aff47f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/lsm303_inclinometer.py renamed to examples/mpu6050_inclinometer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
""" Display inclination data five times per second """
1+
# Display inclination data five times per second
2+
3+
# See this page to learn the math and physics principals behind this example:
4+
# https://learn.adafruit.com/how-tall-is-it/gravity-and-acceleration
25

36
import time
47
from math import atan2, degrees
@@ -10,13 +13,18 @@
1013
sensor = adafruit_mpu6050.MPU6050(i2c)
1114

1215

16+
# Given a point (x, y) return the angle of that point relative to x axis.
17+
# Returns: angle in degrees (0-360)
18+
1319
def vector_2_degrees(x, y):
1420
angle = degrees(atan2(y, x))
1521
if angle < 0:
1622
angle += 360
1723
return angle
1824

1925

26+
# Given an accelerometer sensor object return the inclination angles of X/Z and Y/Z
27+
2028
def get_inclination(_sensor):
2129
x, y, z = _sensor.acceleration
2230
return vector_2_degrees(x, z), vector_2_degrees(y, z)

0 commit comments

Comments
 (0)