From beaa41f0cb5961096398e1388bf0989d82cdc0a3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 22 Jun 2020 18:15:08 -0400 Subject: [PATCH] fix sparklepulse to use _set_color --- adafruit_led_animation/animation/__init__.py | 4 ++-- adafruit_led_animation/animation/sparklepulse.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/adafruit_led_animation/animation/__init__.py b/adafruit_led_animation/animation/__init__.py index b9e76c1..2876afe 100644 --- a/adafruit_led_animation/animation/__init__.py +++ b/adafruit_led_animation/animation/__init__.py @@ -185,6 +185,8 @@ class Animation: def color(self, color): if self._color == color: return + if isinstance(color, int): + color = (color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF) self._set_color(color) def _set_color(self, color): @@ -192,8 +194,6 @@ class Animation: Called after the color is changed, which includes at initialization. Override as needed. """ - if isinstance(color, int): - color = (color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF) self._color = color @property diff --git a/adafruit_led_animation/animation/sparklepulse.py b/adafruit_led_animation/animation/sparklepulse.py index 8e41bf2..9a06848 100644 --- a/adafruit_led_animation/animation/sparklepulse.py +++ b/adafruit_led_animation/animation/sparklepulse.py @@ -80,6 +80,9 @@ class SparklePulse(Sparkle): ) self._generator = pulse_generator(self._period, self, dotstar_pwm=dotstar) + def _set_color(self, color): + self._color = color + def draw(self): self._sparkle_color = next(self._generator) super().draw()