From e70826928e26d3f9bb6aff428ca2f016c475e6b6 Mon Sep 17 00:00:00 2001 From: philmoz Date: Fri, 17 Oct 2025 15:36:36 +1100 Subject: [PATCH] fix(color): input curve preview not updating when 'Side' value changed (#6675) --- radio/src/gui/colorlcd/CMakeLists.txt | 1 - radio/src/gui/colorlcd/model/input_edit.cpp | 70 +++++++++++++++- radio/src/gui/colorlcd/model/input_edit.h | 5 ++ .../src/gui/colorlcd/model/input_edit_adv.cpp | 79 ------------------- radio/src/gui/colorlcd/model/input_edit_adv.h | 33 -------- 5 files changed, 73 insertions(+), 115 deletions(-) delete mode 100644 radio/src/gui/colorlcd/model/input_edit_adv.cpp delete mode 100644 radio/src/gui/colorlcd/model/input_edit_adv.h diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index a5eeea080..b6e68e134 100644 --- a/radio/src/gui/colorlcd/CMakeLists.txt +++ b/radio/src/gui/colorlcd/CMakeLists.txt @@ -57,7 +57,6 @@ set(GUI_SRC startup_shutdown.cpp model/curveedit.cpp - model/input_edit_adv.cpp model/input_edit.cpp model/mixer_edit_adv.cpp model/mixer_edit.cpp diff --git a/radio/src/gui/colorlcd/model/input_edit.cpp b/radio/src/gui/colorlcd/model/input_edit.cpp index 2e5be9225..39058cb68 100644 --- a/radio/src/gui/colorlcd/model/input_edit.cpp +++ b/radio/src/gui/colorlcd/model/input_edit.cpp @@ -25,11 +25,11 @@ #include "curveedit.h" #include "gvar_numberedit.h" #include "source_numberedit.h" -#include "input_edit_adv.h" #include "input_source.h" #include "edgetx.h" #include "etx_lv_theme.h" #include "switchchoice.h" +#include "fm_matrix.h" #define SET_DIRTY() storageDirty(EE_MODEL) @@ -171,12 +171,68 @@ void InputEditWindow::buildBody(Window* form) line->padAll(PAD_LARGE); auto btn = new TextButton(line, rect_t{}, LV_SYMBOL_SETTINGS, [=]() -> uint8_t { - new InputEditAdvanced(this->input, index); + showAdvanced(); return 0; }); lv_obj_set_width(btn->getLvObj(), lv_pct(100)); } +void InputEditWindow::showAdvanced() +{ + if (!advWindow) { + advWindow = new Window(this, + {0, EdgeTxStyles::MENU_HEADER_HEIGHT, LCD_W, LCD_H - EdgeTxStyles::MENU_HEADER_HEIGHT}); + advWindow->setWindowFlag(NO_FOCUS); + advWindow->padAll(PAD_SMALL); + + etx_solid_bg(advWindow->getLvObj()); + + FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY); + advWindow->setFlexLayout(); + advWindow->setHeight(LCD_H - EdgeTxStyles::MENU_HEADER_HEIGHT); + + ExpoData* input = expoAddress(index); + + // Side + auto line = advWindow->newLine(grid); + new StaticText(line, rect_t{}, STR_SIDE); + new Choice( + line, rect_t{}, STR_VCURVEFUNC, 1, 3, + [=]() -> int16_t { return 4 - input->mode; }, + [=](int16_t newValue) { + input->mode = 4 - newValue; + updatePreview = true; + SET_DIRTY(); + }); + + // Trim + line = advWindow->newLine(grid); + new StaticText(line, rect_t{}, STR_TRIM); + const auto trimLast = TRIM_OFF + keysGetMaxTrims() - 1; + auto c = new Choice(line, rect_t{}, -TRIM_OFF, trimLast, + GET_VALUE(-input->trimSource), + SET_VALUE(input->trimSource, -newValue)); + + uint16_t srcRaw = input->srcRaw; + c->setAvailableHandler([=](int value) { + return value != TRIM_ON || srcRaw <= MIXSRC_LAST_STICK; + }); + c->setTextHandler([=](int value) -> std::string { + return getTrimSourceLabel(srcRaw, -value); + }); + + // Flight modes + if (modelFMEnabled()) { + line = advWindow->newLine(grid); + new StaticText(line, rect_t{}, STR_FLMODE); + new FMMatrix(line, rect_t{}, input); + } + } + + advWindow->show(); + advEdit = true; +} + void InputEditWindow::checkEvents() { ExpoData* input = expoAddress(index); @@ -239,3 +295,13 @@ void InputEditWindow::checkEvents() Page::checkEvents(); } + +void InputEditWindow::onCancel() +{ + if (advEdit) { + advEdit = false; + advWindow->hide(); + } else { + Page::onCancel(); + } +} diff --git a/radio/src/gui/colorlcd/model/input_edit.h b/radio/src/gui/colorlcd/model/input_edit.h index 548945cc2..e46c8087b 100644 --- a/radio/src/gui/colorlcd/model/input_edit.h +++ b/radio/src/gui/colorlcd/model/input_edit.h @@ -45,9 +45,14 @@ class InputEditWindow : public Page getvalue_t lastCurveVal = 0; uint8_t lastActiveIndex = 255; StaticText * headerSwitchName = nullptr; + Window* advWindow = nullptr; + bool advEdit = false; void setTitle(); void buildBody(Window *window); + void showAdvanced(); + + void onCancel() override; void checkEvents() override; }; diff --git a/radio/src/gui/colorlcd/model/input_edit_adv.cpp b/radio/src/gui/colorlcd/model/input_edit_adv.cpp deleted file mode 100644 index 6f9fd7293..000000000 --- a/radio/src/gui/colorlcd/model/input_edit_adv.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "input_edit_adv.h" - -#include "fm_matrix.h" -#include "edgetx.h" -#include "etx_lv_theme.h" - -#define SET_DIRTY() storageDirty(EE_MODEL) - -static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), - LV_GRID_TEMPLATE_LAST}; -static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; - -InputEditAdvanced::InputEditAdvanced(uint8_t input_n, uint8_t index) : - Page(ICON_MODEL_INPUTS) -{ - std::string title2(getSourceString(MIXSRC_FIRST_INPUT + input_n)); - header->setTitle(STR_MENUINPUTS); - header->setTitle2(title2); - - FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY); - body->setFlexLayout(); - - ExpoData* input = expoAddress(index); - - // Side - auto line = body->newLine(grid); - new StaticText(line, rect_t{}, STR_SIDE); - new Choice( - line, rect_t{}, STR_VCURVEFUNC, 1, 3, - [=]() -> int16_t { return 4 - input->mode; }, - [=](int16_t newValue) { - input->mode = 4 - newValue; - SET_DIRTY(); - }); - - // Trim - line = body->newLine(grid); - new StaticText(line, rect_t{}, STR_TRIM); - const auto trimLast = TRIM_OFF + keysGetMaxTrims() - 1; - auto c = new Choice(line, rect_t{}, -TRIM_OFF, trimLast, - GET_VALUE(-input->trimSource), - SET_VALUE(input->trimSource, -newValue)); - - uint16_t srcRaw = input->srcRaw; - c->setAvailableHandler([=](int value) { - return value != TRIM_ON || srcRaw <= MIXSRC_LAST_STICK; - }); - c->setTextHandler([=](int value) -> std::string { - return getTrimSourceLabel(srcRaw, -value); - }); - - // Flight modes - if (modelFMEnabled()) { - line = body->newLine(grid); - new StaticText(line, rect_t{}, STR_FLMODE); - new FMMatrix(line, rect_t{}, input); - } -} diff --git a/radio/src/gui/colorlcd/model/input_edit_adv.h b/radio/src/gui/colorlcd/model/input_edit_adv.h deleted file mode 100644 index 11d11e760..000000000 --- a/radio/src/gui/colorlcd/model/input_edit_adv.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#pragma once - -#include "page.h" -#include "button_matrix.h" - -struct ExpoData; - -class InputEditAdvanced : public Page -{ - public: - InputEditAdvanced(uint8_t input_n, uint8_t index); -};