Skip to content

Commit 9183d5c

Browse files
committed
add ability to disable calling show
1 parent 3692fb3 commit 9183d5c

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

adafruit_led_animation/animation/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ def __init__(self, pixel_object, speed, color, peers=None, paused=False, name=No
8181
def __str__(self):
8282
return "<%s: %s>" % (self.__class__.__name__, self.name)
8383

84-
def animate(self):
84+
def animate(self, show=True):
8585
"""
8686
Call animate() from your code's main loop. It will draw the animation draw() at intervals
8787
configured by the speed property (set from init).
8888
89+
:param bool show: Whether to automatically call show on the pixel object when an animation
90+
fires. Default True.
8991
:return: True if the animation draw cycle was triggered, otherwise False.
9092
"""
9193
if self._paused:
@@ -97,11 +99,13 @@ def animate(self):
9799

98100
# Draw related animations together
99101
for anim in self._peers:
102+
anim.draw_count += 1
100103
anim.draw()
101104
anim.after_draw()
102105

103-
for anim in self._peers:
104-
anim.show()
106+
if show:
107+
for anim in self._peers:
108+
anim.show()
105109

106110
# Note that the main animation cycle_complete flag is used, not the peer flag.
107111
for anim in self._peers:

adafruit_led_animation/animation/rainbowwave.py

Whitespace-only changes.

adafruit_led_animation/group.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,20 @@ def add_cycle_complete_receiver(self, callback):
148148
"""
149149
self._also_notify.append(callback)
150150

151-
def animate(self):
151+
def animate(self, show=True):
152152
"""
153153
Call animate() from your code's main loop. It will draw all of the animations
154154
in the group.
155155
156156
:return: True if any animation draw cycle was triggered, otherwise False.
157157
"""
158158
if self._sync:
159-
return self._members[0].animate()
159+
result = self._members[0].animate(show=False)
160+
if result and show:
161+
self._members[0].show()
162+
return result
160163

161-
return any([item.animate() for item in self._members])
164+
return any([item.animate(show) for item in self._members])
162165

163166
@property
164167
def color(self):

adafruit_led_animation/sequence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def random(self):
205205
"""
206206
self.activate(random.randint(0, len(self._members) - 1))
207207

208-
def animate(self):
208+
def animate(self, show=True):
209209
"""
210210
Call animate() from your code's main loop. It will draw the current animation
211211
or go to the next animation based on the advance_interval if set.
@@ -214,7 +214,7 @@ def animate(self):
214214
"""
215215
if not self._paused and self._advance_interval:
216216
self._auto_advance()
217-
return self.current_animation.animate()
217+
return self.current_animation.animate(show)
218218

219219
@property
220220
def current_animation(self):

0 commit comments

Comments
 (0)