mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
button should always be input
This commit is contained in:
@@ -55,7 +55,7 @@ bool PButton::init(uint8_t pin, bool pullMode) {
|
|||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
pinMode(pin_, pullMode ? INPUT_PULLUP : INPUT_PULLDOWN);
|
pinMode(pin_, pullMode ? INPUT_PULLUP : INPUT_PULLDOWN);
|
||||||
#else // esp8266 and standalone
|
#else // esp8266 and standalone
|
||||||
pinMode(pin_, pullMode ? INPUT_PULLUP : INPUT);
|
pinMode(pin_, pullMode ? INPUT_PULLUP : INPUT);
|
||||||
#endif
|
#endif
|
||||||
enabled_ = (digitalRead(pin_) == pullMode); // see if a button is connected
|
enabled_ = (digitalRead(pin_) == pullMode); // see if a button is connected
|
||||||
@@ -91,6 +91,12 @@ bool PButton::check(void) {
|
|||||||
int resultEvent = 0;
|
int resultEvent = 0;
|
||||||
long millisRes = millis();
|
long millisRes = millis();
|
||||||
|
|
||||||
|
// make sure the pin is still input
|
||||||
|
#if defined(ESP32)
|
||||||
|
pinMode(pin_, pullMode_ ? INPUT_PULLUP : INPUT_PULLDOWN);
|
||||||
|
#else // esp8266 and standalone
|
||||||
|
pinMode(pin_, pullMode_ ? INPUT_PULLUP : INPUT);
|
||||||
|
#endif
|
||||||
state_ = digitalRead(pin_) == pullMode_;
|
state_ = digitalRead(pin_) == pullMode_;
|
||||||
|
|
||||||
// Button pressed down
|
// Button pressed down
|
||||||
|
|||||||
Reference in New Issue
Block a user