Skip to content

Commit 029bebd

Browse files
committed
Adding a named tuple for acceleration
1 parent 522775f commit 029bebd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

adafruit_lis3dh.py

Lines changed: 5 additions & 1 deletion
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
"""

0 commit comments

Comments
 (0)