10
10
"""
11
11
from adafruit_ht16k33 .ht16k33 import HT16K33
12
12
13
- try :
14
- from typing import Union , List , Tuple , Optional
15
- from busio import I2C
16
- from PIL import Image
17
- except ImportError :
18
- pass
19
13
20
14
__version__ = "0.0.0+auto.0"
21
15
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HT16K33.git"
@@ -27,7 +21,7 @@ class Matrix8x8(HT16K33):
27
21
_columns = 8
28
22
_rows = 8
29
23
30
- def pixel (self , x : int , y : int , color : Optional [ bool ] = None ) -> Optional [ bool ] :
24
+ def pixel (self , x , y , color = None ):
31
25
"""Get or set the color of a given pixel.
32
26
33
27
:param int x: The x coordinate of the pixel
@@ -43,16 +37,16 @@ def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
43
37
x = (x - 1 ) % 8
44
38
return super ()._pixel (x , y , color )
45
39
46
- def __getitem__ (self , key : int ) -> Optional [ bool ] :
40
+ def __getitem__ (self , key ) :
47
41
x , y = key
48
42
return self .pixel (x , y )
49
43
50
- def __setitem__ (self , key : int , value : bool ) -> None :
44
+ def __setitem__ (self , key , value ) :
51
45
x , y = key
52
46
self .pixel (x , y , value )
53
47
54
48
# pylint: disable=too-many-branches
55
- def shift (self , x : int , y : int , rotate : bool = False ) -> None :
49
+ def shift (self , x , y , rotate = False ):
56
50
"""
57
51
Shift pixels by x and y
58
52
@@ -96,39 +90,39 @@ def shift(self, x: int, y: int, rotate: bool = False) -> None:
96
90
97
91
# pylint: enable=too-many-branches
98
92
99
- def shift_right (self , rotate : bool = False ) -> None :
93
+ def shift_right (self , rotate = False ):
100
94
"""
101
95
Shift all pixels right
102
96
103
97
:param rotate: (Optional) Rotate the shifted pixels to the left side (default=False)
104
98
"""
105
99
self .shift (1 , 0 , rotate )
106
100
107
- def shift_left (self , rotate : bool = False ) -> None :
101
+ def shift_left (self , rotate = False ):
108
102
"""
109
103
Shift all pixels left
110
104
111
105
:param rotate: (Optional) Rotate the shifted pixels to the right side (default=False)
112
106
"""
113
107
self .shift (- 1 , 0 , rotate )
114
108
115
- def shift_up (self , rotate : bool = False ) -> None :
109
+ def shift_up (self , rotate = False ):
116
110
"""
117
111
Shift all pixels up
118
112
119
113
:param rotate: (Optional) Rotate the shifted pixels to bottom (default=False)
120
114
"""
121
115
self .shift (0 , 1 , rotate )
122
116
123
- def shift_down (self , rotate : bool = False ) -> None :
117
+ def shift_down (self , rotate = False ):
124
118
"""
125
119
Shift all pixels down
126
120
127
121
:param rotate: (Optional) Rotate the shifted pixels to top (default=False)
128
122
"""
129
123
self .shift (0 , - 1 , rotate )
130
124
131
- def image (self , img : Image ) -> None :
125
+ def image (self , img ) :
132
126
"""Set buffer to value of Python Imaging Library image. The image should
133
127
be in 1 bit mode and a size equal to the display size.
134
128
@@ -155,12 +149,12 @@ def image(self, img: Image) -> None:
155
149
self .show ()
156
150
157
151
@property
158
- def columns (self ) -> int :
152
+ def columns (self ):
159
153
"""Read-only property for number of columns"""
160
154
return self ._columns
161
155
162
156
@property
163
- def rows (self ) -> int :
157
+ def rows (self ):
164
158
"""Read-only property for number of rows"""
165
159
return self ._rows
166
160
@@ -172,15 +166,15 @@ class Matrix16x8(Matrix8x8):
172
166
173
167
def __init__ (
174
168
self ,
175
- i2c : I2C ,
176
- address : Union [ int , Tuple , List ] = 0x70 ,
177
- auto_write : bool = True ,
178
- brightness : float = 1.0 ,
179
- ) -> None :
169
+ i2c ,
170
+ address = 0x70 ,
171
+ auto_write = True ,
172
+ brightness = 1.0 ,
173
+ ):
180
174
super ().__init__ (i2c , address , auto_write , brightness )
181
175
self ._columns *= len (self .i2c_device )
182
176
183
- def pixel (self , x : int , y : int , color : Optional [ bool ] = None ) -> Optional [ bool ] :
177
+ def pixel (self , x , y , color = None ):
184
178
"""Get or set the color of a given pixel.
185
179
186
180
:param int x: The x coordinate of the pixel
@@ -204,7 +198,7 @@ def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
204
198
class MatrixBackpack16x8 (Matrix16x8 ):
205
199
"""A double matrix backpack."""
206
200
207
- def pixel (self , x : int , y : int , color : Optional [ bool ] = None ) -> Optional [ bool ] :
201
+ def pixel (self , x , y , color = None ):
208
202
"""Get or set the color of a given pixel.
209
203
210
204
:param int x: The x coordinate of the pixel
@@ -229,7 +223,7 @@ class Matrix8x8x2(Matrix8x8):
229
223
LED_GREEN = 2
230
224
LED_YELLOW = 3
231
225
232
- def pixel (self , x : int , y : int , color : Optional [ bool ] = None ) -> Optional [ bool ] :
226
+ def pixel (self , x , y , color = None ):
233
227
"""Get or set the color of a given pixel.
234
228
235
229
:param int x: The x coordinate of the pixel
@@ -249,7 +243,7 @@ def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
249
243
return super ()._pixel (y , x ) | super ()._pixel (y + 8 , x ) << 1
250
244
return None
251
245
252
- def fill (self , color : bool ) -> None :
246
+ def fill (self , color ) :
253
247
"""Fill the whole display with the given color.
254
248
255
249
:param bool color: Whether to fill the display
@@ -263,7 +257,7 @@ def fill(self, color: bool) -> None:
263
257
if self ._auto_write :
264
258
self .show ()
265
259
266
- def image (self , img : Image ) -> None :
260
+ def image (self , img ) :
267
261
"""Set buffer to value of Python Imaging Library image. The image should
268
262
be a size equal to the display size.
269
263
0 commit comments