From 09dcb93489a3605e05a12dee1b88a0fac5de116c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 9 Jun 2019 17:54:13 +0200 Subject: [PATCH] Fix Toggle functionality to button double press when one button and two devices are detected Fix Toggle functionality to button double press when one button and two devices are detected (#5935) --- sonoff/_changelog.ino | 1 + sonoff/support_button.ino | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index c78cddc9b..e77bae119 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -6,6 +6,7 @@ * Add command SetOption65 0/1 and more Tuya Serial based device support (#5815) * Fix include of my_user_config.h in sonoff_aws_iot.cpp (#5930) * Fix exception 9 when syslog is enabled and NTP is just synced (#5917) + * Fix Toggle functionality to button double press when one button and two devices are detected (#5935) * * 6.5.0.14 20190602 * Change webserver HTML input, button, textarea, and select name based on id diff --git a/sonoff/support_button.ino b/sonoff/support_button.ino index 53d91da48..3343a54c2 100644 --- a/sonoff/support_button.ino +++ b/sonoff/support_button.ino @@ -218,11 +218,13 @@ void ButtonHandler(void) if ((SONOFF_DUAL_R2 == my_module_type) || (SONOFF_DUAL == my_module_type) || (CH4 == my_module_type)) { single_press = true; } else { - if ((0 == button_index) && (1 == buttons_present)) { // Single Button1 only - single_press = (Settings.flag.button_swap +1 == multipress[button_index]); // SetOption11 (0) - if (Settings.flag.button_swap) { // SetOption11 (0) + single_press = (Settings.flag.button_swap +1 == multipress[button_index]); // SetOption11 (0) + if ((1 == buttons_present) && (2 == devices_present)) { // Single Button with two devices only + if (Settings.flag.button_swap) { // SetOption11 (0) multipress[button_index] = (single_press) ? 1 : 2; } + } else { + multipress[button_index] = 1; } } }