From f10f3d530595a99286ebcb088559507c58e28f56 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 4 Aug 2025 10:15:59 +0200 Subject: [PATCH] esp32: some pins have no internal pullup --- lib/PButton/PButon.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/PButton/PButon.cpp b/lib/PButton/PButon.cpp index 00c9c7058..8324b7728 100644 --- a/lib/PButton/PButon.cpp +++ b/lib/PButton/PButon.cpp @@ -54,7 +54,15 @@ bool PButton::init(uint8_t pin, bool pullMode) { pullMode_ = pullMode; // 1=HIGH (pullup) 0=LOW (pulldown) #if defined(ESP32) +#if CONFIG_IDF_TARGET_ESP32 + if (pin_ == 34 || pin_ == 35 || pin_ == 36 || pin_ == 39) { + pinMode(pin_, INPUT); + } else { + pinMode(pin_, pullMode ? INPUT_PULLUP : INPUT_PULLDOWN); + } +#else pinMode(pin_, pullMode ? INPUT_PULLUP : INPUT_PULLDOWN); +#endif #else // esp8266 and standalone pinMode(pin_, pullMode ? INPUT_PULLUP : INPUT); #endif @@ -93,7 +101,15 @@ bool PButton::check(void) { // make sure the pin is still input #if defined(ESP32) +#if CONFIG_IDF_TARGET_ESP32 + if (pin_ == 34 || pin_ == 35 || pin_ == 36 || pin_ == 39) { + pinMode(pin_, INPUT); + } else { + pinMode(pin_, pullMode_ ? INPUT_PULLUP : INPUT_PULLDOWN); + } +#else pinMode(pin_, pullMode_ ? INPUT_PULLUP : INPUT_PULLDOWN); +#endif #else // esp8266 and standalone pinMode(pin_, pullMode_ ? INPUT_PULLUP : INPUT); #endif