From 05bfb71aa6bd5a9d47116fa19dde9b64a0f89d7b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 9 Oct 2020 10:28:17 +0200 Subject: [PATCH] Fix ESP32 GPIO16 init --- tasmota/support_button.ino | 4 ++++ tasmota/support_switch.ino | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tasmota/support_button.ino b/tasmota/support_button.ino index 1e1192605..4dc5aa097 100644 --- a/tasmota/support_button.ino +++ b/tasmota/support_button.ino @@ -87,7 +87,11 @@ void ButtonInit(void) for (uint32_t i = 0; i < MAX_KEYS; i++) { if (PinUsed(GPIO_KEY1, i)) { Button.present++; +#ifdef ESP8266 pinMode(Pin(GPIO_KEY1, i), bitRead(Button.no_pullup_mask, i) ? INPUT : ((16 == Pin(GPIO_KEY1, i)) ? INPUT_PULLDOWN_16 : INPUT_PULLUP)); +#else // ESP32 + pinMode(Pin(GPIO_KEY1, i), bitRead(Button.no_pullup_mask, i) ? INPUT : INPUT_PULLUP); +#endif } #ifdef USE_ADC else if (PinUsed(GPIO_ADC_BUTTON, i) || PinUsed(GPIO_ADC_BUTTON_INV, i)) { diff --git a/tasmota/support_switch.ino b/tasmota/support_switch.ino index 1c0a8e12d..fa31106b7 100644 --- a/tasmota/support_switch.ino +++ b/tasmota/support_switch.ino @@ -202,7 +202,11 @@ void SwitchInit(void) Switch.last_state[i] = 1; // Init global to virtual switch state; if (PinUsed(GPIO_SWT1, i)) { Switch.present++; +#ifdef ESP8266 pinMode(Pin(GPIO_SWT1, i), bitRead(Switch.no_pullup_mask, i) ? INPUT : ((16 == Pin(GPIO_SWT1, i)) ? INPUT_PULLDOWN_16 : INPUT_PULLUP)); +#else // ESP32 + pinMode(Pin(GPIO_SWT1, i), bitRead(Switch.no_pullup_mask, i) ? INPUT : INPUT_PULLUP); +#endif if (ac_detect) { Switch.state[i] = 0x80 + 2 * AC_PERIOD; Switch.last_state[i] = 0; // Will set later in the debouncing code