Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
python-ev3dev2 (2.1.0) UNRELEASED; urgency=medium

[Matěj Volf]
* LED animation fix duration None
* Add rest notes to sound.Sound.play_song()

[Kaelin Laundry]
Expand Down
18 changes: 10 additions & 8 deletions ev3dev2/led.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ def all_off(self):
if not self.leds:
return

self.animate_stop()

for led in self.leds.values():
led.brightness = 0

Expand Down Expand Up @@ -401,7 +403,7 @@ def animate_police_lights(self, color1, color2, group1='LEFT', group2='RIGHT', s
def _animate_police_lights():
self.all_off()
even = True
duration_ms = duration * 1000
duration_ms = duration * 1000 if duration is not None else None
stopwatch = StopWatch()
stopwatch.start()

Expand All @@ -413,7 +415,7 @@ def _animate_police_lights():
self.set_color(group1, color2)
self.set_color(group2, color1)

if self.animate_thread_stop or stopwatch.value_ms >= duration_ms:
if self.animate_thread_stop or stopwatch.is_elapsed_ms(duration_ms):
break

even = not even
Expand Down Expand Up @@ -446,7 +448,7 @@ def animate_flash(self, color, groups=('LEFT', 'RIGHT'), sleeptime=0.5, duration

def _animate_flash():
even = True
duration_ms = duration * 1000
duration_ms = duration * 1000 if duration is not None else None
stopwatch = StopWatch()
stopwatch.start()

Expand All @@ -457,7 +459,7 @@ def _animate_flash():
else:
self.all_off()

if self.animate_thread_stop or stopwatch.value_ms >= duration_ms:
if self.animate_thread_stop or stopwatch.is_elapsed_ms(duration_ms):
break

even = not even
Expand Down Expand Up @@ -491,7 +493,7 @@ def animate_cycle(self, colors, groups=('LEFT', 'RIGHT'), sleeptime=0.5, duratio
def _animate_cycle():
index = 0
max_index = len(colors)
duration_ms = duration * 1000
duration_ms = duration * 1000 if duration is not None else None
stopwatch = StopWatch()
stopwatch.start()

Expand All @@ -504,7 +506,7 @@ def _animate_cycle():
if index == max_index:
index = 0

if self.animate_thread_stop or stopwatch.value_ms >= duration_ms:
if self.animate_thread_stop or stopwatch.is_elapsed_ms(duration_ms):
break

sleep(sleeptime)
Expand Down Expand Up @@ -545,7 +547,7 @@ def _animate_rainbow():
MIN_VALUE = 0
MAX_VALUE = 1
self.all_off()
duration_ms = duration * 1000
duration_ms = duration * 1000 if duration is not None else None
stopwatch = StopWatch()
stopwatch.start()

Expand Down Expand Up @@ -580,7 +582,7 @@ def _animate_rainbow():
elif state == 3 and right_value == MIN_VALUE:
state = 0

if self.animate_thread_stop or stopwatch.value_ms >= duration_ms:
if self.animate_thread_stop or stopwatch.is_elapsed_ms(duration_ms):
break

sleep(sleeptime)
Expand Down