-
Notifications
You must be signed in to change notification settings - Fork 0
/
ws-indicate
82 lines (69 loc) · 1.68 KB
/
ws-indicate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# WildlifeSystems
#
# This script is part of the WildlifeSystems project. For further information
# please refer to https://docs.wildlife.systems, or for more information on
# the project itself, please refer to https://wildlife.systems.
# Return codes
#
# Further information on WildlifeSystems standard reurn codes can be found
# at https://docs.wildlife.systems/return-codes.html
# 0 - Success
# 10 - invalid argument
while [[ $(ps ws-indicate | wc -l) -gt 2 ]]; do
sleep 0.1
done
#Initial state
ATINIT=`awk -F'[][]' '{print $2}' /sys/class/leds/led0/trigger`
ABINIT=`cat /sys/class/leds/led0/brightness`
MODEL=$(grep -oP 'Revision\s*:\s*\K[^ ]*' /proc/cpuinfo)
if [[ "$MODEL" != "000d" ]]; then
PTINIT=`awk -F'[][]' '{print $2}' /sys/class/leds/led1/trigger`
PBINIT=`cat /sys/class/leds/led1/brightness`
fi
#Indicators
case "$1" in
list)
echo $ATINIT
echo $ABINIT
echo $PTINIT
echo $PBINIT
exit 0
;;
heartbeat)
for in in {1..2}; do
pi-pwr on actled &
pi-pwr off pwrled &
sleep 0.1
pi-pwr on pwrled &
pi-pwr off actled
sleep 0.1
x=$(( $x + 1 ))
done
;;
countdown)
pi-pwr off actled &
for i in $(seq $2 -1 0); do
pi-pwr off pwrled &
sleep 0.5
pi-pwr on pwrled &
sleep 0.5
echo $i
done
;;
record)
pi-pwr off actled &
pi-pwr on pwrled &
$2
pi-pwr off pwrled &
;;
*)
exit 10
esac
#Restore initial state
echo $ABINIT | sudo tee /sys/class/leds/led0/brightness >> /dev/null
echo $ATINIT | sudo tee /sys/class/leds/led0/trigger >> /dev/null
if [[ "$MODEL" != "000d" ]]; then
echo $PBINIT | sudo tee /sys/class/leds/led1/brightness >> /dev/null
echo $PTINIT | sudo tee /sys/class/leds/led1/trigger >> /dev/null
fi