bbcmicrobit / micropython

Port of MicroPython for the BBC micro:bit
https://microbit-micropython.readthedocs.io
Other
602 stars 284 forks source link

display.clear() does not stop looping animations #789

Closed davidtkaye closed 1 year ago

davidtkaye commented 1 year ago

If a display.show or display.scroll function is called with the loop parameter set to True and the wait parameter set to False then an infinite loop of text/animation is shown on the display. Any subsequent show or scroll function call will break this loop, however the display.clear function will not do this. Therefore to stop an animation and clear the screen two function calls are needed (or a custom image of all 0s).

This workaround is fine but not totally intuitive: the behaviour of the display.clear function should ideally stop any running animation, or if not there should be a straightforward option to do this.

microbit-carlos commented 1 year ago

Thanks for the report @davidtkaye!

I tried this programme with a BBC micro:bit V1 and V2 and I think the issue is actually only in V2. Which version of the board did you use?

from microbit import *

display.show("hello", loop=True, wait=False)
while True:
    sleep(100)
    if button_a.is_pressed():
        display.clear()
    if button_b.is_pressed():
        display.show("X")
davidtkaye commented 1 year ago

Yep, sorry. Should have been in the v2 repository!

microbit-carlos commented 1 year ago

Thanks for confirming and for the report! I'll close this one in favour of https://github.com/microbit-foundation/micropython-microbit-v2/issues/150 👍