0

Trying to use the "On event from" functionality to get finer control over input from button presses. When I convert this blocks code to python in the makecode editor, I get the following code:

Blocks code

def on_microbit_id_button_a_evt_click():
    basic.show_leds("""
        . . . . .
                . . . . .
                . . # . .
                . . . . .
                . . . . .
    """)
control.on_event(EventBusSource.MICROBIT_ID_BUTTON_A,
    EventBusValue.MICROBIT_BUTTON_EVT_CLICK,
    on_microbit_id_button_a_evt_click)

What I don't understand is how to get this control library in the python.microbit.org editor, as there doesn't seem to be any import statement in the converted code, and the from microbit import * doesn't seem to include it.

Sorry if this is a stupid question and thanks in advance!

lriley
  • 11
  • 3
  • The Python used in https://makecode.microbit.org/ is different from the Python in https://python.microbit.org/. I think this explains some of the differences https://microbit.org/get-started/user-guide/python/ in the "Buttons" section – ukBaz Nov 04 '22 at 13:08
  • Ah right, thanks - didn't know about that! So is there a way to get this event functionality in the non-makecode editor? – lriley Nov 04 '22 at 15:52
  • There's some more information on why events are missing from the BBC micro:bit micropython implementation here: https://stackoverflow.com/a/46049756/7222588 – Oppy Nov 06 '22 at 17:07

0 Answers0