Skip to content

Commit 27f1ab7

Browse files
kattnitannewt
authored andcommitted
Added shake_threshold arg and updated docs
1 parent b3c63eb commit 27f1ab7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

adafruit_circuitplayground/express.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ def acceleration(self):
138138
"""
139139
return self._lis3dh.acceleration
140140

141-
def shake(self):
141+
def shake(self, shake_threshold=30):
142142
"""Detect when device is shaken.
143143
144+
:param int shake_threshold: The threshold shake must exceed to return true (Default: 30)
145+
144146
.. image :: /_static/accelerometer.jpg
145147
:alt: Accelerometer
146148
@@ -152,12 +154,11 @@ def shake(self):
152154
if cpx.shake():
153155
print("Shake detected!")
154156
155-
The `shake_threshold` default is 30. Decreasing this number increases
156-
shake sensitivity, i.e. the code will return a shake detected more
157-
easily with a lower `shake_threshold`. Increasing it causes the opposite.
158-
`shake_threshold` requires a minimum value of 10 - 10 is the value when
159-
the board is not moving, therefore anything less than 10 will
160-
erroneously report a constant shake detected.
157+
Decreasing ``shake_threshold`` increases shake sensitivity, i.e. the code
158+
will return a shake detected more easily with a lower ``shake_threshold``.
159+
Increasing it causes the opposite. ``shake_threshold`` requires a minimum
160+
value of 10 - 10 is the value when the board is not moving, therefore
161+
anything less than 10 will erroneously report a constant shake detected.
161162
162163
.. code-block:: python
163164
@@ -168,7 +169,7 @@ def shake(self):
168169
print("Shake detected more easily than before!")
169170
"""
170171
try:
171-
return self._lis3dh.shake()
172+
return self._lis3dh.shake(shake_threshold=shake_threshold)
172173
except AttributeError:
173174
raise RuntimeError("Oops! You need a newer version of CircuitPython "
174175
"(2.2.0 or greater) to use cpx.shake.")

0 commit comments

Comments
 (0)