Skip to content
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

pressedFor not true only once #6

Open
JM-FRANCE opened this issue Jan 10, 2024 · 0 comments
Open

pressedFor not true only once #6

JM-FRANCE opened this issue Jan 10, 2024 · 0 comments

Comments

@JM-FRANCE
Copy link

JM-FRANCE commented Jan 10, 2024

the example

if (myInput.pressedFor(500)) {
   // true (once only) if button has been pressed for 500ms
}

does not seem to work. I get repeated output with this code in Wokwi

#include <Toggle.h>                         // https://github.com/Dlloydev/Toggle

Toggle sw;
const unsigned long longPressDelay = 3000ul;

void setup() {
  Serial.begin(115200);
  sw.begin(3);
  Serial.println("READY");
}

void loop() {
  sw.poll();
  if (sw.pressedFor(longPressDelay)) Serial.println("LONG PRESS");
}

is that a wokwi issue ?

what code would let me check for both short and long press on a button? checking for onPress() will not work with pressedFor() apparently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant