Mercurial > louis > kiibohd-controller
annotate Scan/ISSILed/exampleAPI.bash @ 398:63b1d003fd50
Stop requiring editing of example scripts
The example scripts include hardcoded values that
do not work for everyone. Instead of requiring the
files to be edited (and dirtying the git tree),
allow them to take command-line arguments.
Also adds better guidance for Mac OSX virtual
serial ports.
author | Joshua Flanagan <joshuaflanagan@gmail.com> |
---|---|
date | Tue, 10 Nov 2015 10:32:06 -0600 |
parents | 3e5a95c196f8 |
children | 88814d3c0c8b |
rev | line source |
---|---|
375 | 1 #!/bin/bash |
2 # ISSILed | |
3 # Virtual Serial Port API Example | |
4 # Jacob Alexander 2015 | |
5 | |
398
63b1d003fd50
Stop requiring editing of example scripts
Joshua Flanagan <joshuaflanagan@gmail.com>
parents:
375
diff
changeset
|
6 if [ $# -eq 0 ]; then |
63b1d003fd50
Stop requiring editing of example scripts
Joshua Flanagan <joshuaflanagan@gmail.com>
parents:
375
diff
changeset
|
7 echo "You must specify your virtual serialport. (/dev/ttyACM0 on linux, /dev/cu.usbmodemXXXX on OSX)" |
63b1d003fd50
Stop requiring editing of example scripts
Joshua Flanagan <joshuaflanagan@gmail.com>
parents:
375
diff
changeset
|
8 echo " ex: $0 /dev/ttyACM0" |
63b1d003fd50
Stop requiring editing of example scripts
Joshua Flanagan <joshuaflanagan@gmail.com>
parents:
375
diff
changeset
|
9 exit 1 |
63b1d003fd50
Stop requiring editing of example scripts
Joshua Flanagan <joshuaflanagan@gmail.com>
parents:
375
diff
changeset
|
10 fi |
375 | 11 # XXX Set this to match your virtual serialport |
398
63b1d003fd50
Stop requiring editing of example scripts
Joshua Flanagan <joshuaflanagan@gmail.com>
parents:
375
diff
changeset
|
12 # TODO Show examples for Cygwin/Windows |
63b1d003fd50
Stop requiring editing of example scripts
Joshua Flanagan <joshuaflanagan@gmail.com>
parents:
375
diff
changeset
|
13 # For Mac OSX it will be something like /dev/cu.usbmodem1413 (number may differ) |
63b1d003fd50
Stop requiring editing of example scripts
Joshua Flanagan <joshuaflanagan@gmail.com>
parents:
375
diff
changeset
|
14 SERIALPORT=$1 |
375 | 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 # Write to ISSI Page | |
24 # Arguments | |
25 # - page | |
26 # - starting address | |
27 # - data (usually brightness) (8 bits) | |
28 # | |
29 # For brightness control, set the starting address to 0x24 | |
30 # By default only page 0x00 is used | |
31 # There are 8 pages of memory (these can be cycled through for animiations) | |
32 # 144 led channels | |
33 # Page 0x0A is used for configuration | |
34 # See the datasheet for full details http://www.issi.com/WW/pdf/31FL3731C.pdf | |
35 sleep 0.1 | |
36 printf "ledWPage 0x00 0x24 0x10 0x20 0x30 0x40 0x50\r" > $SERIALPORT | |
37 |