Page 1 of 1

Switch Button Long Push

Posted: 31 Jul 2018, 11:53
by bastibasti
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)

Re: Switch Button Long Push

Posted: 31 Jul 2018, 15:13
by wim16

Re: Switch Button Long Push

Posted: 01 Aug 2018, 10:26
by papperone
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...)

Re: Switch Button Long Push

Posted: 01 Aug 2018, 11:25
by bastibasti
Agreed,

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

Re: Switch Button Long Push

Posted: 01 Aug 2018, 11:27
by grovkillen
The new scheduler will make it possible to have a higher resolution than seconds. So the timer will be working with 100mSec steps.

Re: Switch Button Long Push

Posted: 01 Aug 2018, 22:16
by TD-er
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.

Re: Switch Button Long Push

Posted: 01 Aug 2018, 23:26
by papperone
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?

Re: Switch Button Long Push

Posted: 02 Aug 2018, 06:24
by grovkillen
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.

Re: Switch Button Long Push

Posted: 02 Aug 2018, 11:37
by papperone
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

Re: Switch Button Long Push

Posted: 02 Aug 2018, 12:09
by grovkillen
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-)

Re: Switch Button Long Push

Posted: 02 Aug 2018, 19:04
by papperone
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:

Re: Switch Button Long Push

Posted: 03 Aug 2018, 21:59
by TD-er
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

Re: Switch Button Long Push

Posted: 29 Nov 2018, 09:23
by mpopkin
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?

Re: Switch Button Long Push

Posted: 29 Nov 2018, 12:08
by enesbcs
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.

Re: Switch Button Long Push

Posted: 18 Jun 2019, 12:05
by mattie47
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/

Re: Switch Button Long Push

Posted: 18 Jun 2019, 17:51
by enesbcs
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.