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