microbit-foundation / micropython-microbit-v2

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream
MIT License
41 stars 22 forks source link

`display.clear()` does not stop `display.show(loop=True, wait=False)` #150

Closed microbit-carlos closed 1 year ago

microbit-carlos commented 1 year ago

Reported in the V1 repository, but I think it's actually a V2 only issue:

With this programme pressing button A should stop the animation looping forever by using display.clear(), but it only clears the current image displayed and the next animation steps continue.

Pressing B replaces the animation by just displaying a letter and at that point display.clear() works as expected.

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")

In V1 display.clear() does stop the animation.

davidtkaye commented 1 year ago

Can confirm this is a problem on my V2 microbit, also coincidentally shows up on the microbit simulator in the online Python editor (where I first identified it).

dpgeorge commented 1 year ago

Thanks for the report. Should be fixed by a5dd649283ad6c232e5f924af3b24242f58e3bbc

dpgeorge commented 1 year ago

@microbit-matt-hillsdon for the simulator you can now remove microbit_hal_display_clear(), per 5177bdc96df45266f344b2813f2f4d94891c7928