Skip to content

Commit b9894d7

Browse files
authored
Merge pull request #12 from mattytrentini/master
Changing brightness will now update the strip if auto_write is True. …
2 parents 492dc83 + 503e854 commit b9894d7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

adafruit_dotstar.py

+5
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ def __init__(self, clock, data, n, *, brightness=1.0, auto_write=True):
9595
for i in range(self.end_header_index, len(self._buf)):
9696
self._buf[i] = 0xff
9797
self._brightness = 1.0
98+
# Set auto_write to False temporarily so brightness setter does _not_
99+
# call show() while in __init__.
100+
self.auto_write = False
98101
self.brightness = brightness
99102
self.auto_write = auto_write
100103

@@ -182,6 +185,8 @@ def brightness(self):
182185
@brightness.setter
183186
def brightness(self, brightness):
184187
self._brightness = min(max(brightness, 0.0), 1.0)
188+
if self.auto_write:
189+
self.show()
185190

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

0 commit comments

Comments
 (0)