Commit d63b287c authored by Jim Mussared's avatar Jim Mussared Committed by Damien George
Browse files

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: default avatarJim Mussared <jim.mussared@gmail.com>
parent a3ce8f08
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment