experimentelle Lichtsteuerung
This commit is contained in:
parent
7628f52090
commit
97e0933431
|
@ -1,5 +1,6 @@
|
|||
import pifacedigitalio
|
||||
import time
|
||||
from subprocess import call
|
||||
|
||||
button_count = 8
|
||||
longpress_delay = 0.4
|
||||
|
@ -35,8 +36,7 @@ def switch_longpressed(event):
|
|||
elif pin_shortpress_count[event.pin_num] == 1:
|
||||
event.chip.output_pins[event.pin_num].toggle()
|
||||
elif pin_shortpress_count[event.pin_num] == 2:
|
||||
for i in range(button_count):
|
||||
event.chip.output_pins[i].turn_on()
|
||||
call(["/root/chch-power/ligth.sh"])
|
||||
|
||||
def switch_verylongpressed(event):
|
||||
shortpress_delay = pin_last_rise_date[event.pin_num] - pin_last_shortpress[event.pin_num]
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
TMPFILE=/tmp/light_state
|
||||
touch $TMPFILE
|
||||
LIGHT_STATE=$(cat $TMPFILE)
|
||||
[ -z "$LIGHT_STATE" ] && LIGHT_STATE=0
|
||||
|
||||
STATE_0="a\x00\x03\x00\x00\x00"
|
||||
STATE_1="a\x00\x03\xff\xff\xff"
|
||||
STATE_2="n\x00\x02\x01\x00"
|
||||
|
||||
LIGHT_STATE=$(( $LIGHT_STATE+1 ))
|
||||
case $LIGHT_STATE in
|
||||
0)
|
||||
STATE=$STATE_0
|
||||
;;
|
||||
1)
|
||||
STATE=$STATE_1
|
||||
;;
|
||||
2)
|
||||
STATE=$STATE_2
|
||||
;;
|
||||
*)
|
||||
STATE=$STATE_0
|
||||
LIGHT_STATE=0
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -en $STATE | nc -w1 172.23.92.15 49152
|
||||
echo $LIGHT_STATE > $TMPFILE
|
Loading…
Reference in New Issue