From 551ff1df7b45c41ec12986abb925c60cedfcfa26 Mon Sep 17 00:00:00 2001 From: Daniel Cao Date: Fri, 8 Nov 2024 15:01:49 +0800 Subject: [PATCH] rak10701 * Improve the processing speed of virtual keyboards * Remove the disable GPS feature, as it would interfere with the normal use of TFT * Changed the default screen sleep time to 30s --- src/ButtonThread.cpp | 2 ++ src/input/TouchScreenBase.cpp | 24 ++++++++++++++++++++++++ src/mesh/NodeDB.cpp | 2 +- src/modules/CannedMessageModule.cpp | 14 +++++++++++++- src/modules/CannedMessageModule.h | 6 ++++++ 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index 0ea1309cc..22212cdc8 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -165,6 +165,7 @@ int32_t ButtonThread::runOnce() LOG_BUTTON("Mulitipress! %hux", multipressClickCount); switch (multipressClickCount) { #if HAS_GPS +#ifndef RAK14014 //The power supply of the GPS of RAK14014 cannot be turned off. Once turned off, the screen will not be used,They are the same power source // 3 clicks: toggle GPS case 3: if (!config.device.disable_triple_click && (gps != nullptr)) { @@ -173,6 +174,7 @@ int32_t ButtonThread::runOnce() screen->forceDisplay(true); // Force a new UI frame, then force an EInk update } break; +#endif #endif #if defined(USE_EINK) && defined(PIN_EINK_EN) // i.e. T-Echo // 4 clicks: toggle backlight diff --git a/src/input/TouchScreenBase.cpp b/src/input/TouchScreenBase.cpp index 03618b338..c6ad9babc 100644 --- a/src/input/TouchScreenBase.cpp +++ b/src/input/TouchScreenBase.cpp @@ -1,6 +1,10 @@ #include "TouchScreenBase.h" #include "main.h" +#if defined(RAK14014) && !defined(MESHTASTIC_EXCLUDE_CANNEDMESSAGES) +#include "modules/CannedMessageModule.h" +#endif + #ifndef TIME_LONG_PRESS #define TIME_LONG_PRESS 400 #endif @@ -102,12 +106,32 @@ int32_t TouchScreenBase::runOnce() } _touchedOld = touched; +#if defined RAK14014 + // Speed up the processing speed of the keyboard in virtual keyboard mode + auto state = cannedMessageModule->getRunState(); + if ( state == CANNED_MESSAGE_RUN_STATE_FREETEXT ) { + if(_tapped) + { + _tapped = false; + e.touchEvent = static_cast(TOUCH_ACTION_TAP); + LOG_DEBUG("action TAP(%d/%d)\n", _last_x, _last_y); + } + } else + { + if (_tapped && (time_t(millis()) - _start) > TIME_LONG_PRESS - 50) { + _tapped = false; + e.touchEvent = static_cast(TOUCH_ACTION_TAP); + LOG_DEBUG("action TAP(%d/%d)\n", _last_x, _last_y); + } + } +#else // fire TAP event when no 2nd tap occured within time if (_tapped && (time_t(millis()) - _start) > TIME_LONG_PRESS - 50) { _tapped = false; e.touchEvent = static_cast(TOUCH_ACTION_TAP); LOG_DEBUG("action TAP(%d/%d)", _last_x, _last_y); } +#endif // fire LONG_PRESS event without the need for release if (touched && (time_t(millis()) - _start) > TIME_LONG_PRESS) { diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index bb5a09eaa..9b891f866 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -473,7 +473,7 @@ void NodeDB::initConfigIntervals() config.display.screen_on_secs = default_screen_on_secs; -#if defined(T_WATCH_S3) || defined(T_DECK) +#if defined(T_WATCH_S3) || defined(T_DECK) || defined(RAK14014) config.power.is_power_saving = true; config.display.screen_on_secs = 30; config.power.wait_bluetooth_secs = 30; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index bb3a314a2..83f6b7fd6 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -325,7 +325,9 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) this->shift = !this->shift; } else if (keyTapped == "⌫") { + #ifndef RAK14014 this->highlight = keyTapped[0]; + #endif this->payload = 0x08; @@ -341,8 +343,10 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) validEvent = true; } else if (keyTapped == " ") { + #ifndef RAK14014 this->highlight = keyTapped[0]; - + #endif + this->payload = keyTapped[0]; validEvent = true; @@ -361,7 +365,9 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) this->shift = false; } else if (keyTapped != "") { + #ifndef RAK14014 this->highlight = keyTapped[0]; + #endif this->payload = this->shift ? keyTapped[0] : std::tolower(keyTapped[0]); @@ -830,6 +836,12 @@ void CannedMessageModule::drawKeyboard(OLEDDisplay *display, OLEDDisplayUiState Letter updatedLetter = {letter.character, letter.width, xOffset, yOffset, cellWidth, cellHeight}; +#ifdef RAK14014 //Optimize the touch range of the virtual keyboard in the bottom row + if(outerIndex == outerSize - 1) + { + updatedLetter.rectHeight = 240 - yOffset; + } +#endif this->keyboard[this->charSet][outerIndex][innerIndex] = updatedLetter; float characterOffset = ((cellWidth / 2) - (letter.width / 2)); diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index e9dc2bda0..5d02daf57 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -68,6 +68,12 @@ class CannedMessageModule : public SinglePortModule, public Observable