@@ -88,6 +88,38 @@ def acceleration(self):
88
88
"""
89
89
return self ._lis3dh .acceleration
90
90
91
+ def shake (self ):
92
+ """Detect when device is shaken.
93
+
94
+ .. image :: /_static/accelerometer.jpg
95
+ :alt: Accelerometer
96
+
97
+ .. code-block:: python
98
+
99
+ from adafruit_circuitplayground.express import cpx
100
+
101
+ while True:
102
+ if cpx.shake():
103
+ print("Shake detected!")
104
+
105
+ The `shake_threshold` default is 30. Decreasing this number increases
106
+ shake sensitivity, i.e. the code will return a shake detected more
107
+ easily with a lower `shake_threshold`. Increasing it causes the opposite.
108
+ `shake_threshold` requires a minimum value of 10 - 10 is the value when
109
+ the board is not moving, therefore anything less than 10 will
110
+ erroneously report a constant shake detected.
111
+
112
+ .. code-block:: python
113
+
114
+ from adafruit_circuitplayground.express import cpx
115
+
116
+ while True:
117
+ if cpx.shake(shake_threshold=20):
118
+ print("Shake detected more easily than before!")
119
+ """
120
+ return self ._lis3dh .shake ()
121
+
122
+
91
123
@property
92
124
def touch_A1 (self ):
93
125
"""Detect touch on capacitive touch pad A1.
@@ -323,7 +355,7 @@ def temperature(self):
323
355
temperature_c = cpx.temperature
324
356
temperature_f = temperature_c * 1.8 + 32
325
357
print("Temperature celsius:", temperature_c)
326
- print("Temperature farenheit :", temperature_f)
358
+ print("Temperature fahrenheit :", temperature_f)
327
359
time.sleep(1)
328
360
"""
329
361
return self ._temp .temperature
0 commit comments