microbit-foundation / micropython-microbit-v2

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

`microbit.panic()` display animation flickers compared to CODAL #116

Open microbit-carlos opened 2 years ago

microbit-carlos commented 2 years ago

Running microbit.panic(123) on MicroPython and comparing it to a CODAL programme with microbit.panic(123), and the MicroPython version noticeably flickers.

Looks like MicroPython just calls microbit.panic() directly: https://github.com/microbit-foundation/micropython-microbit-v2/blob/8970afbd19ebfafa68e908e05d0f3db410ab362f/src/codal_app/microbithal.cpp#L101-L103

The CODAL code disables interrupts and directly drives the display GPIO, but is it possible something from the MicroPython side could be running and affecting the timings?

Running the MicroPython and CODAL versions side by side and it also looks like maybe the CODAL version runs slightly quicker?

I wasn't able to capture flickering on video due to the capturing frame rate of my phone camera, but using the "super slowmo" mode, it can be seen that the CODAL programme on the right updates the rows a bit quicker compared with MicroPython on the left:

https://user-images.githubusercontent.com/29712657/187722566-92dd2529-ba82-415e-a156-6940b6e5cfa7.mp4

(Side Note: After 5 iterations the display goes dimmer, but that's by design)

dpgeorge commented 2 years ago

I do also see the flickering panic animation.

Putting a microbit_panic(123) at the very start of main() in src/codal_app/main.cpp, before any of the MicroPython initialisation runs, it still flickers. So I don't know what is wrong, maybe the .json config for MicroPython is doing something strange here?