Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Melissa LeBlanc-Williams committed Feb 6, 2019
1 parent a6bbcca commit b862de5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
17 changes: 12 additions & 5 deletions adafruit_featherwing/dotstar_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class PixelDisplayFeatherWing:
The feather uses pins D13 and D11"""
def __init__(self):
self.rows = 0
self.columns = 0
self._display = None
self._auto_write = True

def __setitem__(self, indices, value):
Expand All @@ -53,8 +56,9 @@ def __setitem__(self, indices, value):
a single, longer int that contains RGB values, like 0xFFFFFF
brightness, if specified should be a float 0-1
"""
self._display[self._get_index(indices)] = value
self._update()
if self._display is not None:
self._display[self._get_index(indices)] = value
self._update()

def __getitem__(self, indices):
"""
Expand All @@ -63,7 +67,10 @@ def __getitem__(self, indices):
a slice of DotStar indexes to retrieve
a single int that specifies the DotStar index
"""
return self._display[self._get_index(indices)]
if self._display is not None:
return self._display[self._get_index(indices)]
else:
return None

def _get_index(self, indices):
"""
Expand Down Expand Up @@ -161,11 +168,11 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
:param pin data: The data pin for the featherwing
:param float brightness: Optional brightness (0.0-1.0) that defaults to 1.0
"""
super().__init__()
self.rows = 6
self.columns = 12
self._display = dotstar.DotStar(clock, data, self.rows * self.columns,
brightness=brightness, auto_write=False)
super().__init__()

def fill(self, color=0):
"""
Expand Down Expand Up @@ -405,4 +412,4 @@ def brightness(self):
@brightness.setter
def brightness(self, brightness):
self._display.brightness = min(max(brightness, 0.0), 1.0)
self._update()
self._update()
8 changes: 2 additions & 6 deletions adafruit_featherwing/neopixel_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ def __init__(self, pixel_pin=board.D6, brightness=0.1):
:param pin pixel_pin: The pin for the featherwing
:param float brightness: Optional brightness (0.0-1.0) that defaults to 1.0
"""

# The order of the pixel colors - RGB or GRB. Some NeoPixels have red and green reversed!
# For RGBW NeoPixels, simply change the ORDER to RGBW or GRBW.

super().__init__()
self.rows = 4
self.columns = 8
self._display = neopixel.NeoPixel(pixel_pin, self.rows * self.columns,
brightness=brightness, auto_write=False,
pixel_order=neopixel.GRB)
super().__init__()

def fill(self, color=0):
"""
Expand Down Expand Up @@ -292,4 +288,4 @@ def brightness(self):
@brightness.setter
def brightness(self, brightness):
self._display.brightness = min(max(brightness, 0.0), 1.0)
self._update()
self._update()

0 comments on commit b862de5

Please sign in to comment.