Skip to content

Commit b862de5

Browse files
author
Melissa LeBlanc-Williams
committed
Linting
1 parent a6bbcca commit b862de5

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

adafruit_featherwing/dotstar_featherwing.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class PixelDisplayFeatherWing:
3939
4040
The feather uses pins D13 and D11"""
4141
def __init__(self):
42+
self.rows = 0
43+
self.columns = 0
44+
self._display = None
4245
self._auto_write = True
4346

4447
def __setitem__(self, indices, value):
@@ -53,8 +56,9 @@ def __setitem__(self, indices, value):
5356
a single, longer int that contains RGB values, like 0xFFFFFF
5457
brightness, if specified should be a float 0-1
5558
"""
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()
5862

5963
def __getitem__(self, indices):
6064
"""
@@ -63,7 +67,10 @@ def __getitem__(self, indices):
6367
a slice of DotStar indexes to retrieve
6468
a single int that specifies the DotStar index
6569
"""
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
6774

6875
def _get_index(self, indices):
6976
"""
@@ -161,11 +168,11 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
161168
:param pin data: The data pin for the featherwing
162169
:param float brightness: Optional brightness (0.0-1.0) that defaults to 1.0
163170
"""
171+
super().__init__()
164172
self.rows = 6
165173
self.columns = 12
166174
self._display = dotstar.DotStar(clock, data, self.rows * self.columns,
167175
brightness=brightness, auto_write=False)
168-
super().__init__()
169176

170177
def fill(self, color=0):
171178
"""
@@ -405,4 +412,4 @@ def brightness(self):
405412
@brightness.setter
406413
def brightness(self, brightness):
407414
self._display.brightness = min(max(brightness, 0.0), 1.0)
408-
self._update()
415+
self._update()

adafruit_featherwing/neopixel_featherwing.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,12 @@ def __init__(self, pixel_pin=board.D6, brightness=0.1):
4545
:param pin pixel_pin: The pin for the featherwing
4646
:param float brightness: Optional brightness (0.0-1.0) that defaults to 1.0
4747
"""
48-
49-
# The order of the pixel colors - RGB or GRB. Some NeoPixels have red and green reversed!
50-
# For RGBW NeoPixels, simply change the ORDER to RGBW or GRBW.
51-
48+
super().__init__()
5249
self.rows = 4
5350
self.columns = 8
5451
self._display = neopixel.NeoPixel(pixel_pin, self.rows * self.columns,
5552
brightness=brightness, auto_write=False,
5653
pixel_order=neopixel.GRB)
57-
super().__init__()
5854

5955
def fill(self, color=0):
6056
"""
@@ -292,4 +288,4 @@ def brightness(self):
292288
@brightness.setter
293289
def brightness(self, brightness):
294290
self._display.brightness = min(max(brightness, 0.0), 1.0)
295-
self._update()
291+
self._update()

0 commit comments

Comments
 (0)