|
@@ -1,61 +1,107 @@
|
|
|
#!/bin/bash
|
|
|
+Mode=UART # (UART / USB )
|
|
|
+Output=0
|
|
|
+Beep=0
|
|
|
+
|
|
|
+# echo "T" >/dev/ttyAMA0
|
|
|
+
|
|
|
+echo -n "Serial ledStatus v1.0 : "
|
|
|
+if [ $Mode = "UART" ]
|
|
|
+then
|
|
|
+echo -e "UART mode\n"
|
|
|
+Output=serial
|
|
|
+#stty -F /dev/serial0 ispeed 9600 ospeed 9600 -ignpar cs8 -cstopb -echo
|
|
|
+echo "serial0" >/tmp/mcled
|
|
|
+else
|
|
|
+echo -e "USB mode\n"
|
|
|
+Output=ttyACM0
|
|
|
stty -F /dev/ttyACM0 ispeed 9600 ospeed 9600 -ignpar cs8 -cstopb -echo
|
|
|
+echo "ttyACM0" >/tmp/mcled
|
|
|
+fi
|
|
|
+
|
|
|
|
|
|
-ip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
|
|
|
+#ip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
|
|
|
+#ip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
|
|
|
+ip=192.168.1.8
|
|
|
test=$(mcstatus $ip status | grep players: | awk '{print$2}' | sed 's/\x2F20//g')
|
|
|
-player1=$(mcstatus 192.168.1.8 status | grep players: | awk '{print$3}' | sed 's/\[\x2E//g')
|
|
|
+player1=$(mcstatus $ip status | grep players: | awk '{print$3}' | sed 's/\[\x2E//g')
|
|
|
date_raw=$(date +%H%M)
|
|
|
-cd ~/scripts/mcled_status/
|
|
|
|
|
|
-case $date_raw in
|
|
|
-[0700-2200]*)
|
|
|
-echo "Day mode"
|
|
|
-echo "D" >/dev/ttyACM0
|
|
|
-sleep 1
|
|
|
+if [ -f /tmp/bootdelay ]
|
|
|
+then
|
|
|
+boottime=`cat /tmp/bootdelay | awk '{print $1}'`
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "z" >/dev/$Output'
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "0" >/dev/$Output'
|
|
|
+echo
|
|
|
+echo "boot delay wait"
|
|
|
+sleep 600
|
|
|
+rm /tmp/bootdelay
|
|
|
+fi
|
|
|
+
|
|
|
+case $Beep in
|
|
|
+0*)
|
|
|
+echo "Buzzer: OFF"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "z" >/dev/$Output'
|
|
|
;;
|
|
|
-[2201-0659]*)
|
|
|
-echo "Night mode"
|
|
|
-echo "N" >/dev/ttyACM0
|
|
|
-sleep 1
|
|
|
+1*)
|
|
|
+echo "Buzzer: ON"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "Z" >/dev/$Output'
|
|
|
;;
|
|
|
*)
|
|
|
;;
|
|
|
esac
|
|
|
|
|
|
+if [ "$date_raw" -ge 0900 -a "$date_raw" -le 2100 ]
|
|
|
+then
|
|
|
+echo "Day: ON"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "D" >/dev/$Output'
|
|
|
+else
|
|
|
+echo "Day: OFF"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "N" >/dev/$Output'
|
|
|
+fi
|
|
|
+
|
|
|
+
|
|
|
case $test in
|
|
|
0*)
|
|
|
-echo "O"
|
|
|
-echo "0" >/dev/ttyACM0
|
|
|
+echo "Players: O"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "0" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/off
|
|
|
;;
|
|
|
1*)
|
|
|
if [ $player1 = "Tristus51" ]
|
|
|
then
|
|
|
-echo "tristan only"
|
|
|
-echo "T" >/dev/ttyACM0
|
|
|
+echo "Code: Tristan"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "T" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
echo $tristan
|
|
|
-elif [ $player1 = "MisterPig51" ]
|
|
|
+elif [ $player1 = "ALVARE" ]
|
|
|
then
|
|
|
-echo "MisterPig only"
|
|
|
-echo "V" >/dev/ttyACM0
|
|
|
+echo "Code: MisterPig"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "V" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
elif [ $player1 = "BobBadin" ]
|
|
|
then
|
|
|
-echo "Ethan Only"
|
|
|
-echo "E" >/dev/ttyACM0
|
|
|
+echo "Code: Ethan"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "E" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
else
|
|
|
-echo "1" >/dev/ttyACM0
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "1" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
fi
|
|
|
;;
|
|
|
2*)
|
|
|
-echo "two"
|
|
|
-echo "2" >/dev/ttyACM0
|
|
|
+echo "Code: two"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "2" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
;;
|
|
|
[3-9]|[1-2][0-0]*)
|
|
|
-echo "further"
|
|
|
-echo "3" >/dev/ttyACM0
|
|
|
+echo "Code: many"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "3" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/on
|
|
|
;;
|
|
|
*)
|
|
|
-echo $test
|
|
|
-echo "error"
|
|
|
-echo "X" >/dev/ttyACM0
|
|
|
+echo "Code: Error"
|
|
|
+sudo bash -c 'Output=$(cat "/tmp/mcled") && echo "X" >/dev/$Output'
|
|
|
+#curl http://192.168.1.120/toggle
|
|
|
;;
|
|
|
esac
|