Skip to content

Commit 914bb80

Browse files
committed
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.
1 parent 16179ea commit 914bb80

File tree

1 file changed

+1
-1
lines changed
  • adafruit_led_animation/animation

1 file changed

+1
-1
lines changed

adafruit_led_animation/animation/chase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def bar_colors():
9696
bar_no += 1
9797

9898
colorgen = bar_colors()
99-
self.pixel_object[:] = [next(colorgen) for _ in self.pixel_object]
99+
self.pixel_object[:] = [next(colorgen) for _ in range(len(self.pixel_object))]
100100

101101
if self.draw_count % len(self.pixel_object) == 0:
102102
self.cycle_complete = True

0 commit comments

Comments
 (0)