28
28
import digitalio
29
29
import adafruit_bus_device .spi_device as spi_device
30
30
31
+
32
+
31
33
__version__ = "0.0.0-auto.0"
32
34
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_74HC595.git"
33
35
@@ -39,7 +41,7 @@ class DigitalInOut:
39
41
direction as input will raise an exception.
40
42
"""
41
43
42
- def __init__ (self , pin_number , shift_register_74hc595 ):
44
+ def __init__ (self , pin_number : 'microcontroller.Pin' , shift_register_74hc595 : 'ShiftRegister74HC595' ):
43
45
"""Specify the pin number of the shift register (0...7) and
44
46
ShiftRegister74HC595 instance.
45
47
"""
@@ -53,7 +55,7 @@ def __init__(self, pin_number, shift_register_74hc595):
53
55
# is unused by this class). Do not remove them, instead turn off pylint
54
56
# in this case.
55
57
# pylint: disable=unused-argument
56
- def switch_to_output (self , value = False , ** kwargs ):
58
+ def switch_to_output (self , value : bool = False , ** kwargs ):
57
59
"""``DigitalInOut switch_to_output``"""
58
60
self .direction = digitalio .Direction .OUTPUT
59
61
self .value = value
@@ -72,7 +74,7 @@ def value(self):
72
74
)
73
75
74
76
@value .setter
75
- def value (self , val ):
77
+ def value (self , val : bool ):
76
78
77
79
if (
78
80
self ._pin >= 0
@@ -91,7 +93,7 @@ def direction(self):
91
93
return digitalio .Direction .OUTPUT
92
94
93
95
@direction .setter
94
- def direction (self , val ): # pylint: disable=no-self-use
96
+ def direction (self , val : digitalio . Direction ): # pylint: disable=no-self-use
95
97
"""``Direction`` can only be set to ``OUTPUT``."""
96
98
if val != digitalio .Direction .OUTPUT :
97
99
raise RuntimeError ("Digital input not supported." )
@@ -102,7 +104,7 @@ def pull(self):
102
104
return None
103
105
104
106
@pull .setter
105
- def pull (self , val ): # pylint: disable=no-self-use
107
+ def pull (self , val : digitalio . Pull ): # pylint: disable=no-self-use
106
108
"""Only supports null/no pull state."""
107
109
if val is not None :
108
110
raise RuntimeError ("Pull-up and pull-down not supported." )
@@ -113,7 +115,7 @@ class ShiftRegister74HC595:
113
115
and indicate the number of shift registers being used
114
116
"""
115
117
116
- def __init__ (self , spi , latch , number_of_shift_registers = 1 ):
118
+ def __init__ (self , spi : 'busio.I2C' , latch : digitalio . DigitalInOut , number_of_shift_registers : int = 1 ):
117
119
self ._device = spi_device .SPIDevice (spi , latch , baudrate = 1000000 )
118
120
self ._number_of_shift_registers = number_of_shift_registers
119
121
self ._gpio = bytearray (self ._number_of_shift_registers )
@@ -131,14 +133,14 @@ def gpio(self):
131
133
return self ._gpio
132
134
133
135
@gpio .setter
134
- def gpio (self , val ):
136
+ def gpio (self , val : '_typing.ReadableBuffer' ):
135
137
self ._gpio = val
136
138
137
139
with self ._device as spi :
138
140
# pylint: disable=no-member
139
141
spi .write (self ._gpio )
140
142
141
- def get_pin (self , pin ) :
143
+ def get_pin (self , pin : int ) -> 'microcontroller.Pin' :
142
144
"""Convenience function to create an instance of the DigitalInOut class
143
145
pointing at the specified pin of this 74HC595 device .
144
146
"""
0 commit comments