41
41
from adafruit_register .i2c_bit import RWBit
42
42
import adafruit_bus_device .i2c_device as i2cdevice
43
43
44
+ try :
45
+ import typing # pylint: disable=unused-import
46
+ from busio import I2C
47
+ except ImportError :
48
+ pass
49
+
44
50
_REG_WIPER = const (0x00 ) # Wiper value register (R/W)
45
51
_REG_CONTROL = const (0x02 ) # Configuration Register (R/W)
46
52
@@ -52,7 +58,7 @@ class DS3502:
52
58
:param address: The I2C device address for the sensor. Default is ``0x40``.
53
59
"""
54
60
55
- def __init__ (self , i2c_bus , address = 0x28 ):
61
+ def __init__ (self , i2c_bus : I2C , address : int = 0x28 ) -> None :
56
62
self .i2c_device = i2cdevice .I2CDevice (i2c_bus , address )
57
63
58
64
# set to mode 1 on init to not write to the IVR every time you set
@@ -62,20 +68,20 @@ def __init__(self, i2c_bus, address=0x28):
62
68
_write_only_to_wiper = RWBit (_REG_CONTROL , 7 )
63
69
64
70
@property
65
- def wiper (self ):
71
+ def wiper (self ) -> int :
66
72
"""The value of the potentionmeter's wiper.
67
73
68
74
:param wiper_value: The value from 0-127 to set the wiper to.
69
75
"""
70
76
return self ._wiper
71
77
72
78
@wiper .setter
73
- def wiper (self , value ) :
79
+ def wiper (self , value : int ) -> None :
74
80
if value < 0 or value > 127 :
75
81
raise ValueError ("wiper must be from 0-127" )
76
82
self ._wiper = value
77
83
78
- def set_default (self , default ) :
84
+ def set_default (self , default : int ) -> None :
79
85
"""Sets the wiper's default value and current value to the given value
80
86
81
87
:param new_default: The value from 0-127 to set as the wiper's default.
0 commit comments