From 97e884a4b78c8e285547565cc27cae6d2eed4d99 Mon Sep 17 00:00:00 2001 From: Bastian Neumann Date: Mon, 24 Apr 2017 18:30:08 +0200 Subject: [PATCH] DeboundeEvent 2.0.0 has breaking changes Version 2.0.0 of the DebounceEvent library has breaking changes. This fixes the changes --- esp8266/sonoffsc/button.ino | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/esp8266/sonoffsc/button.ino b/esp8266/sonoffsc/button.ino index 6f8a6db..76821f6 100644 --- a/esp8266/sonoffsc/button.ino +++ b/esp8266/sonoffsc/button.ino @@ -19,12 +19,18 @@ void buttonSetup() { void buttonLoop() { - if (_button.loop()) { - uint8_t event = _button.getEvent(); - DEBUG_MSG("[BUTTON] Button pressed. Event: %d\n", event); - if (event == EVENT_DOUBLE_CLICK) createAP(); - if (event == EVENT_LONG_CLICK) ESP.reset(); - //if (event == EVENT_SINGLE_CLICK) relayToggle(i); + if (uint8_t event = _button.loop()) { + + if (event == EVENT_RELEASED) { + DEBUG_MSG("[BUTTON] Button pressed. Event: %d Length:%d\n", _button.getEventCount(), _button.getEventLength()); + if(_button.getEventCount() == 1) + //relayToggle(i); + if(_button.getEventCount() >= 2) + createAP(); + if(_button.getEventLength() >= 3000) + ESP.reset(); + } + } }