Switch Button Long Push

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bastibasti
Normal user
Posts: 25
Joined: 31 Jul 2018, 11:41

Switch Button Long Push

#1 Post by bastibasti » 31 Jul 2018, 11:53

Hi,

I have a question regarding the use case when using a button.

- Is there a way to detect a long push (for example, to implement a dimmer -short push on/off, long push pwm increase)


papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Switch Button Long Push

#3 Post by papperone » 01 Aug 2018, 10:26

Honestly I don't like this workaround (it's not a real short/long push implementation) as 1 second can be too low and 2 seconds will make the normal behaviour odd (I push and release immediately but need to way 2 sec until the light will turn on).
I truly believe this should be implemented differently (if I press and release the action shuould be immediately triggered as it's pointless waiting the threshold for the long press) and it must be coded in ESPEasy and not in the rules (unless we change the rule interpretation to handle the above scenario properly...)
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

bastibasti
Normal user
Posts: 25
Joined: 31 Jul 2018, 11:41

Re: Switch Button Long Push

#4 Post by bastibasti » 01 Aug 2018, 11:25

Agreed,

long push should be implemented by the espeasy firmware. I wonder why such a basic feature hasnt been implemented before?

User avatar
grovkillen
Core team member
Posts: 3303
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Switch Button Long Push

#5 Post by grovkillen » 01 Aug 2018, 11:27

The new scheduler will make it possible to have a higher resolution than seconds. So the timer will be working with 100mSec steps.
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 :idea: :idea: :idea:

TD-er
Core team member
Posts: 1810
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Switch Button Long Push

#6 Post by TD-er » 01 Aug 2018, 22:16

grovkillen wrote:
01 Aug 2018, 11:27
The new scheduler will make it possible to have a higher resolution than seconds. So the timer will be working with 100mSec steps.
Just to make that remark a bit more clear, for that one person not familiar with the recent changes in the code ;)

I am now working on a new global GPIO handler to detect and handle GPIO inputs.
This handler will poll the GPIO states quite often and record timings for plugins to collect.
When this handler detects a change, it can schedule a plugin to manage the changes.

Just to make it clear, there will be support for it, but it is being worked on and proper operations also depends on improvement of timings, which is partly being dealt with by the new scheduler.

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Switch Button Long Push

#7 Post by papperone » 01 Aug 2018, 23:26

grovkillen wrote:
01 Aug 2018, 11:27
The new scheduler will make it possible to have a higher resolution than seconds. So the timer will be working with 100mSec steps.
Not sure I understood how this improvement should help to detect faster short/long push... Can you elaborate more?
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

User avatar
grovkillen
Core team member
Posts: 3303
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Switch Button Long Push

#8 Post by grovkillen » 02 Aug 2018, 06:24

You can then have a timer that would detect a hold that is less than one second since the timer would allow to be sub secund.
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 :idea: :idea: :idea:

Mykayla8
Normal user
Posts: 1
Joined: 02 Aug 2018, 09:27
Contact:

Re: Switch Button Long Push

#9 Post by Mykayla8 » 02 Aug 2018, 09:29

Wow really interesting article, may later be able to share other helpful information are more interesting. Thank you!

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Switch Button Long Push

#10 Post by papperone » 02 Aug 2018, 11:37

grovkillen wrote:
02 Aug 2018, 06:24
You can then have a timer that would detect a hold that is less than one second since the timer would allow to be sub secund.
well I don't htink this will fix the problem, let me explain:
I woudl like a long push to be triggered after 2 seconds
I would like any time below 2 seconds to be recognized as short push
I would like the short pulse event to be triggered immediately not waiting the 2 secs of the long pulse threshold
and while 2 seconds can maybe still be reasonable for some users, let's imagine I want long pulse threshold 5 seconds or more!

Doing this with rules is complex and really not optimized, while in a proper "push button" plugin this can be implemented much more effectively without any rules if not the actions to be executed for all the possible events.

