From b862de51b27ec0c948e4ce684a0a18f6221de339 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 5 Feb 2019 19:10:44 -0800 Subject: [PATCH] Linting --- adafruit_featherwing/dotstar_featherwing.py | 17 ++++++++++++----- adafruit_featherwing/neopixel_featherwing.py | 8 ++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/adafruit_featherwing/dotstar_featherwing.py b/adafruit_featherwing/dotstar_featherwing.py index 5043f4f..d0ac87f 100755 --- a/adafruit_featherwing/dotstar_featherwing.py +++ b/adafruit_featherwing/dotstar_featherwing.py @@ -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): @@ -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): """ @@ -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): """ @@ -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): """ @@ -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() \ No newline at end of file + self._update() diff --git a/adafruit_featherwing/neopixel_featherwing.py b/adafruit_featherwing/neopixel_featherwing.py index 250d853..7e1b188 100755 --- a/adafruit_featherwing/neopixel_featherwing.py +++ b/adafruit_featherwing/neopixel_featherwing.py @@ -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): """ @@ -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() \ No newline at end of file + self._update()