Log In  

Does Pico-8 support serial? I am mainly interested in reading serial data, writing would be great as well though.

I'm planning a workshop to make strange interfaces, mainly input. I'm working on Unity, Unreal and openFrameworks examples at the moment and it would be great to support Pico-8 as well.

Is this possible?

Only alternative I could think of was to have a simple program running on the same platform that actually read the serial data and then changed some memory address that Pico-8 could read. That is a lot more work though, and requires different programs per platform. Direct serial support in Pico-8 would be much easier and better.

Any thoughts appreciated.
Thanks

P#50467 2018-03-16 02:15 ( Edited 2018-03-18 20:19)

Pico-8 provides access to eight "GPIO pins," which means one of two things depending on platform:

1) In the web player, a set of addressable memory bytes is sync'd to a JavaScript array in the host webpage. You can make custom inputs from the JS context like sending signals to the game from the rest of the page UI or other things the browser can sense. Or you can make custom outputs to the JS context, controlling other display elements (or other things) from the cart.

2) When running on a Raspberry Pi or PocketCHIP, the GPIO pins map to actual hardware pins, for both input and output. Build actual custom hardware controls, or send signals to other circuits. Here's a test I did a while back sending data to an Arduino, which in turn controlled a NeoPixel strip: https://twitter.com/dan_sanderson/status/906642108613746688

There's no built-in serial protocol. One challenge to building one directly in cart code is the data rate: Pico-8 can only read or write new values once per frame, so you max out at 64 eight-bit bytes per second. I had intended but never got around to writing a simple slow parallel protocol for the RaspPi+Arduino set-up, allowing the Arduino to translate between a set of commands and other devices in a general way (such as via a more standard serial protocol).

http://pico-8.wikia.com/wiki/Gpio

P#50501 2018-03-17 00:14 ( Edited 2018-03-17 04:14)

@dddaaannn

The info on the wiki is either incorrect or out of date. The manual says:

0x5f80 gpio pins (128 bytes)

Maybe only the first 8 are useful on SOC boards, but I think it's just an error. I know someone at some point used all 128 for a networking stack with the external JS.

P#50520 2018-03-17 11:16 ( Edited 2018-03-17 15:17)

Yup, my recollection is all of the bytes are available to the JS array, and only the first 8 (or so?) work as actual GPIO pins on a RaspPi/PocketCHIP. Also the actual GPIO pins are only digital (0/255), not analog, so you only get 8 real bits.

If the wiki is misleading feel free to tweak it.

P#50537 2018-03-17 16:06 ( Edited 2018-03-17 20:06)

Good to know.

I clarified both use cases on the wiki.

P#50541 2018-03-17 18:53 ( Edited 2018-03-17 22:53)

Thanks for the info @dddaaannn. Your Neopixel demo is very nice. We started using arduino/serial as a buffer between various sensors and different hardware to avoid using GPIO. The idea being that we could use serial over usb on all platforms, that support serial, without changes. So writing GPIO code just for Pico8 on the pi isn't an option at the moment. We might as well just use GPIO directly, but that was what we were trying to avoid.

I will keep my fingers crossed for serial support in Pico8 at some point in the future :)

Thanks again
Dan

P#50569 2018-03-18 16:19 ( Edited 2018-03-18 20:19)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-19 21:25:18 | 0.009s | Q:15