Skip to content

Commit dc7da90

Browse files
authored
Merge pull request #27 from Sigafoos/namedtuple
Adding a named tuple for acceleration
2 parents 522775f + ce115e0 commit dc7da90

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

adafruit_lis3dh.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import time
3434
import math
3535
import digitalio
36+
from ucollections import namedtuple
3637
try:
3738
import struct
3839
except ImportError:
@@ -82,6 +83,9 @@
8283
STANDARD_GRAVITY = 9.806
8384
# pylint: enable=bad-whitespace
8485

86+
# the named tuple returned by the class
87+
AccelerationTuple = namedtuple("acceleration", ("x", "y", "z"))
88+
8589

8690
class LIS3DH:
8791
"""Driver base for the LIS3DH accelerometer."""
@@ -162,7 +166,7 @@ def acceleration(self):
162166
y = (y / divider) * STANDARD_GRAVITY
163167
z = (z / divider) * STANDARD_GRAVITY
164168

165-
return x, y, z
169+
return AccelerationTuple(x, y, z)
166170

167171
def shake(self, shake_threshold=30, avg_count=10, total_delay=0.1):
168172
"""

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Uncomment the below if you use native CircuitPython modules such as
1919
# digitalio, micropython and busio. List the modules you use. Without it, the
2020
# autodoc module docs will fail to generate with a warning.
21-
autodoc_mock_imports = ["digitalio", "micropython"]
21+
autodoc_mock_imports = ["digitalio", "micropython", "ucollections"]
2222

2323
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)}
2424

0 commit comments

Comments
 (0)