Skip to content

Adding a named tuple for acceleration #27

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
Mar 19, 2018
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
6 changes: 5 additions & 1 deletion adafruit_lis3dh.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import time
import math
import digitalio
from ucollections import namedtuple
try:
import struct
except ImportError:
Expand Down Expand Up @@ -82,6 +83,9 @@
STANDARD_GRAVITY = 9.806
# pylint: enable=bad-whitespace

# the named tuple returned by the class
AccelerationTuple = namedtuple("acceleration", ("x", "y", "z"))


class LIS3DH:
"""Driver base for the LIS3DH accelerometer."""
Expand Down Expand Up @@ -162,7 +166,7 @@ def acceleration(self):
y = (y / divider) * STANDARD_GRAVITY
z = (z / divider) * STANDARD_GRAVITY

return x, y, z
return AccelerationTuple(x, y, z)

def shake(self, shake_threshold=30, avg_count=10, total_delay=0.1):
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = ["digitalio", "micropython"]
autodoc_mock_imports = ["digitalio", "micropython", "ucollections"]

intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

Expand Down