diff --git a/radio/src/lua/lua_widget.cpp b/radio/src/lua/lua_widget.cpp index f8d923510..dd99bfee9 100644 --- a/radio/src/lua/lua_widget.cpp +++ b/radio/src/lua/lua_widget.cpp @@ -30,6 +30,9 @@ #define MAX_INSTRUCTIONS (20000/100) #if defined(HARDWARE_TOUCH) +uint32_t LuaEventHandler::downTime = 0; +uint32_t LuaEventHandler::tapTime = 0; +uint32_t LuaEventHandler::tapCount = 0; tmr10ms_t LuaEventHandler::swipeTimeOut = 0; coord_t LuaEventHandler::_startX; coord_t LuaEventHandler::_startY; @@ -108,6 +111,21 @@ void LuaEventHandler::event_cb(lv_event_t* e) _startX = rel_pos.x; _startY = rel_pos.y; + + downTime = RTOS_GET_MS(); + } + } else if (code == LV_EVENT_RELEASED) { + // tap count handling + uint32_t now = RTOS_GET_MS(); + if (now - downTime <= LUA_TAP_TIME) { + if (now - tapTime > LUA_TAP_TIME) { + tapCount = 1; + } else { + tapCount++; + } + tapTime = now; + } else { + tapCount = 0; } } #endif @@ -126,10 +144,16 @@ void LuaEventHandler::onClicked() LuaEventData* es = luaGetEventSlot(); if (!es) return; - es->event = EVT_TOUCH_TAP; + if (tapCount > 0) { + es->event = EVT_TOUCH_TAP; + es->tapCount = tapCount; + } else { + es->event = EVT_TOUCH_BREAK; + } + es->touchX = point_act.x; es->touchY = point_act.y; - es->tapCount = 1; + _sliding = false; return; } diff --git a/radio/src/lua/lua_widget.h b/radio/src/lua/lua_widget.h index e5e54026c..b9786ff86 100644 --- a/radio/src/lua/lua_widget.h +++ b/radio/src/lua/lua_widget.h @@ -27,9 +27,16 @@ #include "opentx_types.h" +#define LUA_TAP_TIME 250 // 250 ms + class LuaEventHandler { #if defined(HARDWARE_TOUCH) + // "tap" handling + static uint32_t downTime; + static uint32_t tapTime; + static uint32_t tapCount; + // "swipe" / "slide" handling static tmr10ms_t swipeTimeOut; static bool _sliding; static coord_t _startX;