Led Animations do not allow for non-blocking usage
WesleyJ-128 opened this issue · 0 comments
- ev3dev version: 4.14.117-ev3dev-2.3.5-ev3
- ev3dev-lang-python version:
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii micropython-ev 2.1.0 all Python language bindings for ev3d
ii python3-ev3dev 1.2.0 all Python language bindings for ev3d
ii python3-ev3dev 2.1.0 all Python language bindings for ev3d
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.