Updated Script Cookbook (markdown)

gemu 2019-07-28 19:39:00 +02:00
parent 54f3126f6f
commit 82f021809a
1 changed files with 49 additions and 49 deletions

@ -702,56 +702,56 @@ istr=""
------------------------------------------------------------------------------
#### Fast Polling
; expand strings to hold websend
>D 25
sw=0
ws="websend [192.168.178.86]"
timer=0
hold=0
toggle=0
#### Fast Polling
; expand strings to hold websend
\>D 25
sw=0
ws="websend [192.168.178.86]"
timer=0
hold=0
toggle=0
>B
; gpio 5 button input
spinm(5,0)
\>B
; gpio 5 button input
spinm(5,0)
; fast section 100ms
>F
sw=pin[5]
; 100 ms timer
timer+=1
; fast section 100ms
\>F
sw=pin[5]
; 100 ms timer
timer+=1
; 3 seconds long press
; below 0,5 short press
if sw==0
and timer>5
and timer<30
then
; short press
;=>print short press
toggle^=1
=>%ws% power1 %toggle%
endif
; 3 seconds long press
; below 0,5 short press
if sw==0
and timer>5
and timer<30
then
; short press
;=>print short press
toggle^=1
=>%ws% power1 %toggle%
endif
if sw>0
then
;pressed
if timer>30
then
; hold
hold=1
;=>print hold=%timer%
if toggle>0
then
=>%ws% dimmer +
else
=>%ws% dimmer -
endif
endif
else
timer=0
hold=0
endif
if sw>0
then
;pressed
if timer>30
then
; hold
hold=1
;=>print hold=%timer%
if toggle>0
then
=>%ws% dimmer +
else
=>%ws% dimmer -
endif
endif
else
timer=0
hold=0
endif
[Back To Top](#top)
@ -760,7 +760,7 @@ endif
#### Switching By Recognizing Mains Power Frequency
[#6085 (comment)](../issues/6085#issuecomment-512353010)
>D
\>D
sw1=0
sw2=0
cnt1=0
@ -770,10 +770,10 @@ timer2=0
toggle1=0
toggle2=0
>B
\>B
=>print "WiFi 2-Gang Switch Script"
>F
\>F
; Counter1/2 and Relay1/2 configured in template
cnt1=pc[1]
cnt2=pc[2]