From 9cb567f0131d6ab3cd045711c9a73bc5cf6683ca Mon Sep 17 00:00:00 2001 From: hberg32 Date: Thu, 31 Jul 2025 16:41:58 -0400 Subject: [PATCH] Fix initial offset calculation when reversed in chase.py Found a bug in the chase animation when reverse is set to True which results in the animation being offset by the length of the size parameter. You can observe this by setting up two animations of equal length on a single strip of pixels with the second one reversed. The bars should appear to meet in the middle but don't. Example: pixels = neopixel.NeoPixel(board.A0, 22, auto_write=False, brightness = .5) left_pixels = PixelSubset(pixels, 0, 11) right_pixels = PixelSubset(pixels, 11, 22) left_animation = Chase( left_pixels, speed=.5, color=CYAN, size=2, spacing=11 ) right_animation = Chase( right_pixels, speed=.5, color=CYAN, size=2, spacing=11, reverse=True ) animations = AnimationSequence( AnimationGroup( left_animation, right_animation, sync=True ), auto_clear=True, auto_reset=True, ) while True: animations.animate() --- adafruit_led_animation/animation/chase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_led_animation/animation/chase.py b/adafruit_led_animation/animation/chase.py index 5437ad5..11f68ae 100644 --- a/adafruit_led_animation/animation/chase.py +++ b/adafruit_led_animation/animation/chase.py @@ -51,10 +51,10 @@ class Chase(Animation): self._overflow = len(pixel_object) % self._repeat_width self._direction = 1 if not reverse else -1 self._reverse = reverse - self._offset = 0 + self._offset = 0 if not reverse else len(pixel_object) - size def _resetter(): - self._offset = 0 + self._offset = 0 if not reverse else len(self.pixel_object) - size self._reverse = reverse self._direction = 1 if not reverse else -1