view live status of people counter on clock dial

py3
Georges 2016-03-31 20:43:28 +02:00
parent 3fabf743f5
commit 284d207561
2 changed files with 18 additions and 3 deletions

View File

@ -30,6 +30,14 @@ do
fi fi
logger $0 "$status" logger $0 "$status"
done done
ocounter="$counter"
echo "peoplecounter" >&"${COPROC[1]}"
read counter <&"${COPROC[0]}"
if [ "$counter" != "$ocounter" ]
then
logger $0 peoplecounter=$counter
echo "neocounter=$counter" | ./redi.sh
fi
echo "spacestatus" >&"${COPROC[1]}" echo "spacestatus" >&"${COPROC[1]}"
read status <&"${COPROC[0]}" read status <&"${COPROC[0]}"
if ! [ "$status" = "open" ]; then # do nothing if space is closed if ! [ "$status" = "open" ]; then # do nothing if space is closed

View File

@ -118,17 +118,24 @@ if __name__ == '__main__':
for i in range(pulsewidth): for i in range(pulsewidth):
if(action!=myredis.get('neoaction')): if(action!=myredis.get('neoaction')):
break break
# reset all pixels to black
color=Color(0,0,0) color=Color(0,0,0)
for j in range(0,60): for j in range(0,60):
strip.setPixelColor(clockcalc(j), color) strip.setPixelColor(clockcalc(j), color)
trigo=sin(i/pulsewidth*pi) # put the hours hand as white, skew by 5 depending on minutes value
color=Color(int(r*trigo),int(g*trigo),int(b*trigo)) clockpos=int(int(time.strftime('%I',time.localtime()))*5+int(time.strftime('%M',time.localtime()))/60*5)
clockpos=int(time.strftime('%I',time.localtime()))*5
for j in range(-2,3): for j in range(-2,3):
strip.setPixelColor(clockcalc(clockpos+j),Color(30,30,30)) strip.setPixelColor(clockcalc(clockpos+j),Color(30,30,30))
# set the hours marks as a plusing blue
trigo=sin(i/pulsewidth*pi)
color=Color(int(r*trigo),int(g*trigo),int(b*trigo))
for j in range(0,60,5): for j in range(0,60,5):
strip.setPixelColor(clockcalc(j), color) strip.setPixelColor(clockcalc(j), color)
# put the current people count as magenta
strip.setPixelColor(clockcalc(myredis.get('neocounter')),Color(10,0,10))
# put the minute hand as red
strip.setPixelColor(clockcalc(time.strftime('%M',time.localtime())),Color(30,0,0)) strip.setPixelColor(clockcalc(time.strftime('%M',time.localtime())),Color(30,0,0))
# put the seconds hand as green
strip.setPixelColor(clockcalc(time.strftime('%S',time.localtime())),Color(0,30,0)) strip.setPixelColor(clockcalc(time.strftime('%S',time.localtime())),Color(0,30,0))
showit() showit()
time.sleep(50/1000.0) time.sleep(50/1000.0)