<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://pico8wiki.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=76.244.21.84</id>
	<title>Pico-8 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://pico8wiki.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=76.244.21.84"/>
	<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Special:Contributions/76.244.21.84"/>
	<updated>2026-11-24T02:49:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>http://pico8wiki.com/index.php?title=Serial&amp;diff=12090</id>
		<title>Serial</title>
		<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Serial&amp;diff=12090"/>
		<updated>2021-11-28T17:31:31Z</updated>

		<summary type="html">&lt;p&gt;76.244.21.84: added the page, bascially copy paste from the manual. feel free to format it better&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;For more precise timing, the SERIAL() command can be used. GPIO writes are buffered and dispatched at the end of each frame, allowing clock cycling at higher and/or more regular speeds than is possible by manually bit-banging using POKE() calls.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SERIAL(CHANNEL, ADDRESS, LENGTH)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
CHANNEL:&lt;br /&gt;
&lt;br /&gt;
  0x000..0x0fe    corresponds to gpio pin numbers; send 0x00 for LOW or 0xFF for HIGH&lt;br /&gt;
&lt;br /&gt;
  0x0ff           delay; length is taken to mean &amp;quot;duration&amp;quot; in microseconds (excl. overhead)&lt;br /&gt;
&lt;br /&gt;
  0x400..0x401    ws281x LED string (experimental)&lt;br /&gt;
&lt;br /&gt;
ADDRESS: The PICO-8 memory location to read from / write to.&lt;br /&gt;
&lt;br /&gt;
LENGTH: Number of bytes to send. 1/8ths are allowed to send partial bit strings.&lt;br /&gt;
&lt;br /&gt;
For example, to send a byte one bit at a time to a typical APA102 LED string:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;VAL = 42          -- VALUE TO SEND&lt;br /&gt;
&lt;br /&gt;
DAT = 16 CLK = 15 -- DATA AND CLOCK PINS DEPEND ON DEVICE&lt;br /&gt;
&lt;br /&gt;
POKE(0X4300,0)    -- DATA TO SEND (SINGLE BYTES: 0 OR 0XFF)&lt;br /&gt;
&lt;br /&gt;
POKE(0X4301,0XFF)&lt;br /&gt;
&lt;br /&gt;
FOR B=0,7 DO&lt;br /&gt;
&lt;br /&gt;
  -- SEND THE BIT (HIGH FIRST)&lt;br /&gt;
&lt;br /&gt;
  SERIAL(DAT, BAND(VAL, SHL(1,7-B))&amp;gt;0 AND 0X4301 OR 0X4300, 1)&lt;br /&gt;
&lt;br /&gt;
  -- CYCLE THE CLOCK&lt;br /&gt;
&lt;br /&gt;
  SERIAL(CLK, 0X4301)&lt;br /&gt;
&lt;br /&gt;
  SERIAL(0XFF, 5) -- DELAY 5&lt;br /&gt;
&lt;br /&gt;
  SERIAL(CLK, 0X4300)&lt;br /&gt;
&lt;br /&gt;
  SERIAL(0XFF, 5) -- DELAY 5&lt;br /&gt;
&lt;br /&gt;
END&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional channels are available for bytestreams to and from the host operating system. These are intended to be most useful for UNIX-like environments while developing toolchains, and are not available while running a BBS or exported cart [1]. Maximum transfer rate in all cases is 64k/sec (blocks cpu).&lt;br /&gt;
&lt;br /&gt;
0x800  dropped file   //  stat(120) returns TRUE when data is available&lt;br /&gt;
&lt;br /&gt;
0x802  dropped image  //  stat(121) returns TRUE when data is available&lt;br /&gt;
&lt;br /&gt;
0x804  stdin&lt;br /&gt;
&lt;br /&gt;
0x805  stdout&lt;br /&gt;
&lt;br /&gt;
0x806  file specified with: pico8 -i filename&lt;br /&gt;
&lt;br /&gt;
0x807  file specified with: pico8 -o filename&lt;br /&gt;
&lt;br /&gt;
Image files dropped into PICO-8 show up on channel 0x802 as a bytestream with a special format: The first 4 bytes are the image&#039;s width and height (2 bytes each little-endian, like PEEK2), followed by the image in reading order, one byte per pixel, colour-fitted to the display palette at the time the file was dropped.&lt;br /&gt;
&lt;br /&gt;
[1] Channels 0x800 and 0x802 are available from exported binaries, but with a maximum file size of 256k, or 128x128 for images.&lt;/div&gt;</summary>
		<author><name>76.244.21.84</name></author>
	</entry>
</feed>