From 96ad7ecede9de7eddf7f328bd97abfacf7b07539 Mon Sep 17 00:00:00 2001 From: Stephen Brown Date: Mon, 27 Jun 2022 14:52:06 +0100 Subject: [PATCH] Double click triggered by release instead of keypress --- src/uibuttons.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/uibuttons.cpp b/src/uibuttons.cpp index fd7b676..fe26a2a 100644 --- a/src/uibuttons.cpp +++ b/src/uibuttons.cpp @@ -97,7 +97,7 @@ CUIButton::BtnTrigger CUIButton::ReadTrigger (void) unsigned value = m_pin->Read(); - // TODO: handle long press + // TODO: long press time from config if (m_timer < LONG_PRESS_TIME) { m_timer++; @@ -147,11 +147,6 @@ CUIButton::BtnTrigger CUIButton::ReadTrigger (void) if (m_numClicks < 2) { m_numClicks++; } - if (m_numClicks == 2) { - reset(); - LOGDBG ("Double Click"); - return BtnTriggerDoubleClick; - } } } else @@ -160,7 +155,7 @@ CUIButton::BtnTrigger CUIButton::ReadTrigger (void) // 1 -> 1 : Button is not pressed, was already not pressed } else { - // 0 -> 1 : Button was pressed but is now not pressed + // 0 -> 1 : Button was pressed but is now not pressed (it was released) m_lastValue = 1; m_debounceTimer = 0; LOGDBG ("Up"); @@ -178,6 +173,12 @@ CUIButton::BtnTrigger CUIButton::ReadTrigger (void) LOGDBG ("Click"); return BtnTriggerClick; } + else if (m_numClicks == 2) { + // This is the second release in a short period of time + reset(); + LOGDBG ("Double Click"); + return BtnTriggerDoubleClick; + } } }