@@ -138,9 +138,11 @@ def acceleration(self):
138
138
"""
139
139
return self ._lis3dh .acceleration
140
140
141
- def shake (self ):
141
+ def shake (self , shake_threshold = 30 ):
142
142
"""Detect when device is shaken.
143
143
144
+ :param int shake_threshold: The threshold shake must exceed to return true (Default: 30)
145
+
144
146
.. image :: /_static/accelerometer.jpg
145
147
:alt: Accelerometer
146
148
@@ -152,12 +154,11 @@ def shake(self):
152
154
if cpx.shake():
153
155
print("Shake detected!")
154
156
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.
161
162
162
163
.. code-block:: python
163
164
@@ -168,7 +169,7 @@ def shake(self):
168
169
print("Shake detected more easily than before!")
169
170
"""
170
171
try :
171
- return self ._lis3dh .shake ()
172
+ return self ._lis3dh .shake (shake_threshold = shake_threshold )
172
173
except AttributeError :
173
174
raise RuntimeError ("Oops! You need a newer version of CircuitPython "
174
175
"(2.2.0 or greater) to use cpx.shake." )
0 commit comments