From d30c5f46bc2d368357121be570ed6bf62de255a6 Mon Sep 17 00:00:00 2001 From: eshifri <46511024+eshifri@users.noreply.github.com> Date: Sat, 8 Jan 2022 18:24:43 -0800 Subject: [PATCH] feat: Stuck key test for COLORLCD (#1289) * Stuck key test for COLORLCD #1271 * always start with the first button, no matter what this button is. * Add LED error * Move LED_ERROR_END to ensure runs after dlg close Co-authored-by: Peter Feerick --- radio/src/opentx.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index a117d74fe..d3bc7d787 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -726,7 +726,35 @@ void checkAll() #endif #if defined(COLORLCD) - #warning "KEYSTUCK Message Not Yet Implemented" + if (!waitKeysReleased()) { + auto dlg = new FullScreenDialog(WARNING_TYPE_ALERT, STR_KEYSTUCK); + LED_ERROR_BEGIN(); + AUDIO_ERROR_MESSAGE(AU_ERROR); + tmr10ms_t tgtime = get_tmr10ms() + 500; + uint32_t keys = readKeys(); + std::string strKeys(""); + const char STR_VKEYS[] = TR_VKEYS; + const int len = int(LEN_VKEYS[0]); + char s[6]; + s[5] = 0; + for (int i = 0; i < (int)TRM_BASE; i++) { + if (keys & (1 << i)) { + strncpy(s, &STR_VKEYS[i * len], len); + strKeys += s; + } + } + + dlg->setMessage(strKeys.c_str()); + dlg->setCloseCondition([tgtime]() { + if (tgtime >= get_tmr10ms() && keyDown()) { + return false; + } else { + return true; + } + }); + dlg->runForever(); + LED_ERROR_END(); + } #else if (!waitKeysReleased()) { showMessageBox(STR_KEYSTUCK);