New GPIO for DHT11.
[hqdisplay.git] / powerblink.sh
1 #!/bin/bash
2
3 function blink {
4   for v in {1..61..5} {60..0..5}
5   do
6     case "${1}" in
7       red|green|blue)
8         echo ${v} > /sys/bus/usb/drivers/usbled/*/${1}
9         ;;
10       *)
11         return 0
12         ;;
13     esac
14     sleep 0.1
15   done
16 }
17
18 # 'reset' all colors
19 blink red
20 blink green
21 blink blue
22
23 while true
24 do
25   # wait for file
26   if [ ! -f /dev/shm/power.log ]
27   then
28     sleep 1
29     continue
30   fi
31   # /dev/shm/power.log: 330.0
32   IFS=. read -a pa < /dev/shm/power.log
33   p="${pa[0]}"
34   if [ -z "${p}" ]
35   then
36     sleep 1
37     continue
38   fi
39   if [ "${p}" -lt 50 ]
40   then
41     sleep 10
42   elif [ "${p}" -lt 200 ]
43   then
44     blink blue
45   elif [ "${p}" -lt 450 ]
46   then
47     sleep 10
48   elif [ "${p}" -lt 1000 ]
49   then
50     blink green
51   else
52     blink red
53   fi
54 done