From e1d903eab39bedaf9b76cccca8eda9e8946c1ddc Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 6 Jan 2019 18:50:56 +0100 Subject: [PATCH] Add no pull-up control to Shelly 2 Add no pull-up control to Shelly 2 module (default is pull-up, change GPIO2 to Switch3n for no pull-up) (#4841) --- sonoff/_changelog.ino | 1 + sonoff/sonoff.ino | 3 ++- sonoff/sonoff_template.h | 4 ++-- sonoff/support_switch.ino | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 6076bcff0..269408383 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,6 +1,7 @@ /* 6.4.1.7 20190106 * Fix HLW8012, HJL01 and BL0937 based energy sensors low Power (below 10W) measurement regression from 6.4.1.6 * Add relay status functionality to LED2 when configured leaving LED1 for (wifi/mqtt) status indication + * Add no pull-up control to Shelly 2 module (default is pull-up, change GPIO2 to Switch3n for no pull-up) (#4841) * * 6.4.1.6 20190105 * Add commands PowerCal, VoltageCal and CurrentCal for HLW8012, HJL01 and BL0937 based energy sensors diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 0974c47e7..16205b458 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1775,7 +1775,8 @@ void ButtonHandler(void) } } else { if (pin[GPIO_KEY1 +button_index] < 99) { - if (!((uptime < 4) && (0 == pin[GPIO_KEY1 +button_index]))) { // Block GPIO0 for 4 seconds after poweron to workaround Wemos D1 RTS circuit +// if (!((uptime < 4) && (0 == pin[GPIO_KEY1 +button_index]))) { // Block GPIO0 for 4 seconds after poweron to workaround Wemos D1 RTS circuit + if (uptime > 3) { // Block GPIO for 4 seconds after poweron to workaround Wemos D1 / Obi RTS circuit button_present = 1; button = digitalRead(pin[GPIO_KEY1 +button_index]); } diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 943e7548e..b5e47d745 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -1367,7 +1367,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { { "Shelly 2", // Shelly2 (ESP8266 - 2MB) - https://shelly.cloud/shelly2/ 0, GPIO_TXD, // GPIO01 MCP39F501 Serial input - 0, + GPIO_USER, // GPIO02 Decide if we use (no) pull-up GPIO_RXD, // GPIO03 MCP39F501 Serial output GPIO_REL1, // GPIO04 GPIO_REL2, // GPIO05 @@ -1378,7 +1378,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { 0, // GPIO10 (SD_DATA3 Flash QIO or ESP8285) // GPIO11 (SD_CMD Flash) GPIO_SWT1, // GPIO12 - 0, + 0, // GPIO13 GPIO_SWT2, // GPIO14 0, // GPIO15 MCP39F501 Reset 0, 0 diff --git a/sonoff/support_switch.ino b/sonoff/support_switch.ino index 444ba9475..cc32eb0bb 100644 --- a/sonoff/support_switch.ino +++ b/sonoff/support_switch.ino @@ -110,6 +110,10 @@ void SwitchProbe(void) void SwitchInit(void) { + if (SHELLY2 == Settings.module) { + if (switch_no_pullup > 0) { switch_no_pullup = 0xffff; } // If any switch is no pull-up make them all no pull-up + } + switches_found = 0; for (byte i = 0; i < MAX_SWITCHES; i++) { lastwallswitch[i] = 1; // Init global to virtual switch state;