experimentelle Lichtsteuerung
This commit is contained in:
parent
7628f52090
commit
97e0933431
2 changed files with 32 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
import pifacedigitalio
|
import pifacedigitalio
|
||||||
import time
|
import time
|
||||||
|
from subprocess import call
|
||||||
|
|
||||||
button_count = 8
|
button_count = 8
|
||||||
longpress_delay = 0.4
|
longpress_delay = 0.4
|
||||||
|
@ -35,8 +36,7 @@ def switch_longpressed(event):
|
||||||
elif pin_shortpress_count[event.pin_num] == 1:
|
elif pin_shortpress_count[event.pin_num] == 1:
|
||||||
event.chip.output_pins[event.pin_num].toggle()
|
event.chip.output_pins[event.pin_num].toggle()
|
||||||
elif pin_shortpress_count[event.pin_num] == 2:
|
elif pin_shortpress_count[event.pin_num] == 2:
|
||||||
for i in range(button_count):
|
call(["/root/chch-power/ligth.sh"])
|
||||||
event.chip.output_pins[i].turn_on()
|
|
||||||
|
|
||||||
def switch_verylongpressed(event):
|
def switch_verylongpressed(event):
|
||||||
shortpress_delay = pin_last_rise_date[event.pin_num] - pin_last_shortpress[event.pin_num]
|
shortpress_delay = pin_last_rise_date[event.pin_num] - pin_last_shortpress[event.pin_num]
|
||||||
|
|
30
ligth.sh
Executable file
30
ligth.sh
Executable file
|
@ -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…
Add table
Add a link
Reference in a new issue