Skip to content

pressedFor not true only once #6

Description

@JM-FRANCE

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions