From a4af85ef370caca612c37f2b1d1738b10dda5eb9 Mon Sep 17 00:00:00 2001 From: eshifri <46511024+eshifri@users.noreply.github.com> Date: Fri, 24 Sep 2021 18:42:52 -0700 Subject: [PATCH] Fix module and trainer subform resizing and show NV14 RF module version (#800) * Fixes #792 * Add RF module FW version * Clean(er) implementation * Whitespace changes cleanup * Cleanup * Trainer module fix Co-authored-by: Peter Feerick --- radio/src/gui/colorlcd/model_setup.cpp | 41 ++++++++++++++---------- radio/src/gui/colorlcd/radio_version.cpp | 9 ++++-- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 9d499ddef..dcc6bab5e 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -669,12 +669,13 @@ class TrainerModuleWindow : public FormGroup GET_SET_DEFAULT(g_model.trainerData.pulsePol)); grid.nextLine(); } - -#if defined(HARDWARE_TOUCH) - new StaticText(this, grid.getLabelSlot(true)); -#endif - getParent()->moveWindowsTop(top() + 1, adjustHeight()); } +#if defined(HARDWARE_TOUCH) + new StaticText(this, grid.getLabelSlot(true)); +#endif + auto par = getParent(); + par->moveWindowsTop(top() + 1, adjustHeight()); + par->adjustInnerHeight(); } protected: @@ -789,18 +790,22 @@ class ModuleWindow : public FormGroup { clear(); // Module Type - new StaticText(this, grid.getLabelSlot(true), STR_MODE, 0, COLOR_THEME_PRIMARY1); - moduleChoice = new Choice(this, grid.getFieldSlot(2, 0), STR_INTERNAL_MODULE_PROTOCOLS, - MODULE_TYPE_NONE, MODULE_TYPE_COUNT - 1, - GET_DEFAULT(g_model.moduleData[moduleIdx].type), - [=](int32_t newValue) { - setModuleType(moduleIdx, newValue); - update(); - moduleChoice->setFocus(SET_FOCUS_DEFAULT); - SET_DIRTY(); - }); + new StaticText(this, grid.getLabelSlot(true), STR_MODE, 0, + COLOR_THEME_PRIMARY1); + moduleChoice = new Choice( + this, grid.getFieldSlot(2, 0), STR_INTERNAL_MODULE_PROTOCOLS, + MODULE_TYPE_NONE, MODULE_TYPE_COUNT - 1, + GET_DEFAULT(g_model.moduleData[moduleIdx].type), + [=](int32_t newValue) { + setModuleType(moduleIdx, newValue); + update(); + moduleChoice->setFocus(SET_FOCUS_DEFAULT); + SET_DIRTY(); + }); moduleChoice->setAvailableHandler([=](int8_t moduleType) { - return moduleIdx == INTERNAL_MODULE ? isInternalModuleAvailable(moduleType) : isExternalModuleAvailable(moduleType); + return moduleIdx == INTERNAL_MODULE + ? isInternalModuleAvailable(moduleType) + : isExternalModuleAvailable(moduleType); }); // Module parameters @@ -1392,7 +1397,9 @@ class ModuleWindow : public FormGroup { grid.nextLine(); } - getParent()->moveWindowsTop(top() + 1, adjustHeight()); + auto par = getParent(); + par->moveWindowsTop(top() + 1, adjustHeight()); + par->adjustInnerHeight(); } void checkEvents() override diff --git a/radio/src/gui/colorlcd/radio_version.cpp b/radio/src/gui/colorlcd/radio_version.cpp index b4540e815..67c02945e 100644 --- a/radio/src/gui/colorlcd/radio_version.cpp +++ b/radio/src/gui/colorlcd/radio_version.cpp @@ -205,6 +205,7 @@ RadioVersionPage::RadioVersionPage(): { } +extern uint32_t NV14internalModuleFwVersion; void RadioVersionPage::build(FormWindow * window) { FormGridLayout grid; @@ -236,8 +237,12 @@ void RadioVersionPage::build(FormWindow * window) auto options = new OptionsText(window, grid.getFieldSlot(1,0)); grid.nextLine(options->height() + 4); - //TODO: NV14 internal module version (NV14internalModuleFwVersion) - +#if defined(AFHDS2) + new StaticText(window, grid.getLabelSlot(), "RF FW:"); + sprintf(reusableBuffer.moduleSetup.msg, "%d.%d.%d", (int)((NV14internalModuleFwVersion >> 16) & 0xFF), (int)((NV14internalModuleFwVersion >> 8) & 0xFF), (int)(NV14internalModuleFwVersion & 0xFF)); + new StaticText(window, grid.getFieldSlot(), reusableBuffer.moduleSetup.msg); + grid.nextLine(); +#endif #if defined(PXX2) // Module and receivers versions auto moduleVersions = new TextButton(window, grid.getLineSlot(), STR_MODULES_RX_VERSION);