[x] Have you tried using the latest version of the library?
[x] Have you checked this has not already been submitted and/or resolved?
[x] If you are requesting help a better choice may be the Arduino forum
Subject of the issue
I am unable to get a long press event to fire.
Your Environment
Library Version: 2.1.0
Arduino IDE version: 1.8.13
Hardware model/type: ESP8266
OS and Version: Windows 10
Steps to Reproduce
Using a momentary-on switch wired like this, I've been able to get a single press response and a double press response, but not a long press response.
Expected Behaviour
When I press and hold the button, after I let go, a long press response should have been received.
Actual Behaviour
If I press and hold the button, I receive a single press response while the button is still held down. I do not ever get a long press response.
Code Demonstrating the Issue
I'm running the code block before. On the button, I will do a single press, then a double press, then press and hold for long press and paste the Serial Monitor output.
#include <MD_UISwitch.h>
#define BUTTON_PIN 14 // GPIO Pin
MD_UISwitch_Digital Button(BUTTON_PIN, HIGH);
void setup() {
Serial.begin(115200);
Button.begin();
Button.enableDoublePress(true);
Button.enableLongPress(true);
Button.enableRepeatResult(true);
}
void loop() {
MD_UISwitch::keyResult_t k = Button.read();
switch(k) {
case MD_UISwitch::KEY_UP: Serial.print("\nKEY_UP "); break;
case MD_UISwitch::KEY_DOWN: Serial.print("\n\nKEY_DOWN "); break;
case MD_UISwitch::KEY_PRESS:
Serial.print("Single press");
Serial.println("\n");
break;
case MD_UISwitch::KEY_DPRESS:
Serial.print("Double press");
Serial.println("\n");
break;
case MD_UISwitch::KEY_LONGPRESS:
Serial.print("Long press");
Serial.println("\n");
break;
}
}
The Serial Monitor reads:
KEY_DOWN
KEY_UP Single press
KEY_DOWN
KEY_UP
KEY_DOWN
KEY_UP Double press
KEY_DOWN Single press
KEY_UP
Thanks
I really appreciate the library and you taking the time to address the issue. I'm pretty new at this Arduino stuff, and the project I'm working on is the first C++ I've ever written. If it's user error, I humbly apologize for wasting your time!
IMPORTANT
Before submitting this issue
Subject of the issue
I am unable to get a long press event to fire.
Your Environment
Library Version: 2.1.0 Arduino IDE version: 1.8.13 Hardware model/type: ESP8266 OS and Version: Windows 10
Steps to Reproduce
Using a momentary-on switch wired like this, I've been able to get a single press response and a double press response, but not a long press response.
Expected Behaviour
When I press and hold the button, after I let go, a long press response should have been received.
Actual Behaviour
If I press and hold the button, I receive a single press response while the button is still held down. I do not ever get a long press response.
Code Demonstrating the Issue
I'm running the code block before. On the button, I will do a single press, then a double press, then press and hold for long press and paste the Serial Monitor output.
The Serial Monitor reads:
Thanks
I really appreciate the library and you taking the time to address the issue. I'm pretty new at this Arduino stuff, and the project I'm working on is the first C++ I've ever written. If it's user error, I humbly apologize for wasting your time!