From 35e14ff83e9b5195c0ebeb0e99126573f6330e42 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 25 Jun 2022 15:04:03 +0200 Subject: [PATCH] Fixes for FlySkySettings --- radio/src/gui/colorlcd/flysky_settings.cpp | 34 +++++++++++++++------- radio/src/gui/colorlcd/flysky_settings.h | 4 ++- radio/src/gui/colorlcd/module_setup.cpp | 11 +++++-- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/radio/src/gui/colorlcd/flysky_settings.cpp b/radio/src/gui/colorlcd/flysky_settings.cpp index 90da40849..4c5ff7556 100644 --- a/radio/src/gui/colorlcd/flysky_settings.cpp +++ b/radio/src/gui/colorlcd/flysky_settings.cpp @@ -28,8 +28,8 @@ class FSProtoOpts : public FormGroup { - std::function getMode; - std::function setMode; + std::function _getMode; + std::function _setMode; public: FSProtoOpts(Window* parent, std::function getMode, @@ -39,30 +39,44 @@ public: FSProtoOpts::FSProtoOpts(Window* parent, std::function getMode, std::function setMode) : FormGroup(parent, rect_t{}), - getMode(std::move(getMode)), - setMode(std::move(setMode)) + _getMode(std::move(getMode)), + _setMode(std::move(setMode)) { setFlexLayout(LV_FLEX_FLOW_ROW); // PPM / PWM new Choice( this, rect_t{}, STR_FLYSKY_PULSE_PROTO, 0, 1, - [=]() { return getMode() >> 1; }, - [=](int v) { setMode((getMode() & 1) | ((v & 1) << 1)); SET_DIRTY(); }); + [=]() -> int { return _getMode() >> 1; }, + [=](int v) { + _setMode((_getMode() & 1) | ((v & 1) << 1)); + SET_DIRTY(); + }); + // SBUS / iBUS new Choice( this, rect_t{}, STR_FLYSKY_SERIAL_PROTO, 0, 1, - [=]() { return getMode() & 1; }, - [=](int v) { setMode((getMode() & 2) | (v & 1)); SET_DIRTY(); }); + [=]() -> int { return _getMode() & 1; }, + [=](int v) { + _setMode((_getMode() & 2) | (v & 1)); + SET_DIRTY(); + }); } FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx) : - FormGroup(parent, rect_t{}), md(&g_model.moduleData[moduleIdx]) + FormGroup(parent, rect_t{}), + moduleIdx(moduleIdx), + md(&g_model.moduleData[moduleIdx]), + grid(g) { - FlexGridLayout grid(g); setFlexLayout(); +} +void FlySkySettings::update() +{ + clear(); + // RX options: auto line = newLine(&grid); new StaticText(line, rect_t{}, STR_OPTIONS, 0, COLOR_THEME_PRIMARY1); diff --git a/radio/src/gui/colorlcd/flysky_settings.h b/radio/src/gui/colorlcd/flysky_settings.h index f97737a84..d4e346d7e 100644 --- a/radio/src/gui/colorlcd/flysky_settings.h +++ b/radio/src/gui/colorlcd/flysky_settings.h @@ -28,9 +28,11 @@ struct ModuleData; class FlySkySettings : public FormGroup, public ModuleOptions { + uint8_t moduleIdx; ModuleData* md; + FlexGridLayout grid; - void update() override {} + void update() override; public: FlySkySettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx); diff --git a/radio/src/gui/colorlcd/module_setup.cpp b/radio/src/gui/colorlcd/module_setup.cpp index 27fc0f94d..83149b53a 100644 --- a/radio/src/gui/colorlcd/module_setup.cpp +++ b/radio/src/gui/colorlcd/module_setup.cpp @@ -138,10 +138,16 @@ void ModuleWindow::updateModule() FlexGridLayout grid(col_dsc, row_dsc, 2); clear(); + modOpts = nullptr; + chRange = nullptr; + bindButton = nullptr; + rangeButton = nullptr; + registerButton = nullptr; + fsLine = nullptr; + // Module parameters ModuleData* md = &g_model.moduleData[moduleIdx]; - modOpts = nullptr; if (md->type == MODULE_TYPE_NONE) { return; } @@ -630,8 +636,9 @@ ModulePage::ModulePage(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP) moduleChoice->setSetValueHandler([=](int32_t newValue) { setModuleType(moduleIdx, newValue); - subTypeChoice->update(); moduleWindow->updateModule(); + subTypeChoice->update(); + SET_DIRTY(); });