Add "powerstrip" at backdoor.
authorAndreas Schiermeier <andreas@schiermeier.name>
Thu, 9 Feb 2017 20:39:26 +0000 (21:39 +0100)
committerAndreas Schiermeier <andreas@schiermeier.name>
Thu, 9 Feb 2017 20:39:26 +0000 (21:39 +0100)
powerblink.sh

index a59d54d..d5bf4a7 100755 (executable)
@@ -4,13 +4,32 @@ function blink {
   for v in {1..61..5} {60..0..5}
   do
     case "${1}" in
-      red|green|blue)
-        echo ${v} > /sys/bus/usb/drivers/usbled/*/${1}
+      red)
+        espcol="$((v+10))0000"
+        echo ${v} > /sys/bus/usb/drivers/usbled/*/red
+        echo 0 > /sys/bus/usb/drivers/usbled/*/green
+        echo 0 > /sys/bus/usb/drivers/usbled/*/blue
         ;;
-      *)
-        return 0
+      green)
+        espcol="00$((v+10))00"
+        echo 0 > /sys/bus/usb/drivers/usbled/*/red
+        echo ${v} > /sys/bus/usb/drivers/usbled/*/green
+        echo 0 > /sys/bus/usb/drivers/usbled/*/blue
+        ;;
+      blue)
+        espcol="0000$((v+10))"
+        echo 0 > /sys/bus/usb/drivers/usbled/*/red
+        echo 0 > /sys/bus/usb/drivers/usbled/*/green
+        echo ${v} > /sys/bus/usb/drivers/usbled/*/blue
+        ;;
+      yellow)
+        espcol="$((v+10))$((v+10))00"
+        echo ${v} > /sys/bus/usb/drivers/usbled/*/red
+        echo ${v} > /sys/bus/usb/drivers/usbled/*/green
+        echo 0 > /sys/bus/usb/drivers/usbled/*/blue
         ;;
     esac
+    curl -s "http://esp_9b8df9.hq/control?mode=3&led=0&color=$espcol" &> /dev/null
     sleep 0.1
   done
 }
@@ -22,7 +41,7 @@ blink blue
 
 while true
 do
-  # wait for file
+  # wait for watt
   if [ ! -f /dev/shm/power.log ]
   then
     sleep 1
@@ -36,18 +55,18 @@ do
     sleep 1
     continue
   fi
-  if [ "${p}" -lt 50 ]
+  if [ "${p}" -lt 80 ]
   then
     sleep 10
-  elif [ "${p}" -lt 200 ]
+  elif [ "${p}" -lt 230 ]
   then
     blink blue
-  elif [ "${p}" -lt 450 ]
+  elif [ "${p}" -lt 500 ]
   then
-    sleep 10
+    blink green
   elif [ "${p}" -lt 1000 ]
   then
-    blink green
+    blink yellow
   else
     blink red
   fi