Spacekrant
From HSG Wiki
a network connected 24x6 led display running various display routines.
joris made fancy hardware and firmware, sasja rewrote the firmware and connected it to the network. talk to them to learn the details.
Contents
how to talk to it: some bash examples[edit]
Note: in the examples below, '\x1b' is the ESC character, you can also use '\e'. On a Mac, replace '\' with '\\'.
# put foo on the scroller printf "\x1bffoo" | nc barmaid 1337 # ESC-f foo # put bar on the scroller # with higher scrolling speed printf "\x1bf\x1b\x1bdbar" | nc barmaid 1337 # ESC-f to start scroller, 'ESC-ESC-d' to set speed # put the whitespace logo on it printf "\x1bh" | nc barmaid 1337 # ESC-h # and of course: game of life # initialized with a lightweight spaceship printf "\x1bgl" | nc barmaid 1337 # ESC-g l # realtime interactive mode # only one connection at a time # has a 10 sec inactivity timeout stty -icanon && nc barmaid 1337 # disable tty buffering, then open tcp connection # turn it into a clock (as long as your machine stays on the lan) nohup bash -c 'while true; do print "\x1bj$(date +%H:%M)" | nc barmaid 1337; sleep 60; done;' >/dev/null 2>&1 & # it gets better: this is a scrolling clock that shows and updates every second, isnt bash just great! nohup bash -c 'printf "\ef\e\eg" | nc barmaid 1337; while true; do sleep 1; { printf "\x7f%.0s" {1..8}; printf "$(date +%H:%M:%S)"; } | nc barmaid 1337; done;' >/dev/null 2>&1 &
routines running on it[edit]
when sending the two bytes eg. ESC+'a' over serial you trigger the program 'a'. The current programs are:
a | do nothing |
b | all on |
c | all off |
d | 144 bit binary clock (lame) |
e | wat (lame) |
f | text scroller |
g | game of life |
h | whitespace logo |
i | bits to leds |
j | static text |
text scroller[edit]
- ESC-f to start/refresh text
- ESC-ESC-a to ESC-ESC-z to set speed (a is fastest, z slowest)
- all other data is treated as text, backspace/delete are also supported
conway[edit]
- ESC-g to start, using the current led pattern
- ESC-ESC-a to ESC-ESC-z to set speed (a is fastest, z slowest)
- any other character is put in the middle of the display to seed the pattern
- q,w,a,s are replaced with gliders in all directions, l is a lightweight spaceship moving right
bits to leds[edit]
- ESC-i to start & clear pattern
- any byte sent to it will set the 8 next leds according to the bits, wrapping around at the end
- one exception! sending 0b00011011 aka 0x1b aka \e aka ESC to the leds is done by sending ESC-ESC (escape is escaped with escape)
how does it work[edit]
- you or your script connects to some port of some machine in the network and give it some input
- the service forwards to the spacekrant over serial over usb
- the device firmware separates commands from data
- commands are used to select the routine (everything escaped with ESC, except ESC ESC)
- data is forwarded to the current running routine, and it does whatever is right with it
- every 6 ms (right after the 6th line is drawn), the current routine directly accesses a buffer in mem that is mapped to the 24x6 leds do to whatever with it
- a 1ms periodic timer interrupt handler in the firmware checks that buffer and draws the next line, on and on
- a counter ic that selects the active row of leds is incremented
- three bytes are pushed into three daisychained shiftregisters each controlling 8 columns of leds
- unfortunate electrons are being shoved into hole-dominated territory => photons all over the place.
a challenge awaits you[edit]
the first person to give me a bash command that will put 6 simultaneously living gliders on the display wins a crate of mate! put your solution below and claim your prize.
- Solved by Bloemist Thuesday 10th of May (22:12:16)
printf "\x1bc\x1bi" | nc barmaid 1337; sleep 1; echo -ne '\x4\x4\x4\x2\x2\x2\xE\xE\xE' | nc barmaid 1337; sleep 1; echo -ne '\x40\x40\x40\x20\x20\x20\xE0\xE0\xE0' | nc barmaid 1337 ; sleep 2; printf "\x1bg" | nc barmaid 1337
wheres the hardware design[edit]
http://www.van-looveren.net/joris/?q=node/26
wheres the code[edit]
https://gitlab.com/sasja/spacekrant2
todo[edit]
- when sending +100 chars at once some buffer gets full and drops data, workaround: send your text slower