]> git.donarmstrong.com Git - kiibohd-controller.git/blob - Scan/STLcd/exampleAPI.bash
Start removing select Linux-isms
[kiibohd-controller.git] / Scan / STLcd / exampleAPI.bash
1 #!/usr/bin/env bash
2 # STLcd
3 # Virtual Serial Port API Example
4 # Jacob Alexander 2015
5
6 # XXX Set this to match your virtual serialport
7 # TODO Show examples for Mac OSX and Cygwin/Windows
8 SERIALPORT=/dev/ttyACM0
9
10 # NOTE: Make sure you don't write too quickly to the serial port, it can get overwhelmed by a modern computer
11 #       Generally this just means commands will get ignored
12 #       I'm using 100 ms sleeps here, but much smaller are probably sufficient
13
14 # Clear out cli buffer
15 printf "\r" > $SERIALPORT
16
17 # Change backlight color
18 # 3 16-bit numbers (hex or decimal) Red, Green and Blue
19 sleep 0.1
20 printf "lcdColor 0x100 0x2000 0x4000\r" > $SERIALPORT # Light blue
21
22 # Change the lcd image
23 # Arguments:
24 #  - page
25 #  - starting address
26 #  - pixels (1 bit per pixel)
27 #
28 # There are 9 total pages of display memory, but only 4 are visable at time (it is possible to scroll though)
29 # Each page is 128 bits wide (16 bytes)
30 # See the datasheet for full details http://www.newhavendisplay.com/specs/NHD-C12832A1Z-FSRGB-FBW-3V.pdf
31 sleep 0.1
32 printf "lcdDisp 0x0 0x0  0xFF 0x13 0xFF 0x11 0xFF\r" > $SERIALPORT
33 sleep 0.1
34 printf "lcdDisp 0x1 0x10 0xFF 0x13 0xFF 0x11 0xFF 0x44\r" > $SERIALPORT
35 sleep 0.1
36 printf "lcdDisp 0x2 0x20 0xFF 0x13 0xFF 0x11 0xFF\r" > $SERIALPORT
37 sleep 0.1
38 printf "lcdDisp 0x3 0x30 0xFF 0x13 0xFF 0x11 0xFF\r" > $SERIALPORT
39
40 # Send command directly to the lcd
41 # See the datasheet for full details http://www.newhavendisplay.com/specs/NHD-C12832A1Z-FSRGB-FBW-3V.pdf
42 sleep 0.1
43 printf "lcdCmd 0xA7\r" > $SERIALPORT # Reverse display (0xA6 is Normal)
44