From 3692fb3e2740045e300f6eebd86aa5f61314b0db Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 7 Jun 2020 12:15:13 -0400 Subject: [PATCH 1/3] Fix PixelMap auto_write value. --- adafruit_led_animation/helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_led_animation/helper.py b/adafruit_led_animation/helper.py index 255a2d0..dcf1b50 100644 --- a/adafruit_led_animation/helper.py +++ b/adafruit_led_animation/helper.py @@ -124,7 +124,7 @@ def __setitem__(self, index, val): else: self._set_pixels(index, val) - if not self._pixels.auto_write: + if self.auto_write: self.show() def __getitem__(self, index): @@ -310,7 +310,7 @@ def __setitem__(self, index, val): else: self._pixels[index + self._start] = val - if not self._pixels.auto_write: + if self.auto_write: self.show() def __getitem__(self, index): From 9183d5c7dbf4af43825491a3d7d207e4fcf450f3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 7 Jun 2020 12:15:44 -0400 Subject: [PATCH 2/3] add ability to disable calling show --- adafruit_led_animation/animation/__init__.py | 10 +++++++--- adafruit_led_animation/animation/rainbowwave.py | 0 adafruit_led_animation/group.py | 9 ++++++--- adafruit_led_animation/sequence.py | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 adafruit_led_animation/animation/rainbowwave.py diff --git a/adafruit_led_animation/animation/__init__.py b/adafruit_led_animation/animation/__init__.py index 6327ead..63415af 100644 --- a/adafruit_led_animation/animation/__init__.py +++ b/adafruit_led_animation/animation/__init__.py @@ -81,11 +81,13 @@ def __init__(self, pixel_object, speed, color, peers=None, paused=False, name=No def __str__(self): return "<%s: %s>" % (self.__class__.__name__, self.name) - def animate(self): + def animate(self, show=True): """ Call animate() from your code's main loop. It will draw the animation draw() at intervals configured by the speed property (set from init). + :param bool show: Whether to automatically call show on the pixel object when an animation + fires. Default True. :return: True if the animation draw cycle was triggered, otherwise False. """ if self._paused: @@ -97,11 +99,13 @@ def animate(self): # Draw related animations together for anim in self._peers: + anim.draw_count += 1 anim.draw() anim.after_draw() - for anim in self._peers: - anim.show() + if show: + for anim in self._peers: + anim.show() # Note that the main animation cycle_complete flag is used, not the peer flag. for anim in self._peers: diff --git a/adafruit_led_animation/animation/rainbowwave.py b/adafruit_led_animation/animation/rainbowwave.py new file mode 100644 index 0000000..e69de29 diff --git a/adafruit_led_animation/group.py b/adafruit_led_animation/group.py index a9dacb9..0005170 100644 --- a/adafruit_led_animation/group.py +++ b/adafruit_led_animation/group.py @@ -148,7 +148,7 @@ def add_cycle_complete_receiver(self, callback): """ self._also_notify.append(callback) - def animate(self): + def animate(self, show=True): """ Call animate() from your code's main loop. It will draw all of the animations in the group. @@ -156,9 +156,12 @@ def animate(self): :return: True if any animation draw cycle was triggered, otherwise False. """ if self._sync: - return self._members[0].animate() + result = self._members[0].animate(show=False) + if result and show: + self._members[0].show() + return result - return any([item.animate() for item in self._members]) + return any([item.animate(show) for item in self._members]) @property def color(self): diff --git a/adafruit_led_animation/sequence.py b/adafruit_led_animation/sequence.py index 3532cde..8997c5b 100644 --- a/adafruit_led_animation/sequence.py +++ b/adafruit_led_animation/sequence.py @@ -205,7 +205,7 @@ def random(self): """ self.activate(random.randint(0, len(self._members) - 1)) - def animate(self): + def animate(self, show=True): """ Call animate() from your code's main loop. It will draw the current animation or go to the next animation based on the advance_interval if set. @@ -214,7 +214,7 @@ def animate(self): """ if not self._paused and self._advance_interval: self._auto_advance() - return self.current_animation.animate() + return self.current_animation.animate(show) @property def current_animation(self): From e1d4f0d940388b8f5fff0ab4aef13fb8b3191d45 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 8 Jun 2020 20:33:58 -0400 Subject: [PATCH 3/3] remove stray file --- adafruit_led_animation/animation/rainbowwave.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 adafruit_led_animation/animation/rainbowwave.py diff --git a/adafruit_led_animation/animation/rainbowwave.py b/adafruit_led_animation/animation/rainbowwave.py deleted file mode 100644 index e69de29..0000000