@@ -80,6 +80,7 @@ def __init__(
80
80
self ._seesaw .write (_NEOPIXEL_BASE , _NEOPIXEL_PIN , cmd )
81
81
cmd = struct .pack (">H" , n * self ._bpp )
82
82
self ._seesaw .write (_NEOPIXEL_BASE , _NEOPIXEL_BUF_LENGTH , cmd )
83
+ self ._pre_brightness_color = [None ] * n
83
84
84
85
@property
85
86
def brightness (self ):
@@ -90,8 +91,16 @@ def brightness(self):
90
91
def brightness (self , brightness ):
91
92
# pylint: disable=attribute-defined-outside-init
92
93
self ._brightness = min (max (brightness , 0.0 ), 1.0 )
93
- if self .auto_write :
94
+
95
+ # Suppress auto_write while updating brightness.
96
+ current_auto_write = self .auto_write
97
+ self .auto_write = False
98
+ for i in range (self ._n ):
99
+ if self ._pre_brightness_color [i ] is not None :
100
+ self [i ] = self ._pre_brightness_color [i ]
101
+ if current_auto_write :
94
102
self .show ()
103
+ self .auto_write = current_auto_write
95
104
96
105
def deinit (self ):
97
106
pass
@@ -114,6 +123,8 @@ def __setitem__(self, key, color):
114
123
else :
115
124
r , g , b , w = color
116
125
126
+ self ._pre_brightness_color [key ] = color
127
+
117
128
# If all components are the same and we have a white pixel then use it
118
129
# instead of the individual components.
119
130
if self ._bpp == 4 and r == g == b and w == 0 :
0 commit comments