marcobrianza / ClickButton

A simple button Arduino library to get short and long clicks, multiple clicks (double click, triple click etc.). Click-and-hold is also possible.
63 stars 28 forks source link

Support ESP8266 #4

Closed sabag closed 3 years ago

sabag commented 5 years ago

this library is awesome but it is not working on ESP8266. I was able to very easily fix it to work on ESP8266 by changing the code to :

pinMode(_pin, INPUT_PULLUP);

instead of INPUT.

does this makes sense ? could this be pushed into the master ?

marcobrianza commented 5 years ago

look at this https://github.com/marcobrianza/ClickButton/blob/master/ClickButton.cpp#L111 it already enables pullup in the correct case. I found it to work on ESP8266

sabag commented 5 years ago

ok so its probably something else because i tested it on wemos d1 mini and it did not work.

marcobrianza commented 4 years ago

some pins have external resistor connected to pins, for example try to use D1, D2, D5,D6,D7

cstanke commented 4 years ago

I can confirm that on ESP8266 based hardware with esp8266 Arduino Core 2.6.1, the code, as currently written, does not activate the internal pull-up on pull-up enabled pins.

The following code change works:

  //pinMode(_pin, INPUT);
  // Turn on internal pullup resistor if applicable
  //if (_activeHigh == LOW && internalPullup == CLICKBTN_PULLUP) digitalWrite(_pin,HIGH);
  if (_activeHigh == LOW && internalPullup == CLICKBTN_PULLUP)
    pinMode(_pin, INPUT_PULLUP);
  else
    pinMode(_pin, INPUT);

I've submitted a pull request with supporting documentation on this.

marcobrianza commented 3 years ago

hello, I just merged the pull requests about this issue