From f8357be8878b2218f4605f7194a523dd12f2cae1 Mon Sep 17 00:00:00 2001 From: Tony Cake Date: Fri, 17 Dec 2021 00:38:19 +0100 Subject: [PATCH] [ghost] Fix `RTN` behavior on Ghost config menus (#1261) * Fix menu back behavior in the Ghost menu When backing out of a ghost sub-menu one level, don't close the module menu unless already in the root menu. * Fix formatting --- .../gui/colorlcd/radio_ghost_module_config.cpp | 18 ++++++++++++++++-- .../gui/colorlcd/radio_ghost_module_config.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/colorlcd/radio_ghost_module_config.cpp b/radio/src/gui/colorlcd/radio_ghost_module_config.cpp index f5a835452..0fc095160 100644 --- a/radio/src/gui/colorlcd/radio_ghost_module_config.cpp +++ b/radio/src/gui/colorlcd/radio_ghost_module_config.cpp @@ -134,10 +134,24 @@ void RadioGhostModuleConfig::onEvent(event_t event) reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_CLOSE; moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL; RTOS_WAIT_MS(10); - deleteLater(); + Page::onEvent(event); break; } - Page::onEvent(event); +} + +void RadioGhostModuleConfig::checkEvents() +{ + Page::checkEvents(); + + if (reusableBuffer.ghostMenu.menuStatus == GHST_MENU_STATUS_UNOPENED) { // Handles situation where module is plugged after tools start + reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE; + reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_OPEN; + moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL; + } + else if (reusableBuffer.ghostMenu.menuStatus == GHST_MENU_STATUS_CLOSING) { + RTOS_WAIT_MS(10); + deleteLater(); + } } #endif diff --git a/radio/src/gui/colorlcd/radio_ghost_module_config.h b/radio/src/gui/colorlcd/radio_ghost_module_config.h index 5a5264615..42f209052 100644 --- a/radio/src/gui/colorlcd/radio_ghost_module_config.h +++ b/radio/src/gui/colorlcd/radio_ghost_module_config.h @@ -30,6 +30,7 @@ class RadioGhostModuleConfig: public Page #if defined(HARDWARE_KEYS) void onEvent(event_t event) override; + void checkEvents(); #endif protected: