Ferrite

Developers

The terminal's pages

The small stack language the cable terminal's full-screen pages are written in.

The cable terminal's full-screen pages are a program in a small stack language, compiled into an SPI part and run by an interpreter in the firmware (manual TERM-47). What follows is the language's own description, from the program's source.

The terminal's full-screen pages (TERM-11 to TERM-20, TERM-47; decision 346): a small stack language that build.rs compiles into the template pack, the program term::tpl runs from the SPI part. Everything a page shows and does is here: the text, layout, list rows, hints, help, what each key does, the channel list's tools. The firmware keeps the interpreter and the natives listed below (a value, a channel's field, a setting by its menu number, the radio's formatters, a write through the App). The byte format is described in term/tpl.rs.

Words run left to right on a stack of 32-bit numbers. A string "..." prints itself (\" \ \n \xNN; columns counted, clipped at the row's width); raw "..." sends an escape sequence; bold "..." prints in bold; pick "a|b|c" prints piece i (i on the stack). @x pushes variable x, !x stores into it: vars keep their values (16 bits: a zone is -3 for every channel, -1 for none), locals last one run. : name ... ; defines a word (in the lib before the first page, else in that page; ( ... ) is a comment). if ... else ... then, begin ... while ... repeat, begin ... until, exit. Numbers (16-bit literals): 12, -1, 0x1F, 'c'; const names one. . prints a number, .r / .z (n width) padded with spaces / zeros; at (col) moves right with spaces. \ alone starts a comment; a line starting with # is one.

A page: hints "Key=What|...", help "line\nline", rules for its body rows (body row 0 is the line under the top line; the first rule that takes a row draws it, run with @i the row in a list):

row N CODE         that row
bot K CODE         K rows above the hints line's row (body - K, body = rows - 2)
list N COUNT CODE  rows N.. for COUNT's count
tail K CODE        K rows after the last list's end
pre CODE           runs before the rules (exit: a blank row)

and its keys: key KEY CODE (KEY up down left right pgup pgdn home end enter esc line lesc digit, or "c"; letters come lower case; a digit's CODE gets the key on the stack), key pre CODE first (the key on the stack), key else CODE for any other. : prep ... ; runs before each redraw, : poll ... ; each poll while @busy isn't 0. A page is read from the SPI flash with the lib, through a small window each (tpl::Code); a key or a poll that sets !chain to another page runs that page's key or poll next (the channel list's tools are one). The pages' order is term::Page's (a page only chained to comes after them).

Natives

What the firmware gives the program, by how many numbers each takes from the stack and gives back.

Takes Gives Natives
0 1 rows cols colour bt pin pinn cmdon bnote warn noteon typing lnum hascall ssb txbuilt clock battmv gps gpsph gpss btdev bsave count zones cedit radioch homech nmarks active nev
0 0 cmdtail cmdopen note noteclr cap lname lstop line lfind find version callsign region cal eset eclr eload cmode ctone cput unmark
1 0 say lstart zname mhz freq3 citem cdel cren ftext flabel cname gname gdesc slotmode slottone rssi
1 1 capcmp evago zlen cget cf newch mark nextmark prevmark markbelow slotch aprs slotf slotoff sq scanning livef
2 0 cset markset ev
2 1 cat room isub nitems
3 0 iname ihelp ival
3 1 fchg sreset
4 1 seek schg
0 1 lmhz
0 0 scan
1 1 nlist gpsl devv
2 1 quick aprsdo
3 1 sapply litem

Made from ferrite/crates/ferrite-app/src/term/pages.vt by docs/tools/mkdev.py.