removed flash by semaphore in redis. error code display on clock dial
parent
01a6c13db3
commit
3fabf743f5
|
@ -24,7 +24,7 @@ pulseon() {
|
||||||
echo $!
|
echo $!
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Initializing hardware"
|
logger $0 "Initializing hardware"
|
||||||
# the button
|
# the button
|
||||||
|
|
||||||
ledcolor() {
|
ledcolor() {
|
||||||
|
@ -33,7 +33,7 @@ ledcolor() {
|
||||||
blue=$3
|
blue=$3
|
||||||
showleds set $((red/ATTENUATION)) $((green/ATTENUATION)) $((blue/ATTENUATION))
|
showleds set $((red/ATTENUATION)) $((green/ATTENUATION)) $((blue/ATTENUATION))
|
||||||
}
|
}
|
||||||
echo "Main loop"
|
logger $0 "Main loop"
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
if [ $(arp -a | awk '{arp[$2]=$4;ip[$4]=ip[$4]" "$2}END{print ip[arp["(10.2.113.1)"]]}' | wc -w) -gt 1 ]
|
if [ $(arp -a | awk '{arp[$2]=$4;ip[$4]=ip[$4]" "$2}END{print ip[arp["(10.2.113.1)"]]}' | wc -w) -gt 1 ]
|
||||||
|
|
46
buzzctrl.sh
46
buzzctrl.sh
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# led is not neopixel, so use the python lib for that
|
|
||||||
BUTTONPIN=25
|
BUTTONPIN=25
|
||||||
BUZZERURL="$(cat "$(dirname "$0")"/secret.txt)/state.xml?relay1State=2&pulseTime1=5"
|
BUZZERURL="$(cat "$(dirname "$0")"/secret.txt)/state.xml?relay1State=2&pulseTime1=5"
|
||||||
BUZZERSTATUSURL="$(cat "$(dirname "$0")"/secret.txt)/state.xml"
|
BUZZERSTATUSURL="$(cat "$(dirname "$0")"/secret.txt)/state.xml"
|
||||||
|
@ -9,11 +8,13 @@ cd $(dirname "$0")
|
||||||
|
|
||||||
showleds() {
|
showleds() {
|
||||||
./redi.sh <<EOF
|
./redi.sh <<EOF
|
||||||
|
valid=no
|
||||||
neoaction=$1
|
neoaction=$1
|
||||||
neored=$2
|
neored=$2
|
||||||
neogreen=$3
|
neogreen=$3
|
||||||
neoblue=$4
|
neoblue=$4
|
||||||
neomorse=$5
|
neovalue=$5
|
||||||
|
valid=yes
|
||||||
EOF
|
EOF
|
||||||
# sudo kill $(ps -edf| awk '/[s]etneocolor.py/{print $2}' ) 2>/dev/null
|
# sudo kill $(ps -edf| awk '/[s]etneocolor.py/{print $2}' ) 2>/dev/null
|
||||||
# sudo python /home/pi/doorbuzz/setneocolor.py $1 $2 $3 $4
|
# sudo python /home/pi/doorbuzz/setneocolor.py $1 $2 $3 $4
|
||||||
|
@ -58,7 +59,7 @@ morse[8]="---.."
|
||||||
morse[9]="----."
|
morse[9]="----."
|
||||||
morseled() {
|
morseled() {
|
||||||
message=$1
|
message=$1
|
||||||
echo $message
|
logger $0 morseled $message
|
||||||
msglen=${#message}
|
msglen=${#message}
|
||||||
pos=0
|
pos=0
|
||||||
morsecode=""
|
morsecode=""
|
||||||
|
@ -75,14 +76,36 @@ echo $morsecode
|
||||||
|
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
dialcode() {
|
||||||
|
# shows number code on clock dial
|
||||||
|
message=$1
|
||||||
|
logger $0 dialcode $message
|
||||||
|
msglen=${#message}
|
||||||
|
pos=0
|
||||||
|
while [ $pos -lt $msglen ]
|
||||||
|
do
|
||||||
|
dcode="${message:${pos}:1}"
|
||||||
|
dcode=$((dcode*5)) # convert numbers into clock values
|
||||||
|
pos=$((pos+1))
|
||||||
|
echo $dcode
|
||||||
|
red=$2
|
||||||
|
green=$3
|
||||||
|
blue=$4
|
||||||
|
showleds set 0 0 0
|
||||||
|
showleds number $((red/ATTENUATION)) $((green/ATTENUATION)) $((blue/ATTENUATION)) "$dcode"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
showleds set 0 0 0
|
||||||
|
}
|
||||||
|
|
||||||
echo "morsing IP"
|
logger $0 "morsing IP"
|
||||||
morseled "$(hostname -I|awk -F. '{sub(" ","",$NF);printf $NF}')" 255 0 0
|
#morseled "$(hostname -I|awk -F. '{sub(" ","",$NF);printf $NF}')" 255 0 0
|
||||||
sleep 10
|
dialcode "$(hostname -I|awk -F. '{sub(" ","",$NF);printf $NF}')" 255 0 0
|
||||||
echo "Main loop"
|
sleep 1
|
||||||
|
logger $0 "Main loop"
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
ledcolor 0 255 255
|
#ledcolor 0 255 255
|
||||||
pulsepid=$(pulseon 0 0 255 )
|
pulsepid=$(pulseon 0 0 255 )
|
||||||
trap "ledcolor 0 0 0;exit" 1 2 3
|
trap "ledcolor 0 0 0;exit" 1 2 3
|
||||||
gpio -g wfi $BUTTONPIN falling
|
gpio -g wfi $BUTTONPIN falling
|
||||||
|
@ -91,12 +114,13 @@ do
|
||||||
gpio -g wfi $BUTTONPIN falling
|
gpio -g wfi $BUTTONPIN falling
|
||||||
done
|
done
|
||||||
ledcolor 0 255 255
|
ledcolor 0 255 255
|
||||||
echo "Pushiii"
|
logger $0 "Big Red Button pushed"
|
||||||
wget -O - -S --timeout=1 --tries=1 "$BUZZERURL" 2>&1
|
wget -O - -S --timeout=1 --tries=1 "$BUZZERURL" 2>&1
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ $ret -ne 0 ]
|
if [ $ret -ne 0 ]
|
||||||
then
|
then
|
||||||
morseled "$ret" 255 0 0
|
#morseled "$ret" 255 0 0
|
||||||
|
dialcode "$ret" 255 0 0
|
||||||
sleep 5
|
sleep 5
|
||||||
else
|
else
|
||||||
while wget -O - --timeout=1 --tries=1 $BUZZERSTATUSURL|grep '<relay1state>1</relay1state>'
|
while wget -O - --timeout=1 --tries=1 $BUZZERSTATUSURL|grep '<relay1state>1</relay1state>'
|
||||||
|
@ -107,7 +131,7 @@ do
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo "DOOONE"
|
logger $0 "button push action finished"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@ do
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ $ret -eq 1 ] # no more coprocess
|
if [ $ret -eq 1 ] # no more coprocess
|
||||||
then
|
then
|
||||||
echo "connecting to pidor"
|
logger $0 "connecting to pidor"
|
||||||
coproc ssh -i ~/.ssh/doorbuzz $pidor
|
coproc ssh -i ~/.ssh/doorbuzz $pidor
|
||||||
sleep 10
|
sleep 10
|
||||||
echo "connected"
|
logger $0 "connected"
|
||||||
echo "flashoff" >&"${COPROC[1]}"
|
echo "flashoff" >&"${COPROC[1]}"
|
||||||
ret=0
|
ret=0
|
||||||
fi
|
fi
|
||||||
|
@ -28,7 +28,7 @@ do
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
echo "$status"
|
logger $0 "$status"
|
||||||
done
|
done
|
||||||
echo "spacestatus" >&"${COPROC[1]}"
|
echo "spacestatus" >&"${COPROC[1]}"
|
||||||
read status <&"${COPROC[0]}"
|
read status <&"${COPROC[0]}"
|
||||||
|
@ -46,7 +46,7 @@ do
|
||||||
if [ "$new_status" -eq "$old_status" ]; then
|
if [ "$new_status" -eq "$old_status" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "phone status change detected"
|
logger $0 "phone status change detected"
|
||||||
if [ "$new_status" -eq 0 ]; then
|
if [ "$new_status" -eq 0 ]; then
|
||||||
echo "neoaction=flash" | ./redi.sh
|
echo "neoaction=flash" | ./redi.sh
|
||||||
echo "flashon" >&"${COPROC[1]}"
|
echo "flashon" >&"${COPROC[1]}"
|
||||||
|
|
|
@ -30,6 +30,10 @@ def wheel(pos):
|
||||||
def clockcalc(value):
|
def clockcalc(value):
|
||||||
return 1+((30+int(value))%60)
|
return 1+((30+int(value))%60)
|
||||||
|
|
||||||
|
def showit():
|
||||||
|
if ( valid == "yes" ):
|
||||||
|
strip.show()
|
||||||
|
|
||||||
# Main program logic follows:
|
# Main program logic follows:
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Create NeoPixel object with appropriate configuration.
|
# Create NeoPixel object with appropriate configuration.
|
||||||
|
@ -55,17 +59,31 @@ if __name__ == '__main__':
|
||||||
action=myredis.get('neoaction')
|
action=myredis.get('neoaction')
|
||||||
except:
|
except:
|
||||||
action="set"
|
action="set"
|
||||||
|
try:
|
||||||
|
valid=myredis.get('valid')
|
||||||
|
except:
|
||||||
|
valid="yes"
|
||||||
|
if ( valid != "yes" ):
|
||||||
|
continue
|
||||||
if(action == "set"):
|
if(action == "set"):
|
||||||
print "Color set to: ",r,g,b
|
print "Color set to: ",r,g,b
|
||||||
for i in range(0,LED_COUNT):
|
for i in range(0,LED_COUNT):
|
||||||
strip.setPixelColor(i, Color(r,g,b))
|
strip.setPixelColor(i, Color(r,g,b))
|
||||||
strip.show()
|
showit()
|
||||||
|
if(action == "number"):
|
||||||
|
tmp=myredis.get('neovalue')
|
||||||
|
if(not tmp):
|
||||||
|
continue
|
||||||
|
i=clockcalc(int(tmp))
|
||||||
|
print "Digit ",i," set to: ",r,g,b
|
||||||
|
strip.setPixelColor(i, Color(r,g,b))
|
||||||
|
showit()
|
||||||
if(action == "morse"):
|
if(action == "morse"):
|
||||||
print "Morsing with: ",r,g,b
|
print "Morsing with: ",r,g,b
|
||||||
speed=10
|
speed=10
|
||||||
for i in range(0,LED_COUNT):
|
for i in range(0,LED_COUNT):
|
||||||
strip.setPixelColor(i, Color(0,0,0))
|
strip.setPixelColor(i, Color(0,0,0))
|
||||||
morsecode=myredis.get('neomorse')
|
morsecode=myredis.get('neovalue')
|
||||||
morsep=1
|
morsep=1
|
||||||
for c in morsecode:
|
for c in morsecode:
|
||||||
if c==".":
|
if c==".":
|
||||||
|
@ -91,7 +109,7 @@ if __name__ == '__main__':
|
||||||
morsep+=1
|
morsep+=1
|
||||||
strip.setPixelColor(morsep, Color(0,0,0))
|
strip.setPixelColor(morsep, Color(0,0,0))
|
||||||
morsep+=1
|
morsep+=1
|
||||||
strip.show()
|
showit()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if(action == "pulse"):
|
if(action == "pulse"):
|
||||||
print "Pulsing with: ",r,g,b
|
print "Pulsing with: ",r,g,b
|
||||||
|
@ -112,7 +130,7 @@ if __name__ == '__main__':
|
||||||
strip.setPixelColor(clockcalc(j), color)
|
strip.setPixelColor(clockcalc(j), color)
|
||||||
strip.setPixelColor(clockcalc(time.strftime('%M',time.localtime())),Color(30,0,0))
|
strip.setPixelColor(clockcalc(time.strftime('%M',time.localtime())),Color(30,0,0))
|
||||||
strip.setPixelColor(clockcalc(time.strftime('%S',time.localtime())),Color(0,30,0))
|
strip.setPixelColor(clockcalc(time.strftime('%S',time.localtime())),Color(0,30,0))
|
||||||
strip.show()
|
showit()
|
||||||
time.sleep(50/1000.0)
|
time.sleep(50/1000.0)
|
||||||
|
|
||||||
if(action == "flash"):
|
if(action == "flash"):
|
||||||
|
@ -129,7 +147,7 @@ if __name__ == '__main__':
|
||||||
for q in range(3):
|
for q in range(3):
|
||||||
for i in range(0, strip.numPixels(), 3):
|
for i in range(0, strip.numPixels(), 3):
|
||||||
strip.setPixelColor(i+q, wheel((i+j) % 255))
|
strip.setPixelColor(i+q, wheel((i+j) % 255))
|
||||||
strip.show()
|
showit()
|
||||||
time.sleep(wait_ms/1000.0)
|
time.sleep(wait_ms/1000.0)
|
||||||
for i in range(0, strip.numPixels(), 3):
|
for i in range(0, strip.numPixels(), 3):
|
||||||
strip.setPixelColor(i+q, 0)
|
strip.setPixelColor(i+q, 0)
|
||||||
|
|
Loading…
Reference in New Issue