From 5ce9025401c1eec462ec3a69343efa6d240421c9 Mon Sep 17 00:00:00 2001 From: Darsh Patel Date: Sat, 28 Apr 2018 01:24:31 +0530 Subject: [PATCH 1/2] Fixed multiple toggles due to repeated code some remotes repeat the code within 200ms thus toggling the relay twice , this fixes the toggle function. --- code/espurna/ir.ino | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/espurna/ir.ino b/code/espurna/ir.ino index 93d75878..5cadae7e 100644 --- a/code/espurna/ir.ino +++ b/code/espurna/ir.ino @@ -14,7 +14,7 @@ Copyright (C) 2017-2018 by François Déchery IRrecv * _ir_recv; decode_results _ir_results; - +unsigned long last = millis(); // ----------------------------------------------------------------------------- // PRIVATE // ----------------------------------------------------------------------------- @@ -43,7 +43,12 @@ void _irProcessCode(unsigned long code) { relayStatus(0, button_value); } if (button_mode == IR_BUTTON_MODE_TOGGLE) { + if (millis() - last > 250){ relayToggle(button_value); + } + else{ + DEBUG_MSG_P(PSTR("[IR] Ignoring repeated code\n")); + } } #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE From 01bd5dad04883c96d816086fcad6f34fd1ff5d59 Mon Sep 17 00:00:00 2001 From: Darsh Patel Date: Sun, 29 Apr 2018 18:57:09 +0530 Subject: [PATCH 2/2] fix requested changes used tabs instead of spaces, change variable name to the one which is more uniform across the project, fixed bug about condition always being true --- code/espurna/ir.ino | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/espurna/ir.ino b/code/espurna/ir.ino index 5cadae7e..5a197417 100644 --- a/code/espurna/ir.ino +++ b/code/espurna/ir.ino @@ -14,7 +14,7 @@ Copyright (C) 2017-2018 by François Déchery IRrecv * _ir_recv; decode_results _ir_results; -unsigned long last = millis(); +unsigned long _ir_last = millis(); // ----------------------------------------------------------------------------- // PRIVATE // ----------------------------------------------------------------------------- @@ -43,11 +43,12 @@ void _irProcessCode(unsigned long code) { relayStatus(0, button_value); } if (button_mode == IR_BUTTON_MODE_TOGGLE) { - if (millis() - last > 250){ - relayToggle(button_value); + if (millis() - _ir_last > 250){ + relayToggle(button_value); + _ir_last = millis(); } else{ - DEBUG_MSG_P(PSTR("[IR] Ignoring repeated code\n")); + DEBUG_MSG_P(PSTR("[IR] Ignoring repeated code\n")); } } #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE