Long press button delay
Moderators: grovkillen, Stuntteam, TD-er
-
- New user
- Posts: 7
- Joined: 03 Apr 2018, 14:18
Long press button delay
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?
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?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Long press button delay
Delay will not work since it's essentially pausing the unit until the delay time is up.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Long press button delay
Maybe use the new way to directly read gpio :
[Plugin#GPIO#Pinstate#13]
After 250 mS delay?
[Plugin#GPIO#Pinstate#13]
After 250 mS delay?
Re: Long press button 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
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8
Re: Long press button delay
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
-
- New user
- Posts: 7
- Joined: 03 Apr 2018, 14:18
Re: Long press button delay
Does anyone have more detailed information on the use of the new way to directly read gpio? For example, [Plugin#GPIO#Pinstate#13]
-
- New user
- Posts: 7
- Joined: 03 Apr 2018, 14:18
Re: Long press button delay
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
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
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
Please have a look at the usable pins here: https://www.esp8266.com/wiki/doku.php?i ... llocations
Who is online
Users browsing this forum: No registered users and 11 guests