To summarize I'd like the push button device to be able to trigger at least 2 events with different timing (long push = fixed threshold, short push = variable threshold within the long push limit and immediate) and avoid false long push (with above ruleset if I press quickly 2 or more times within the threshold I could trigger the long push); and I think more events can be detected (double push, triple push, etc...)

I have no time unfortunately those days/weeks due to work related issues and as well I've been on deserved vacation for 3 weeks, but if nobody will be avail I'll add it anyway to the list of improvements I'd like to work with for ESPEasy
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

User avatar
grovkillen
Core team member
Posts: 3303
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Switch Button Long Push

#11 Post by grovkillen » 02 Aug 2018, 12:09

I think we're on the same page here. Only a quick add to the discussion. The upcoming GPIO handler will make stuff like this possible. 8-)
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 :idea: :idea: :idea:

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Switch Button Long Push

#12 Post by papperone » 02 Aug 2018, 19:04

grovkillen wrote:
02 Aug 2018, 12:09
I think we're on the same page here. Only a quick add to the discussion. The upcoming GPIO handler will make stuff like this possible. 8-)
that's great news!!! :mrgreen:
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

TD-er
Core team member
Posts: 1810
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Switch Button Long Push

#13 Post by TD-er » 03 Aug 2018, 21:59

Just for completeness, a part of the discussion between Jimmy and I about this:
The idea is to read 1 single register to inspect all GPIO pins. Mask (AND) that with just the bits you want to check and compare with the last known value.
That's about 5 clock cycli, so can be done as often as possible.
When something has changed, it has to see what bit has changed (XOR) and process the change.
Such a change may result in an "event", which is now not more than add a job to the scheduler.
Then the plugin that should deal with the event can read the last change, the time high and the time low.
Also we have the actual pin state, because it is not cached

mpopkin
Normal user
Posts: 1
Joined: 29 Nov 2018, 09:16

Re: Switch Button Long Push

#14 Post by mpopkin » 29 Nov 2018, 09:23

hello, I'm making a switchboard with 4 channel mains relay module with 4 buttons. I want when one of the buttons long pressed to turn ON/OFF all 4 relays. anyway, Can I do this?
I love playing a digital piano

User avatar
enesbcs
Normal user
Posts: 426
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Switch Button Long Push

#15 Post by enesbcs » 29 Nov 2018, 12:08

mpopkin wrote:
29 Nov 2018, 09:23
hello, I'm making a switchboard with 4 channel mains relay module with 4 buttons. I want when one of the buttons long pressed to turn ON/OFF all 4 relays. anyway, Can I do this?
I've done it with this plugin:
https://github.com/enesbcs/ESPEasyPlugi ... button.ino
Using "butonname#Longpress" event on all four buttons.

mattie47
Normal user
Posts: 1
Joined: 18 Jun 2019, 12:02

Re: Switch Button Long Push

#16 Post by mattie47 » 18 Jun 2019, 12:05

enesbcs wrote:
29 Nov 2018, 12:08
mpopkin wrote:
29 Nov 2018, 09:23
hello, I'm making a switchboard with 4 channel mains relay module with 4 buttons. I want when one of the buttons long pressed to turn ON/OFF all 4 relays. anyway, Can I do this?
I've done it with this plugin:
https://github.com/enesbcs/ESPEasyPlugi ... button.ino
Using "butonname#Longpress" event on all four buttons.

Just wanted to say thanks for this. I've been using the plugin for ~ 6 months now :-)

I also wrote a blog post about how to use it as well :-)

https://techlife.nz/blog/create-an-esp8 ... g-espeasy/

User avatar
enesbcs
Normal user
Posts: 426
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Switch Button Long Push

#17 Post by enesbcs » 18 Jun 2019, 17:51

mattie47 wrote:
18 Jun 2019, 12:05
Just wanted to say thanks for this. I've been using the plugin for ~ 6 months now :-)

I also wrote a blog post about how to use it as well :-)

https://techlife.nz/blog/create-an-esp8 ... g-espeasy/
Thanks for mentioning. :) In fact, the new P001_Switch plugin in ESPEasy also capable of sensing longpress and doubleclick events.

Post Reply

Who is online

Users browsing this forum: valbuz99 and 18 guests