Skip to content

Commit

Permalink
Merge pull request #23 from kattni/brightness-show
Browse files Browse the repository at this point in the history
Update to brightness
  • Loading branch information
tannewt authored Feb 12, 2018
2 parents d7b1307 + cac9340 commit c72d18c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions neopixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def __init__(self, pin, n, *, bpp=3, brightness=1.0, auto_write=True):
self.n = n
self.bpp = bpp
self.buf = bytearray(n * bpp)
# Set auto_write to False temporarily so brightness setter does _not_
# call show() while in __init__.
self.auto_write = False
self.brightness = brightness
self.auto_write = auto_write

Expand Down Expand Up @@ -178,6 +181,8 @@ def brightness(self):
def brightness(self, brightness):
# pylint: disable=attribute-defined-outside-init
self._brightness = min(max(brightness, 0.0), 1.0)
if self.auto_write:
self.show()

def fill(self, color):
"""Colors all pixels the given ***color***."""
Expand Down

0 comments on commit c72d18c

Please sign in to comment.