microsoft / pxt-arcade

Arcade game editor based on Microsoft MakeCode
https://arcade.makecode.com
MIT License
473 stars 200 forks source link

edge connector blocks freeze code #3699

Open PhilAtKitronik opened 2 years ago

PhilAtKitronik commented 2 years ago

Describe the bug edge connection extension blocks freezes code

To Reproduce import the edge connection blocks in to arcade for using the pins from BBC micro:bit The test code I was using was as follows

controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
    pins.P2.digitalWrite(true)
    pause(500)
    pins.P2.digitalWrite(false)
    pause(500)
})
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
    music.baDing.play()
})
let mySprite = sprites.create(img`
    . . . . . . . . . . b 5 b . . . 
    . . . . . . . . . b 5 b . . . . 
    . . . . . . b b b b b b . . . . 
    . . . . . b b 5 5 5 5 5 b . . . 
    . . . . b b 5 d 1 f 5 5 d f . . 
    . . . . b 5 5 1 f f 5 d 4 c . . 
    . . . . b 5 5 d f b d d 4 4 . . 
    . b b b d 5 5 5 5 5 4 4 4 4 4 b 
    b d d d b b d 5 5 4 4 4 4 4 b . 
    b b d 5 5 5 b 5 5 5 5 5 5 b . . 
    c d c 5 5 5 5 d 5 5 5 5 5 5 b . 
    c b d c d 5 5 b 5 5 5 5 5 5 b . 
    . c d d c c b d 5 5 5 5 5 d b . 
    . . c b d d d d d 5 5 5 b b . . 
    . . . c c c c c c c c b b . . . 
    . . . . . . . . . . . . . . . . 
    `, SpriteKind.Player)
forever(function () {
    controller.moveSprite(mySprite, 100, 100)
})

The sprite moves around, buzzer beeps when button A is pressed. on pin2 we have a small motor controlled via a FET. I expected the pin to go high wait and go low, to turn the motor on and off after 500 milliseconds. Once I press button B the code locks up and can not control the sprite or sound the buzzer.

I'm using the digital write high and low blocks as could not find the default pin for the vibrate block with regards to using the micro:bit hardware

abchatra commented 2 years ago

Code works on simulator. Issue is on hardware.

This requires edge-connector extension.

PhilAtKitronik commented 2 years ago

The hardware design is taken from Microsoft Arcade shield reference design for the BBC micro:bit V2. I have just tried to use the button for anything else like change the colour of the background the buttons work fine which suggests the hardware is fine. it's only the edge connection blocks that affect it.

abchatra commented 2 years ago

Sorry I didn't mean bug was in the hardware. This bug is reproduced on the hardware.

PhilAtKitronik commented 2 years ago

any progress on this issue?

dsssssssss9 commented 1 year ago

@abchatra @pelikhan

Any News on this please ?

I have projects done in "Standard" MakeCode that i should like to enhance using MakeCode Arcade but Edge Connector Extension still exhibits the code locking problem

JakeAtKitronik commented 3 months ago

We are still encountering this issue with N3 based Arcades (Micro:bit based arcades). With the edge connector extension added to a project, and a block added to assign a pin high or low, although the resulting program will compile - the resulting program will lock up the arcade, with the screen remaining blank.

When the block to interface with the IO pin is added, there is a very brief error message within the Makecode Arcade interface:

IO Error in MakeCode Arcade

This would suggest that the Makecode Arcade backend has not been configured correctly to interact with the edge connector on N3 processors, despite being physically present on the reference design: https://github.com/microsoft/pxt-arcade-hardware-designs/blob/master/microbit-shield/MicroBitArcadeShieldMVD%2008-1.1.PDF

As this ticket has been made back in 2021, I feel reluctant to believe that any action may be taken on this issue any time soon.

This an issue that has been spotted with both the official N3 processor option selected, as well as the experimental RP2040 support.

tballmsft commented 3 months ago

I believe this is because https://github.com/microsoft/pxt-arcade/blob/f05a119cd973e0282ef77053721cc380d47c5b25/libs/hw---n3/config.ts doesn't supply the needed pin mapping for the edge connector. I will investigate further.

tballmsft commented 3 months ago

here is program from top with config for N3 that edge connector extension needs ... will test when I get HW: https://makecode.com/_CuhapH58Vdbe

you need to select a micro:bit shield in order for this program to compile

JakeAtKitronik commented 3 months ago

Brilliant! This works perfectly! Thank you so much for looking into the issue :)

tballmsft commented 3 months ago

Did it also resolve the problem you were seeing?

JakeAtKitronik commented 3 months ago

Yep, adding the definitions into our test script works as well

JakeAtKitronik commented 3 months ago

Also tweaking the provided code works for the RP2040 as well.

tballmsft commented 3 months ago

OK. The fix I put it in is only for the N3. I can add for RP2040 as well. It will only be for the three big pins P0, P1, and P2

tballmsft commented 3 months ago

actually, the mapping for RP2040 is in the bootloader. Can you change the mapping? @mmoskal ?

mmoskal commented 3 months ago

the bootloader is provided by console manufacturer (they ship a special "game" that has all the mappings in it)

tballmsft commented 3 months ago

sorry, how does the mapping get incorporated then?

mmoskal commented 3 months ago

see here https://arcade.makecode.com/hardware/adding#r2

Manufacturer is supposed to provide a "recovery UF2" (which may contain a game) that has all the bootloader settings. That file can be created by using the sample UF2 linked from the page above, editing it using https://microsoft.github.io/uf2/patcher/ and concatenating it with game binary.

JakeAtKitronik commented 3 months ago

Aha! I didn't realise for the RP2040 you just needed to add it to the bootloader, I must of missed that. Glad to know you just need to concatenate the demo game and the bootloader together as well!

mmoskal commented 3 months ago

Just to note, to concatenate you will need to update the block numbers, not just "cat" the files together.

This PR may be useful https://github.com/microsoft/uf2/pull/81