How to go about an extension targeting both Micro:bit AND Arcade (in regards of 'screen')

I would like make an extension that can target either the led matrix on the micro:bit OR the screen on Arcade. But also to abstract the use of pxt-interval ( without having to use a different approach for when Arcade is used. Would something like #define be possible? or like in Go with explicit tags by filename _windows.go or … what I tried before, function detection, but this didn’t work. Any suggestions?

Create an extension that has a “virtual” screen interface and maybe set-interval as well. Then create 2 more specialized extensions for microbit and arcade which are specialized and implement the screen functionality.

so basically there is no way around doing two extensions that are targetting that platform directly. to avoid the trouble it would seem just doing pxt-awesome-extension-microbit and pxt-awesome-extension-arcade would anyway be needed (even with a ‘virtual’ screen).

instead, what about something that does this platform tagging inside the extension? main_arcade.ts, main_microbit.ts with some specific metadata perhaps inside the pxt.json ? since in that way the shared re-use and platfrm specifc code is contained inside the extension. would not want the user to decide and ‘pick’ what is the right version for him/her.

It gets tricky if you try to do these kind of file selection if you use the project from the CLI. TypeScript will pick up all the .ts files and get confused because there are multiple copies of the file.
Eventually, we are working on providing a common core set of primitives, including setInterval, accross all our editors but this takes time as we update them at different times.

Until then, it’s best to split them into multiple repoes.

:+1: will split for now … main extension will not work on Arcade anyway due to lack of serial. haven’t been able to get this to work.

Serial is in arcade but hidden. Add it by editing pxt.json and add to dependencies

 "serial": "*"

As per: Serial port

Serial is currently not implemented on stm32

We are not using serial-port on the device; we are using the STM cube.

? :thinking: ?

are you implying the use of a virtual COM port with ST-link? If so, that is not very useful to communicate with other hardware.

Looks like we haven’t implement the serial layer in codal-stm32, so serial won’t work for all STM-based arcade boards.

No, we would implement serial over the pins defined in the bootloader of the arcade device, e.g. micro:bit serial pins on the meowbit edge connector.

That is what I would expect, but I was therefore also right this doesn’t work now.