40
40
from adafruit_register .i2c_bits import RWBits
41
41
import adafruit_bus_device .i2c_device as i2cdevice
42
42
43
+
44
+ try :
45
+ from typing import Tuple
46
+ from busio import I2C
47
+ except ImportError :
48
+ pass
49
+
43
50
_MSA301_I2CADDR_DEFAULT = const (0x26 )
44
51
_MSA311_I2CADDR_DEFAULT = const (0x62 )
45
52
@@ -244,7 +251,7 @@ def __init__(self):
244
251
self ._tap_count = 0
245
252
246
253
@property
247
- def acceleration (self ):
254
+ def acceleration (self ) -> Tuple [ float , float , float ] :
248
255
"""The x, y, z acceleration values returned in a
249
256
3-tuple and are in :math:`m / s ^ 2`"""
250
257
# read the 6 bytes of acceleration data
@@ -268,12 +275,12 @@ def acceleration(self):
268
275
def enable_tap_detection (
269
276
self ,
270
277
* ,
271
- tap_count = 1 ,
272
- threshold = 25 ,
273
- long_initial_window = True ,
274
- long_quiet_window = True ,
275
- double_tap_window = TapDuration .DURATION_250_MS
276
- ):
278
+ tap_count : int = 1 ,
279
+ threshold : int = 25 ,
280
+ long_initial_window : bool = True ,
281
+ long_quiet_window : bool = True ,
282
+ double_tap_window : int = TapDuration .DURATION_250_MS
283
+ ) -> None :
277
284
"""
278
285
Enables tap detection with configurable parameters.
279
286
@@ -321,7 +328,7 @@ def enable_tap_detection(
321
328
raise ValueError ("tap must be 1 for single tap, or 2 for double tap" )
322
329
323
330
@property
324
- def tapped (self ):
331
+ def tapped (self ) -> bool :
325
332
"""`True` if a single or double tap was detected, depending on the value of the\
326
333
``tap_count`` argument passed to ``enable_tap_detection``"""
327
334
if self ._tap_count == 0 :
@@ -346,7 +353,7 @@ class MSA301(MSA3XX):
346
353
:param ~busio.I2C i2c_bus: The I2C bus the MSA is connected to.
347
354
"""
348
355
349
- def __init__ (self , i2c_bus ):
356
+ def __init__ (self , i2c_bus : I2C ):
350
357
self .i2c_device = i2cdevice .I2CDevice (i2c_bus , _MSA301_I2CADDR_DEFAULT )
351
358
352
359
if self ._part_id != 0x13 :
@@ -361,7 +368,7 @@ class MSA311(MSA3XX):
361
368
:param ~busio.I2C i2c_bus: The I2C bus the MSA is connected to.
362
369
"""
363
370
364
- def __init__ (self , i2c_bus ):
371
+ def __init__ (self , i2c_bus : I2C ):
365
372
self .i2c_device = i2cdevice .I2CDevice (i2c_bus , _MSA311_I2CADDR_DEFAULT )
366
373
367
374
if self ._part_id != 0x13 :
0 commit comments