button should always be input

This commit is contained in:
MichaelDvP
2024-02-03 14:58:49 +01:00
parent 9573c4ed94
commit 38e08be752

View File

@@ -91,6 +91,12 @@ bool PButton::check(void) {
int resultEvent = 0;
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_;
// Button pressed down