Skip to content

Commit c72d18c

Browse files
authored
Merge pull request #23 from kattni/brightness-show
Update to brightness
2 parents d7b1307 + cac9340 commit c72d18c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

neopixel.py

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ def __init__(self, pin, n, *, bpp=3, brightness=1.0, auto_write=True):
8383
self.n = n
8484
self.bpp = bpp
8585
self.buf = bytearray(n * bpp)
86+
# Set auto_write to False temporarily so brightness setter does _not_
87+
# call show() while in __init__.
88+
self.auto_write = False
8689
self.brightness = brightness
8790
self.auto_write = auto_write
8891

@@ -178,6 +181,8 @@ def brightness(self):
178181
def brightness(self, brightness):
179182
# pylint: disable=attribute-defined-outside-init
180183
self._brightness = min(max(brightness, 0.0), 1.0)
184+
if self.auto_write:
185+
self.show()
181186

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

0 commit comments

Comments
 (0)