microsoft / microcode

Coding "on the go" with the micro:bit (V2)
https://microsoft.github.io/microcode
MIT License
47 stars 18 forks source link

button mapping is buggy #374

Closed tballmsft closed 1 year ago

tballmsft commented 1 year ago

I find that when a kittenbot button is attached and the micro:bit reset that the mapping of buttons on the micro:bit to integer ranges gets messed up. The micro:bit (fixed) buttons (A,B,logo,pins0,1,2) don't always get mapped to 0..5 when a button module is already attached to the Jacdac bus on reset. Instead, I find that the button module might have a value 0 (rather than 6), and so act as the A button.

Note that the problem doesn't occur if we start with nothing connected to the Jacdac bus and then add the module. The problem only occurs when the button is connected to the micro:bit and it is reset.

tballmsft commented 1 year ago

i see

void app_init_services() {
    jd_role_manager_init();
    init_jacscript_manager();
    init_local_services();

    // tsagg_init(&noop_cloud);
}

so if external buttons are already connected, perhaps this explains things. we need to give priority to the built-in buttons.

It's not clear to me how to do this, given that app_init_services is called from inside jacdac-c.

mmoskal commented 1 year ago

Generally, the program should only start 1.5s after boot, see https://github.com/microsoft/jacdac-c/blob/codal-jacdac/jacscript/jacscriptmgr.c#L365 - this should be enough time for devices to enumerate. I'll try to locate my micro:bit and look at this tomorrow.

pelikhan commented 1 year ago

Can we get some screen animation during those 1.5s of restart time?

tballmsft commented 1 year ago

To be clear, the problem I am seeing is that when external buttons are plugged in, they seem to get the roles that are usually allocated to the built-in buttons, yielding bad user experience.

mmoskal commented 1 year ago

Can't repro. My testcase

tballmsft commented 1 year ago

Hmm... yeah, I can't repro anymore either.