1616__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
1717
1818import board
19- import adafruit_ht16k33 . matrix as matrix
19+ from adafruit_ht16k33 import matrix
2020
2121from adafruit_featherwing .auto_writeable import AutoWriteable
2222
23+ try :
24+ from typing import Optional , Tuple , Union
25+ from busio import I2C
26+ except ImportError :
27+ pass
28+
2329
2430class MatrixFeatherWing (AutoWriteable ):
2531 """Class representing an `Adafruit 8x16 LED Matrix FeatherWing
2632 <https://www.adafruit.com/product/3155>`_.
2733
2834 Automatically uses the feather's I2C bus."""
2935
30- def __init__ (self , address = 0x70 , i2c = None ):
36+ def __init__ (self , address : int = 0x70 , i2c : Optional [ I2C ] = None ):
3137
3238 if i2c is None :
3339 i2c = board .I2C ()
@@ -37,14 +43,14 @@ def __init__(self, address=0x70, i2c=None):
3743 self .rows = 8
3844 super ().__init__ ()
3945
40- def __getitem__ (self , key ) :
46+ def __getitem__ (self , key : Tuple [ int , int ]) -> bool :
4147 """
4248 Get the current value of a pixel
4349 """
4450 x , y = key
4551 return self .pixel (x , y )
4652
47- def __setitem__ (self , key , value ):
53+ def __setitem__ (self , key : Tuple [ int , int ], value : Union [ int , bool ] ):
4854 """
4955 Turn a pixel off or on
5056 """
@@ -59,7 +65,7 @@ def _update(self):
5965 if self ._auto_write :
6066 self ._matrix .show ()
6167
62- def pixel (self , x , y , color = None ):
68+ def pixel (self , x : int , y : int , color : Optional [ bool ] = None ) -> Optional [ bool ] :
6369 """
6470 Turn a pixel on or off or retrieve a pixel value
6571
@@ -79,7 +85,7 @@ def show(self):
7985 """
8086 self ._matrix .show ()
8187
82- def fill (self , fill ):
88+ def fill (self , fill : bool ):
8389 """
8490 Turn all pixels on or off
8591
@@ -92,7 +98,7 @@ def fill(self, fill):
9298 else :
9399 raise ValueError ("Must set to either True or False." )
94100
95- def shift_right (self , rotate = False ):
101+ def shift_right (self , rotate : bool = False ):
96102 """
97103 Shift all pixels right
98104
@@ -101,7 +107,7 @@ def shift_right(self, rotate=False):
101107 self ._matrix .shift_right (rotate )
102108 self ._update ()
103109
104- def shift_left (self , rotate = False ):
110+ def shift_left (self , rotate : bool = False ):
105111 """
106112 Shift all pixels left
107113
@@ -110,7 +116,7 @@ def shift_left(self, rotate=False):
110116 self ._matrix .shift_left (rotate )
111117 self ._update ()
112118
113- def shift_up (self , rotate = False ):
119+ def shift_up (self , rotate : bool = False ):
114120 """
115121 Shift all pixels up
116122
@@ -119,7 +125,7 @@ def shift_up(self, rotate=False):
119125 self ._matrix .shift_up (rotate )
120126 self ._update ()
121127
122- def shift_down (self , rotate = False ):
128+ def shift_down (self , rotate : bool = False ):
123129 """
124130 Shift all pixels down
125131
@@ -138,7 +144,7 @@ def blink_rate(self):
138144 return self ._matrix .blink_rate
139145
140146 @blink_rate .setter
141- def blink_rate (self , rate ):
147+ def blink_rate (self , rate : int ):
142148 self ._matrix .blink_rate = rate
143149
144150 @property
@@ -150,7 +156,7 @@ def brightness(self):
150156 return round (self ._matrix .brightness * 15 )
151157
152158 @brightness .setter
153- def brightness (self , brightness ):
159+ def brightness (self , brightness : int ):
154160 if not 0 <= brightness <= 15 :
155161 raise ValueError ("Brightness must be a value between 0 and 15" )
156162 self ._matrix .brightness = brightness / 15
0 commit comments