@@ -39,6 +39,9 @@ class PixelDisplayFeatherWing:
39
39
40
40
The feather uses pins D13 and D11"""
41
41
def __init__ (self ):
42
+ self .rows = 0
43
+ self .columns = 0
44
+ self ._display = None
42
45
self ._auto_write = True
43
46
44
47
def __setitem__ (self , indices , value ):
@@ -53,8 +56,9 @@ def __setitem__(self, indices, value):
53
56
a single, longer int that contains RGB values, like 0xFFFFFF
54
57
brightness, if specified should be a float 0-1
55
58
"""
56
- self ._display [self ._get_index (indices )] = value
57
- self ._update ()
59
+ if self ._display is not None :
60
+ self ._display [self ._get_index (indices )] = value
61
+ self ._update ()
58
62
59
63
def __getitem__ (self , indices ):
60
64
"""
@@ -63,7 +67,10 @@ def __getitem__(self, indices):
63
67
a slice of DotStar indexes to retrieve
64
68
a single int that specifies the DotStar index
65
69
"""
66
- return self ._display [self ._get_index (indices )]
70
+ if self ._display is not None :
71
+ return self ._display [self ._get_index (indices )]
72
+ else :
73
+ return None
67
74
68
75
def _get_index (self , indices ):
69
76
"""
@@ -161,11 +168,11 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
161
168
:param pin data: The data pin for the featherwing
162
169
:param float brightness: Optional brightness (0.0-1.0) that defaults to 1.0
163
170
"""
171
+ super ().__init__ ()
164
172
self .rows = 6
165
173
self .columns = 12
166
174
self ._display = dotstar .DotStar (clock , data , self .rows * self .columns ,
167
175
brightness = brightness , auto_write = False )
168
- super ().__init__ ()
169
176
170
177
def fill (self , color = 0 ):
171
178
"""
@@ -405,4 +412,4 @@ def brightness(self):
405
412
@brightness .setter
406
413
def brightness (self , brightness ):
407
414
self ._display .brightness = min (max (brightness , 0.0 ), 1.0 )
408
- self ._update ()
415
+ self ._update ()
0 commit comments