ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
422 stars 146 forks source link

Led Animations do not allow for non-blocking usage #753

Open WesleyJ-128 opened 4 years ago

WesleyJ-128 commented 4 years ago

I was trying to use the leds on the EV3 as status indicators for certain points in the driving programs that I am writing. As I am not familiar with how to use the led functions in ev3dev, I created a simple test program:

from ev3dev2.led import Leds
from time import sleep
lights = Leds()
lights.all_off()
lights.animate_police_lights('YELLOW', 'GREEN', duration=None, block=False)
print("test")
sleep(10)
print("test1")
lights.reset()
print("test2")
sleep(5)

I expected this to turn the leds off and immediately start the police light animation, print test, let the animation run for ten seconds, print test1, set both lights to green, print test2, then wait five seconds before completion. However, when I run this program, the leds turn off after some amount of startup time, test is printed, then after 10 seconds, test1 is printed, and the lights stay off and the program never progresses farther, without throwing any error messages. If I set duration= to 5, I get the exact same behavior. If I also change block= to True, the animation is played for 5 seconds, test is printed, and after 10 seconds, the program continues as expected.

I have also tried this program with other animation types, and I get identical behavior.

The print statements were added as progress markers after I found the program was acting strangely.