The Hackaday BASIC interpreter is based on the uBASIC project by Adam Dunkels. This provided a tokenizer and the most rudimentary words needed for the language to operate. From there, Jaromir Sukuba greatly expanded the word set to take advantage of the best the badge hardware has to offer.
The reference for all of the words is listed below. You may also see examples of these words in use by viewing the example code project log.
- Code in the program buffer can be viewed one page at a time by typing
more. You can overwrite lines just by typing the line number at the prompt along with your new commands. It is recommended that you number every 10 lines or more so that you can add commands in between them as you develop your code.
memclrword will clear the code currently in the program buffer.
- There are two print commands.
printlnwill include a line feed
BASIC Word List:
Badge Custom Words
led X,Y- control LED, X[0..2] RGB, Y[0..1] on/off
tune A,B,C,D- plays tones A, B, C for duration D
clrscr- clear screen
setxy X,Y- set cursor at X,Y
wait X- wait for X ms
color X,Y- X=Foreground, Y=Background using EGA 16-color palette
chr X- prints character with ASCII representation X
termt X- sets VT100 terminal on or off (1-on, 0-off)
termup- forces screen refresh, if VT100 terminal is off
rnd X- function to return random number 0..X
ein X- function to return value of expansion pin X
eout X,Y- control expansion pin, X[0..3], Y[0..1] on/off
edr X,Y- sets expansion pin function X[0..3], Y[0..1] output/input
uin X- function to return received byte from serial port, if X=0, function is non-blocking, if X=1, function is blocking
uout X- outputs value X to serial port as single byte
input "string"- prints string and returns user entered value
peek X- returns value from memory location X
poke X,Y- write value Y into memory, on location X
cursor X- turns cursor on (X=1) or off (X=0)
kin X- function to return byte from keyboard, if X=0, function is non-blocking, if X=1, function is blocking
BASIC CLI commands
run- runs program
save X- Save program buffer to flash. There are 16 slots: X[0..15]
load X- Load program into buffer from flash. There are 16 slots: X[0..15]
list- list whole program
more- list program by pages
memclr- clears all code from the program buffer
free- prints amount of free program buffer
sload- load new program into buffer from serial port
ssave- output program buffer via serial port
help- short help
In order to save you some typing, we defined some aliases for functions