Page 1 of 1
Long press button delay
Posted: 03 Apr 2018, 20:35
by trojan-tj1
Hello! I'm new to using EspEasy. I've been trying to figure it out for a few days, but I can not do anything. My task is simple. There is 1 switch. With this switch I want to operate 2 relays. By means of short and long pressing of the button. Switch is a simple press button. I can do it with the help of this rule:
on sw1#value1 do
if [sw1#value1] = 0
timerSet, 1, 1
endon
on rules#timer=1 do
if [sw1#value1] = 1
...
else
...
endif
endon
But there is a problem - too long delay with a short press. A whole second. And it's very inconvenient. I have read that for timerSet you can not use a value of less than 1 second. I read about the delay function. I'm trying to use it instead of timerSet, but nothing happens. Maybe someone can help me?
Re: Long press button delay
Posted: 03 Apr 2018, 20:46
by grovkillen
Delay will not work since it's essentially pausing the unit until the delay time is up.
Re: Long press button delay
Posted: 03 Apr 2018, 21:09
by Martinus
Maybe use the new way to directly read gpio :
[Plugin#GPIO#Pinstate#13]
After 250 mS delay?
Re: Long press button delay
Posted: 05 Apr 2018, 09:45
by toffel969
Martinus wrote: ↑03 Apr 2018, 21:09
Maybe use the new way to directly read gpio :
[Plugin#GPIO#Pinstate#13]
After 250 mS delay?
Hi martinus
Is there doc/info available on that new feature, so that we can update the wiki ( couldn't find a PR on github)? Does this also work on mcp/pcf gpio? Since when is it part of the nightlies?
regards
Re: Long press button delay
Posted: 05 Apr 2018, 12:46
by Martinus
toffel969 wrote: ↑05 Apr 2018, 09:45Hi martinus
Is there doc/info available on that new feature, so that we can update the wiki ( couldn't find a PR on github)? Does this also work on mcp/pcf gpio? Since when is it part of the nightlies?
regards
I think that Wiki should reflect the current stable to avoid confusion. This feature was added on Dev branch on March 7th. It's preliminary work on build-in GPIO only.
Waiting to be evaluated by it's requester on issue:
https://github.com/letscontrolit/ESPEasy/issues/1018
Re: Long press button delay
Posted: 15 Apr 2018, 13:12
by trojan-tj1
Does anyone have more detailed information on the use of the new way to directly read gpio? For example, [Plugin#GPIO#Pinstate#13]
Re: Long press button delay
Posted: 15 Apr 2018, 19:44
by trojan-tj1
At last I managed to realize what I wanted. Nowhere in the forums did not find a solution. Through trial and error, I made this rule. I turn to the experts. What can you say about this rule?
on System#Boot do
TaskValueSet 2,1,1 //dummy variable for long press
TaskValueSet 2,2,1 //dummy variable for short press
endon
on sw1#value1 do //my button
delay 250
if [Plugin#GPIO#Pinstate#12]=0
event,longpush
else
event,shortpush
endif
endon
on longpush do
if [counter#longcount]=1
gpio,14,0
TaskValueSet 2,1,0
else
gpio,14,1
TaskValueSet 2,1,1
endon
on shortpush do
if [counter#shortcount]=1
gpio,16,0
TaskValueSet 2,2,0
else
gpio,16,1
TaskValueSet 2,2,1
endon
Re: Long press button delay
Posted: 16 Apr 2018, 00:28
by TD-er
My first reaction is, don't use GPIO 16.
Please have a look at the usable pins here:
https://www.esp8266.com/wiki/doku.php?i ... llocations