|
@@ -0,0 +1,80 @@
|
|
1
|
+#!/bin/bash
|
|
2
|
+
|
|
3
|
+# The serialHelper115200 file is my own SerialHelper Utility compiled
|
|
4
|
+# with 115200 baud. Get it from here:
|
|
5
|
+# https://github.com/xythobuz/SerialHelper
|
|
6
|
+
|
|
7
|
+DATA_FILE=led_data_file
|
|
8
|
+
|
|
9
|
+if [ $# -ne 6 ]; then
|
|
10
|
+ echo "Usage: two times three hex bytes for color"
|
|
11
|
+ echo "$0 r1 g1 b1 r2 g2 b2"
|
|
12
|
+ exit
|
|
13
|
+fi
|
|
14
|
+
|
|
15
|
+PORTFILE=`ls /dev/tty.wchusbserial* | head -n 1`
|
|
16
|
+echo "Using $PORTFILE as serial port..."
|
|
17
|
+
|
|
18
|
+echo "WARNING: This is toggling the LEDs very fast between your two colors!"
|
|
19
|
+echo "The name epilepsy is no joke. Be careful."
|
|
20
|
+read -p "Press ENTER to continue..."
|
|
21
|
+
|
|
22
|
+echo "Opening serial port..."
|
|
23
|
+serialHelper115200 -rw $PORTFILE >/dev/null 2>/dev/null &
|
|
24
|
+TERM_PID=$!
|
|
25
|
+echo "PID is $TERM_PID"
|
|
26
|
+
|
|
27
|
+echo "Waiting for Arduino to be ready..."
|
|
28
|
+sleep 3
|
|
29
|
+
|
|
30
|
+echo
|
|
31
|
+
|
|
32
|
+for i in `seq 1 20`; do
|
|
33
|
+
|
|
34
|
+ echo "Preparing data to send..."
|
|
35
|
+ echo -n "xythobuzRGBled" > $DATA_FILE
|
|
36
|
+ for i in {1..156}; do
|
|
37
|
+ echo -n -e "\x$1\x$2\x$3" >> $DATA_FILE
|
|
38
|
+ done
|
|
39
|
+
|
|
40
|
+ echo "Sending data..."
|
|
41
|
+ cat $DATA_FILE > $PORTFILE
|
|
42
|
+
|
|
43
|
+ echo "Waiting for data to appear..."
|
|
44
|
+ sleep 0.05
|
|
45
|
+
|
|
46
|
+ echo
|
|
47
|
+
|
|
48
|
+ echo "Preparing data to send..."
|
|
49
|
+ echo -n "xythobuzRGBled" > $DATA_FILE
|
|
50
|
+ for i in {1..156}; do
|
|
51
|
+ echo -n -e "\x$4\x$5\x$6" >> $DATA_FILE
|
|
52
|
+ done
|
|
53
|
+
|
|
54
|
+ echo "Sending data..."
|
|
55
|
+ cat $DATA_FILE > $PORTFILE
|
|
56
|
+
|
|
57
|
+ echo "Waiting for data to appear..."
|
|
58
|
+ sleep 0.05
|
|
59
|
+
|
|
60
|
+ echo
|
|
61
|
+done
|
|
62
|
+
|
|
63
|
+echo "Preparing data to send..."
|
|
64
|
+echo -n "xythobuzRGBled" > $DATA_FILE
|
|
65
|
+for i in {1..156}; do
|
|
66
|
+ echo -n -e "\x00\x00\x00" >> $DATA_FILE
|
|
67
|
+done
|
|
68
|
+
|
|
69
|
+echo "Sending data..."
|
|
70
|
+cat $DATA_FILE > $PORTFILE
|
|
71
|
+
|
|
72
|
+echo "Waiting for data to appear..."
|
|
73
|
+sleep 0.1
|
|
74
|
+
|
|
75
|
+echo "Closing serial port..."
|
|
76
|
+kill $TERM_PID
|
|
77
|
+
|
|
78
|
+echo "Deleting created data file..."
|
|
79
|
+rm -rf $DATA_FILE
|
|
80
|
+
|