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

Button can't handle more than one same function #2

Open
Nezaemmy opened this issue Feb 12, 2025 · 1 comment
Open

Button can't handle more than one same function #2

Nezaemmy opened this issue Feb 12, 2025 · 1 comment

Comments

@Nezaemmy
Copy link

Thank you so much for this library.
I'm using esp32 board when I tried to run this code, it couldn't handle btn.isHeld()==2 always perform btn.isHeld()==1

#include "EMFButton.h"

EMFButton btn (3, HIGH_P);

void setup() {
  Serial.begin(9600);
}

void loop() {
  btn.tick();

  if (btn.isHeld()==1)
    Serial.println(" ONE");
  
  if (btn.isHeld()==2)
    Serial.println("TWO");
  
  if (btn.hasClicks() ==3)
    Serial.println("THREE");
}

Second question, if we use HIGH_P, does it mean only INPUT or INPUT_PULLUP?

@St3p40
Copy link
Owner

St3p40 commented Feb 12, 2025

Hello
Thank you for using my library

isHeld function just lets us know if button was pressed more than n milliseconds and it is bool value. For getting clicks amount after pressing button for n milliseconds(just clicks + long pressing) you need to use hasClicksWithHeld function.

HIGH_P sets INPUT_PULLUP

Let me know if there are mistakes in library's code

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

2 participants