speed bar generation by not querying pixels

In a test this improved speed substantially, nearly doubling
the speed of the following test program
```python
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=1, auto_write=False, pixel_order="RGB")
evens = helper.PixelMap(pixels, [(i,) for i in range(0, pixel_num, 2)], individual_pixels=True)
animation = RainbowChase(evens, 0, spacing=8)
t0 = adafruit_ticks.ticks_ms()
while True:
    for i in range(10):
        animation.animate(show=False)
    t1 = adafruit_ticks.ticks_ms()
    print(f"{10000/(t1-t0):.0f}fps")
    t0 = t1
```

Performance on Raspberry Pi Pico W:
Before: ~85fps
After: ~140fps

This also happens to make it compatible with an in-process PR that adds
a fast PixelMap-like class to the core, but which doesn't support
getitem.
This commit is contained in:
Jeff Epler 2022-11-10 14:53:25 -06:00
parent 16179eaadf
commit 914bb8060b
No known key found for this signature in database
GPG key ID: D5BF15AB975AB4DE

View file

@ -96,7 +96,7 @@ class Chase(Animation):
bar_no += 1
colorgen = bar_colors()
self.pixel_object[:] = [next(colorgen) for _ in self.pixel_object]
self.pixel_object[:] = [next(colorgen) for _ in range(len(self.pixel_object))]
if self.draw_count % len(self.pixel_object) == 0:
self.cycle_complete = True