4040from adafruit_register .i2c_bits import RWBits
4141import adafruit_bus_device .i2c_device as i2cdevice
4242
43+
44+ try :
45+ from typing import Tuple
46+ from busio import I2C
47+ except ImportError :
48+ pass
49+
4350_MSA301_I2CADDR_DEFAULT = const (0x26 )
4451_MSA311_I2CADDR_DEFAULT = const (0x62 )
4552
@@ -244,7 +251,7 @@ def __init__(self):
244251 self ._tap_count = 0
245252
246253 @property
247- def acceleration (self ):
254+ def acceleration (self ) -> Tuple [ float , float , float ] :
248255 """The x, y, z acceleration values returned in a
249256 3-tuple and are in :math:`m / s ^ 2`"""
250257 # read the 6 bytes of acceleration data
@@ -268,12 +275,12 @@ def acceleration(self):
268275 def enable_tap_detection (
269276 self ,
270277 * ,
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 :
277284 """
278285 Enables tap detection with configurable parameters.
279286
@@ -321,7 +328,7 @@ def enable_tap_detection(
321328 raise ValueError ("tap must be 1 for single tap, or 2 for double tap" )
322329
323330 @property
324- def tapped (self ):
331+ def tapped (self ) -> bool :
325332 """`True` if a single or double tap was detected, depending on the value of the\
326333 ``tap_count`` argument passed to ``enable_tap_detection``"""
327334 if self ._tap_count == 0 :
@@ -346,7 +353,7 @@ class MSA301(MSA3XX):
346353 :param ~busio.I2C i2c_bus: The I2C bus the MSA is connected to.
347354 """
348355
349- def __init__ (self , i2c_bus ):
356+ def __init__ (self , i2c_bus : I2C ):
350357 self .i2c_device = i2cdevice .I2CDevice (i2c_bus , _MSA301_I2CADDR_DEFAULT )
351358
352359 if self ._part_id != 0x13 :
@@ -361,7 +368,7 @@ class MSA311(MSA3XX):
361368 :param ~busio.I2C i2c_bus: The I2C bus the MSA is connected to.
362369 """
363370
364- def __init__ (self , i2c_bus ):
371+ def __init__ (self , i2c_bus : I2C ):
365372 self .i2c_device = i2cdevice .I2CDevice (i2c_bus , _MSA311_I2CADDR_DEFAULT )
366373
367374 if self ._part_id != 0x13 :
0 commit comments