microsoft / devicescript

TypeScript for Tiny IoT Devices (ESP32, RP2040, ...)
https://microsoft.github.io/devicescript/
MIT License
3.28k stars 118 forks source link

How to get on-board led pin information? #410

Closed wh1tecat-nya closed 1 year ago

wh1tecat-nya commented 1 year ago

I found a definition of led pin information in boards.json. https://github.com/microsoft/devicescript/blob/9f8380259428f0f6290c9f7379bdfe3e06250418/compiler/src/boards.json#L695-L697

But it is not included @dsboard/{boardname}(devicescript-boards.d.ts). How to use on-board led or led pin assignment?

pedropalhari commented 1 year ago

Having the same issue, trying to instantiate it directly with gpio(25) also fails. Seems to be in use by something else (like gpio(0)) but couldn't figure it out why yet.

pelikhan commented 1 year ago

For the onboard LED, you would need to use setStatusLight --> https://microsoft.github.io/devicescript/developer/status-light . The onboard LED is also used to notify the status of the network stack and is "shared" with the runtime.

Keep this issue opened to beef up the docs.

pedropalhari commented 1 year ago

Hi, @pelikhan, thanks for the follow up!

Weirdly, I did encounter that section of the docs (and tried it). And on the RPi 2040 at least it's not (currently) working. It compiles and runs with no issue but nothing happens on the board. I tested on 2 different RPis I have here.

I was able to simulate a "hello world" with an external led though and didn't explore it much more (was just doing a quick getting started to check the framework) so I can't provide additional info now. But I can come back to it during the weekend and see if I'm able to pinpoint exactly what's happening.

pelikhan commented 1 year ago

Fixed by https://github.com/microsoft/devicescript/commit/ecb7c7be5ab9c882e6194880e63d4ba60932fd06