Closed AchimPieters closed 5 years ago
I will look into it. When I wrote it more than a year ago it worked perfectly for me, but I've been getting reports about long press trigger before. Some people even stripped long press functionality from some button library copies (e.g. in sonoff_basic example). I'm certainly interested in keeping full functionality, so I will look into fixing it and extracting as a separate library (to finally stop it being copy-pasted everywhere).
Ok, I have figured that out. You're using button in "active low" configuration (meaning signal goes low when button is pressed). Original button example was written for "active high" and thus everything is inverted in your case and you get long presses all the time.
You can fix it by changing this line to
if (gpio_read(button->gpio_num) == 0) {
I have extracted button code into a separate library which allows configuring which active mode your button uses: esp-button.
PS you do not need pullup resistors on buttons (shown on your wiring diagram), it will use built-in pullup resistors.
Awesome :bangbang: you are the 👍
I have a look into it tomorrow!
Hi Maxim,
I have I little problem with your button demo.
My hardware is build like this:
unfortunately I can't get it to work properly, because when I push the button I says long press or sometimes double press.
I tried changing the button.c part:
to other milliseconds, but not with the right results. can you help me?