drivers/neopixel: Optimize fill() for speed.
This makes fill() about 7x faster (PYBV11 and PYBD_SF6) for the cost of +40 bytes of bytecode (or 120 bytes text). Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
a3ce8f08ec
commit
d63b287c85
|
@ -37,8 +37,11 @@ class NeoPixel:
|
|||
return tuple(self.buf[offset + self.ORDER[i]] for i in range(self.bpp))
|
||||
|
||||
def fill(self, color):
|
||||
for i in range(self.n):
|
||||
self[i] = color
|
||||
for i in range(self.bpp):
|
||||
c = color[i]
|
||||
b = self.buf
|
||||
for j in range(self.ORDER[i], len(self.buf), self.bpp):
|
||||
b[j] = c
|
||||
|
||||
def write(self):
|
||||
bitstream(self.pin, _BITSTREAM_TYPE_HIGH_LOW, self.timing, self.buf)
|
||||
|
|
Loading…
Reference in New Issue