Wiring

Screen

Color Reference

Color is set using \e[<c>m or \e[<c>;<c>m where "<c>" are numbers from the following tables:

Foreground
30 31 32 33 34 35 36 37
90 91 92 93 94 95 96 97
Background
40 41 42 43 44 45 46 47
100 101 102 103 104 105 106 107

Bright foreground can also be set using the "bold" attribute 1 (eg. \e[31;1m). For more details, see the ANSI code reference below.

User Input

All the user types on their keyboard is sent as-is to the UART, including ESC, ANSI sequences for arrow keys and CR-LF for Enter. The input is limited to ASCII codes 32-126, backspace 8 and tab 9.

The buttons under the screen send ASCII codes 1, 2, 3, 4, 5.

Mouse input (click/tap) is sent as \e[<y>;<x>M. You can use this for on-screen buttons, menu navigation etc.

Supported ANSI Escape Sequences

Sequences are started by ASCII code 27 (ESC, \e, \x1b, \033)

Instead of \a (BELL, ASCII 7) in the commands, you can use `\e\` (ESC + backslash). It's the Text Separator code.

Text Attributes

All text attributes are set using \e[...m where the dots are numbers separated by semicolons. You can combine up to 3 attributes in a single command.

Attribute Meaning
0 Reset text attributes to default
7 Inverse (fg/bg swap when printing)
27 Inverse OFF
30-37, 90-97 Foreground color, normal and bright
40-47, 100-107 Background color, normal and bright

Cursor

Movement commands scroll the screen if needed. The coordinates are 1-based, origin top left.

Code Params Meaning
\e[<n>A [count] Move cursor up
\e[<n>B [count] Move cursor down
\e[<n>C [count] Move cursor forward (right)
\e[<n>D [count] Move cursor backward (left)
\e[<n>E [count] Go N line down, start of line
\e[<n>F [count] Go N lines up, start of line
\e[<n>G column Go to column
\e[<y>;<x>G [row=1];[col=1] Go to row and column
\e[6n -- Query cursor position. Position is sent back as \e[?;?R with row;column.
\e[s -- Store position
\e[u -- Restore position
\e7 -- Store position & attributes
\e8 -- Restore position & attributes
\e[?25l -- Hide cursor
\e[?25h -- Show cursor
\e[?7l -- Disable cursor auto-wrap & auto-scroll at end of screen
\e[?7h -- Enable cursor auto-wrap & auto-scroll at end of screen

Screen

Code Params Meaning
\e[<m>J [mode=0] Clear screen. Mode: 0 - from cursor, 1 - to cursor, 2 - all
\e[<m>K [mode=0] Erase line. Mode: 0 - from cursor, 1 - to cursor, 2 - all
\e[<n>S [lines] Scroll screen content up, add empty line at the bottom
\e[<n>T [lines] Scroll screen content down, add empty line at the top
\e]W<r>;<c>\a rows;cols Set screen size, maximum 25x80 (resp. total 2000 characters). This also clears the screen.

System Commands

Code Params Meaning
\ec -- "Device Reset" - clear screen, reset attributes, show cursor & move it to 1,1. The screen size and WiFi settings stay unchanged.
\e]FR\a -- "Factory Reset", emergency code when you mess up the WiFi, restores SSID to unique default, clears stored credentials & enters Client+AP mode.
\e[5n -- Query device status, replies with \e[0n "device is OK". Can be used to check if the UART works.