do some sound effects. aplay or speech synth. make peoplecounter play join and leave sounds in timely manner

master
Level2 Pidor 2017-01-19 21:59:15 +01:00
parent b02efa5861
commit e5e3bc99f6
5 changed files with 68 additions and 14 deletions

View File

@ -0,0 +1,20 @@
#!/bin/bash
(
if [ "$1" = "released" ]
then
sleep 2
aplay '/root/win/Windows XP Startup.wav'
#espeak -s 130 "Welcome to Level2." 2>/dev/null
fi
if [ "$1" = "pushed" ]
then
aplay '/root/win/Windows XP Critical Error.wav'
sleep 1
aplay '/root/win/Windows XP Critical Stop.wav'
#espeak -s 130 "Level2 is closing." 2>/dev/null
#espeak -s 120 -p 80 "Please wait, until all lights are off." 2>/dev/null
sleep 1
#espeak -s 120 -p 80 "I will tell you when I am finished." 2>/dev/null
aplay '/root/win/Windows XP Logoff.wav'
fi
) &

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ "$1" = "released" ]
then
:
# espeak -s 130 "Welcome to Level2." 2>/dev/null
fi
if [ "$1" = "pushed" ]
then
#espeak -s 130 "Thank you for waiting. I am done. Have a nice day." 2>/dev/null
aplay '/root/win/Windows XP Shutdown.wav'
fi

View File

@ -10,7 +10,8 @@ else
fi
STATSFILE="/run/peoplecounter$DEV"
SAMPLES=20 # how many records to keep in file
INTERVAL=10 # how long to wait between polls
INTERVAL=0 # how long to wait between polls
INTERVALSKIP=20 # poll with INTERVAL but only consider every INTERVALSKIP's for SAMPLES
MAXFILE="/var/cache/peoplecountermax$DEV"
PRESENCY="/run/presency$DEV" # value shown on website
# /run/peoplecounter lists all recent reads, newest at end
@ -52,6 +53,7 @@ function addcount() {
}
PEOPLECOUNTERIP=$(cat $(dirname "$0")"/peoplecounterip.txt")
state="online"
rtoldp=0
while true
do
# scrape new value
@ -59,22 +61,43 @@ do
wget -qO - "http://$PEOPLECOUNTERIP/output.cgi?t=$(date +%s)" |
sed 's/.*Occupancy://'|
awk '{print $2}')"
# echo "p=$p" # debug
if [ "$p" != "" ] # oh we got something
then
oldp="$(getlastpeople)"
addcount "$p"
if [ "$p" != "$oldp" ]
skipcounter=$((skipcounter+1))
if [ $skipcounter -gt $INTERVALSKIP ]
then
logger $(basename $0) changed from $oldp to $p people
curmax=$(getmaxpeople)
oldmax=$(cat "$MAXFILE")
if [ "$curmax" -gt "${oldmax:-0}" ]
# echo "skipcounter expired. updating" # debug
skipcounter=0
addcount "$p"
# if max then call this:
if [ "$p" != "$oldp" ]
then
logger $(basename $0) setting max to $curmax because bigger than ${oldmax:-}
echo "$curmax" > "$MAXFILE"
chmod a+rw "$MAXFILE"
logger $(basename $0) changed from $oldp to $p people
curmax=$(getmaxpeople)
oldmax=$(cat "$MAXFILE")
if [ "$curmax" -gt "${oldmax:-0}" ]
then
logger $(basename $0) setting max to $curmax because bigger than ${oldmax:-}
echo "$curmax" > "$MAXFILE"
chmod a+rw "$MAXFILE"
fi
fi
fi
if [ $p -gt $rtoldp ]
then
# echo "p($p) -gt rtoldp($rtoldp)" # debug
aplay '/root/win/Windows XP Logon Sound.wav'
fi
if [ $p -lt $rtoldp ]
then
# echo "p($p) -lt rtoldp($rtoldp)" # debug
aplay '/root/win/Windows XP Logoff Sound.wav'
fi
# echo "rtoldp=$p" # debug
rtoldp=$p
oldaverage="$(cat "$PRESENCY")"
newaverage=$(getaveragepeople)
#logger $(basename $0) averages o=$oldaverage n=$newaverage

View File

@ -42,7 +42,7 @@ doorlockbutton="$(cat /run/doorlockbutton)"
nai=$(stat -c "%Y" /run/spacestatus) # get mtime as status change time
if [ "$status" = "open" ]
then
/usr/bin/curl --max-time 1 --silent --insecure --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":true,"lastchange":'"$nai"'}}' http://spaceapi.syn2cat.lu/sensor/set
/usr/bin/curl --max-time 1 --silent --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":true,"lastchange":'"$nai"'}}' https://spaceapi.syn2cat.lu/sensor/set
#logger -t $(basename $0) "$$ sending status $status to spacapi ret=$?"
fi
for plugin in $(ls "$0".d)
@ -60,7 +60,7 @@ then
# problem: if closing state but not actually shuting door for a longer time, the status in spaceapi
# will be the time of closing but not that of actually shutting the door
# but the status will only be updated once the door is shut
/usr/bin/curl --max-time 1 --silent --insecure --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":false,"lastchange":'"$nai"'}}' http://spaceapi.syn2cat.lu/sensor/set
/usr/bin/curl --max-time 1 --silent --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":false,"lastchange":'"$nai"'}}' https://spaceapi.syn2cat.lu/sensor/set
#logger -t $(basename $0) "$$ sending status $status to spacapi ret=$?"
fi
@ -74,5 +74,5 @@ if [ "$status" = "closed" ]
then
presency=0
fi
/usr/bin/curl --max-time 1 --silent --insecure --data key="$spaceapikey" --data-urlencode sensors='{"sensors":{"people_now_present":[{"value":'"$presency"'}]}}' http://spaceapi.syn2cat.lu/sensor/set
/usr/bin/curl --max-time 1 --silent --data key="$spaceapikey" --data-urlencode sensors='{"sensors":{"people_now_present":[{"value":'"$presency"'}]}}' https://spaceapi.syn2cat.lu/sensor/set
V

View File

@ -91,8 +91,8 @@
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="optical" >Optical (BluRay) 5.1</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="cd" >CD (white laptop)r</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="tuner" >Tuner</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="vol-" >Vol-</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="vol+" >Vol+</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="vol-" >Vol-</a></p>
<p><a class="col-md-3 btn btn-danger btn-lg btn-block" data-area="receiver" data-status="off" >Off</a></p>
</div>
</div>