Pi Shack BASIC is HERE!!
Fellow Shackian KenUNIX passed away in early June. SysOp remembers him.
NOTE: Colors are my choice. The default is your terminal's (B&W, W&B, ...)
Pi Shack BASIC is here!! It's a quick, fun and simple way to program the GPIO features of modern SBCs like the Raspberry Pi. It provides a classic BASIC experience with live access to hardware features, very similar to what was common with the microcomputers that became available in the 1970s and '80s. Plus it unlocks a lot of the potential of Linux I/O and interprocess communication.
The interactive experience coupled with in interpreter coding makes developing ideas, testing hardware or manipulating the hardware directly, possible in ways all other languages can't. At least all the languages that I'm aware of.
Click here to get your copy today!
Example:
' Cycle a single NeoPixel through red, green, blue, red, ...
' The NeoPixel data-in pin should get wired to SPI port #1 MOSI.
DEFINT a-z
OPEN "b",#1,"/dev/spidev1.1:2400000" : ' 2.4MHz = 800KHz*3
neo_rst$=string$(15,0) : ' 50us of GND to restart at 1st Neo.
' Start color sequence
r,g = 0 : b = 255
DO
' Cycle colors: r->g->b->r
x=b : b=g : g=r : r = x
' Assemble wire bits - repeat neo_pixel$() for all attached LEDs
neo_data$=neo_rst$+neo_pixel$(r,g,b)
' Send data to SPI port
put #1,,neo_data$
SLEEP 0.1 : ' 1/10th second between changes
LOOP UNTIL INP(1)=0 : 'GND GPIO #1 to exit (ie push button w/ pull-up)
END
' change 1 byte into its 3 byte wire format
FUNCTION neo_byte$(b%)
r$=chr$(&b10010010 OR ((b% AND 128)\2) OR ((b% AND 64)\8) OR ((b% AND 32)\32))
r$=r$+chr$(&b1001001 OR ((b% AND 16)*2) OR ((b% AND 8)\2))
r$=r$+chr$(&b100100 OR ((b% AND 4)*32) OR ((b% AND 2)*8) OR (b% AND 1)*2)
neo_byte$=r$
END FUNCTION
' Make a wire RGB triplet
FUNCTION neo_pixel$(r%,g%,b%)
neo_pixel$=neo_byte$(r%)+neo_byte$(g%)+neo_byte$(b%)
END FUNCTION
This will cycle a Neo Pixel attached to the MOSI line of SPI bus #1, through an R, G, B sequence and then back to R at full intensity, until a button attached to GPIO #1 is pushed. It demonstrates a line number free design using the newer BASIC DO
... LOOP
and FUNCTION
statements.
After the program has run and been exited you can experiment with sending data to the Neo Pixel from the command prompt like this:
psBASIC> s$ = neo_rst$+neo_pixel$(12,64,128) : put #1,,s$