-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Longpress in Switch input - Switch #4862
Comments
That is a normal behaviour.. In general there could be an option for longpress like "disable/enable trigger shortpress before longpress" |
In my easy scenario I have a push button connected to a Input GPIO with a pull-down resistor (so GPIO is connected to GND via the resistor).
So why Longpress STATE (10) is generated if I press the push button for a very very short time?
Also here, we should manage Shortpress and Longpress and generate the appropriate EVENT according. |
What happens when you change "Longpress event:" to |
happens that the "Longpress event:" is NOT generated (also if I press and leave push button pressed for some seconds):
but I suppose in this case it's correct. |
Ok.. let´s figure this out in the forum.... i don´t think its a bug since i couldn´t reproduce it. |
so there is a bug. You are right.. this seems to be bug indeed. It does create a longpress event when longpress event is set to "active on low". (every time you release the button there will be a longpress as it is supposed to be) The combination "switch type" = "push button active low" & "longpress event " = "active on high" does not work at all. |
Did some testing. The longpress event is triggered only if the button type and the longpress event type are matching. eg. Which makes sense.. who needs a longpress event when the button is released. Edit: Which also begs the question.. do we need the longpress event selection? It could be kind of set automatically regarding the switch type leaving it a en/disable option only |
I'm surprised that a Push Button config actually works with a long-press, as the nature of the Push Button, AFAICS, is that it changes state on the push or release of that button. No proper way of having a long-press in that configuration. |
ok, sorry but I see/read a lot of confusion :-) |
if you use a latching push button maybe.. but in the plugin you simulate a latching push button with a non latching one... so it makes sense. unless i am mistaken |
For a push button setup, it makes sense to have a long press. However, I think we need to make things a bit more clear conceptually. When you only want to get an event for longpress or short press, then we must only send out an event when the opposite happens as what the user has configured. "Active Low" typically means the input state is normally "high" and when you press a button the logic level is pulled to GND.
If you really don't want a short-pressed event when a long pressed is intended, then only the 2nd option should be used. |
Hi also to you @TD-er
Totally agree.
Exactly!
It depend. Instead, IF Longpress (or doubleclick) is enabled we MUST take care of the button release in order to understand if we MUST generate the LONGPRESS or DOUBLECLICK event or a simply "normal push" EVENT. |
We can make it as elaborate as you describe. With "elaborate" I mean it either needs lots of options to choose from, or nested options and at least quite some documentation to make it clear what to expect... Or... we can try to make it simple:
The 'release' event should then have 2 event values:
I think this is quite intuitive and flexible at the same time, what do you think? |
Oh and to make sure we won't open another Pandora's box here, I am even thinking about making a separate plugin ID for input and output GPIO. |
Sorry but I dont' like so much events for each state (push, release, etc...) |
That's why I mention the word "Option", so you can enable/disable sending events on either rising or falling edge of the signal. This also makes me think about whether we should keep the "invert" option as it makes things really complex. |
I don´t see why not having just one en/disbable option for longpress and make it like @iz8mbw suggesetd:
And keep the three options for switch type. so inverted or not we get an e.g. always the same longpress event... let´s say |
Well the reason why we should not "just-do-this-or-that" is simply the reason how we ended up in this mess of completely out of control and unmanageble complexity of something as basic as handling a single GPIO pin. We have been 'fighting' this switch plugin for over 6 years already and right now we at least stripped about 10k of compiled binary code away from the switch plugin and split off quite some totally unrelated functionality. And about the added complexity of something as basic as "invert" for the entire plugin... I was already "done" with this complexity of the switch plugin back in 2018 or '19, but we keep on patching it and I think now it is time to just make 2 simple plugins to replace P001-Switch:
This so we can make it work and then if it is working well we just let P001 go (or migrate it using a setting migration) ESP32 does have very nice hardware filtering options which we don't use. It is absolutely too complex for what it needs to do. |
Thanks for the perspective... i only viewed from the input side. |
Would it be an option to leave everythig as it is? |
@TommoT1 Well that's one reason I was thinking about making new plugins for the GPIO interaction. As always, with ESPEasy we aim to make it intuitive and simple for anyone and still allow to do all the advanced stuff for those who are more experienced. |
Yep, for the input plugin adding all supported types of pull-up and -down and also open drain should be added as well as a selector for the various strengths of the pull resistors (ESP32 does have several strengths available) For both input and output you can also define how a pin should react to deep sleep. And for the ESP8266 it is possible to read out a single register and read the pin values of all pins in a single call. For ESP32 you can use RMT to capture some sequence in memory and thus allow for very accurate filtering on debounce or noise filtering. For the ESP32 I need to look into the options for the output plugin as the ESP32 does have some very very nice hardware options to generate extremely timing critical sequences and also combine several pins to lock them. (allowing pins to change state at exactly the same time) I have to look into all of these as some might be more useful outside of these plugins and some might be useful to a lot more plugins and thus need to be part of the ESPEasy internals so those filters/features can be used anywhere a plugin/command may need to interact with a GPIO pin. |
Hi @TD-er |
Hi @TD-er can you work on this? |
Hello.
As I described here I notices that EVENT 10 (the long press event) is always generated also if the press duration of push button is less than what is configured in "Longpress min. interval (ms)".
Example: I have Long press interval set to 600 ms but if I press very fast I have two EVENTs, first one is "1" and just after I have "10".
So, EVENT 10 (longpress) is generated also if I press the push button for a time less than 600 ms.
More, EVENT 0 (or 1) is sent anyway/always just before the EVENT 10 (or 11) during a Lonpress.
In my opinion the Push Button in Switch input should works like this in "chronological" order IF Long press feature is NOT enabled:
since in this case the Long press feature is NOT enabled in the configuration of the "Switch input" we don't care of the button release (or button release time) so to be more fast the EVENT should be generated as soon as possible, so do NOT wait for button release to generate the EVENT 1 (or 0).
Instead IF the Longpress feature is enabled in the configuration of the "Switch input", we MUST take care of the release of the button.
So, IF the button is pressed for a time LESS than Logpress Interval, works like that:
Instead, IF the button is pressed for a time EQUAL or GREATER than Logpress Interval, works like that:
now with Longpress enabled and Push Button pressed for LESS than Logpress Interval it works like that:
How is it now, the Logpress feature is not usable.
Similar Issue without a solution: #2696
Thanks.
The text was updated successfully, but these errors were encountered: