Skip to content

Commit 2d67238

Browse files
mattytrentinimcscope
authored andcommitted
Changing brightness will now update the strip if auto_write is True. See Issue adafruit#10.
1 parent 84534e0 commit 2d67238

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)