Skip to content

Commit

Permalink
Merge pull request #12 from mattytrentini/master
Browse files Browse the repository at this point in the history
Changing brightness will now update the strip if auto_write is True. …
  • Loading branch information
tannewt authored Feb 10, 2018
2 parents 492dc83 + 503e854 commit b9894d7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions adafruit_dotstar.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def __init__(self, clock, data, n, *, brightness=1.0, auto_write=True):
for i in range(self.end_header_index, len(self._buf)):
self._buf[i] = 0xff
self._brightness = 1.0
# 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 @@ -182,6 +185,8 @@ def brightness(self):
@brightness.setter
def brightness(self, brightness):
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 b9894d7

Please sign in to comment.