@@ -165,16 +165,17 @@ def acceleration(self):
165
165
return x , y , z
166
166
167
167
def shake (self , shake_threshold = 30 , avg_count = 10 , total_delay = 0.1 ):
168
- """Detect when the accelerometer is shaken. Optional parameters:
169
- shake_threshold - Increase or decrease to change shake sensitivity. This
170
- requires a minimum value of 10. 10 is the total
171
- acceleration if the board is not moving, therefore
172
- anything less than 10 will erroneously report a constant
173
- shake detected. (Default 30)
174
- avg_count - The number of readings taken and used for the average
175
- acceleration. (Default 10)
176
- total_delay - The total time in seconds it takes to obtain avg_count
177
- readings from acceleration. (Default 0.1)
168
+ """
169
+ Detect when the accelerometer is shaken. Optional parameters:
170
+ :param shake_threshold: Increase or decrease to change shake sensitivity. This
171
+ requires a minimum value of 10. 10 is the total
172
+ acceleration if the board is not moving, therefore
173
+ anything less than 10 will erroneously report a constant
174
+ shake detected. (Default 30)
175
+ :param avg_count: The number of readings taken and used for the average
176
+ acceleration. (Default 10)
177
+ :param total_delay: The total time in seconds it takes to obtain avg_count
178
+ readings from acceleration. (Default 0.1)
178
179
"""
179
180
shake_accel = (0 , 0 , 0 )
180
181
for _ in range (avg_count ):
@@ -220,45 +221,48 @@ def read_adc_mV(self, adc): # pylint: disable=invalid-name
220
221
221
222
@property
222
223
def tapped (self ):
223
- """True if a tap was detected recently. Whether its a single tap or double tap is
224
- determined by the tap param on ``set_tap``. ``tapped`` may be True over
225
- multiple reads even if only a single tap or single double tap occurred if the
226
- interrupt (int) pin is not specified.
224
+ """
225
+ True if a tap was detected recently. Whether its a single tap or double tap is
226
+ determined by the tap param on ``set_tap``. ``tapped`` may be True over
227
+ multiple reads even if only a single tap or single double tap occurred if the
228
+ interrupt (int) pin is not specified.
227
229
228
- The following example uses ``i2c`` and specifies the interrupt pin:
230
+ The following example uses ``i2c`` and specifies the interrupt pin:
229
231
230
- .. code-block:: python
232
+ .. code-block:: python
231
233
232
- import adafruit_lis3dh
233
- import digitalio
234
+ import adafruit_lis3dh
235
+ import digitalio
234
236
235
- i2c = busio.I2C(board.SCL, board.SDA)
236
- int1 = digitalio.DigitalInOut(board.D11) # pin connected to interrupt
237
- lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)
238
- lis3dh.range = adafruit_lis3dh.RANGE_8_G
237
+ i2c = busio.I2C(board.SCL, board.SDA)
238
+ int1 = digitalio.DigitalInOut(board.D11) # pin connected to interrupt
239
+ lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)
240
+ lis3dh.range = adafruit_lis3dh.RANGE_8_G
239
241
240
- """
242
+ """
241
243
if self ._int1 and not self ._int1 .value :
242
244
return False
243
245
raw = self ._read_register_byte (REG_CLICKSRC )
244
246
return raw & 0x40 > 0
245
247
246
248
def set_tap (self , tap , threshold , * ,
247
249
time_limit = 10 , time_latency = 20 , time_window = 255 , click_cfg = None ):
248
- """Set the tap detection parameters.
249
-
250
- .. note:: Tap related registers are called CLICK_ in the datasheet.
251
-
252
- :param int tap: 0 to disable tap detection, 1 to detect only single
253
- taps, and 2 to detect only double taps.
254
- :param int threshold: A threshold for the tap detection. The higher the value
255
- the less sensitive the detection. This changes based on the accelerometer
256
- range. Good values are 5-10 for 16G, 10-20 for 8G, 20-40 for 4G, and 40-80 for
257
- 2G.
258
- :param int time_limit: TIME_LIMIT register value (default 10).
259
- :param int time_latency: TIME_LATENCY register value (default 20).
260
- :param int time_window: TIME_WINDOW register value (default 255).
261
- :param int click_cfg: CLICK_CFG register value."""
250
+ """
251
+ Set the tap detection parameters.
252
+
253
+ .. note:: Tap related registers are called CLICK_ in the datasheet.
254
+
255
+ :param int tap: 0 to disable tap detection, 1 to detect only single
256
+ taps, and 2 to detect only double taps.
257
+ :param int threshold: A threshold for the tap detection. The higher the value
258
+ the less sensitive the detection. This changes based on
259
+ the accelerometer range. Good values are 5-10 for 16G,
260
+ 10-20 for 8G, 20-40 for 4G, and 40-80 for 2G.
261
+ :param int time_limit: TIME_LIMIT register value (default 10).
262
+ :param int time_latency: TIME_LATENCY register value (default 20).
263
+ :param int time_window: TIME_WINDOW register value (default 255).
264
+ :param int click_cfg: CLICK_CFG register value.
265
+ """
262
266
if (tap < 0 or tap > 2 ) and click_cfg is None :
263
267
raise ValueError ('Tap must be 0 (disabled), 1 (single tap), or 2 (double tap)!' )
264
268
if threshold > 127 or threshold < 0 :
0 commit comments