From cf01c2b441aa8e8c39a6154ec8d2041bd163ccda Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Wed, 19 Apr 2023 11:40:45 +1000 Subject: [PATCH] Revert "fix(color): Scroll order for 'FlySky' module options (#3479)" This reverts commit 54e0d350e8ad3cfef3382cfe6267a19863887ff2. --- radio/src/gui/colorlcd/flysky_settings.cpp | 170 +++++++-------------- radio/src/gui/colorlcd/flysky_settings.h | 20 --- radio/src/hal/module_port.h | 6 - radio/src/pulses/afhds3.cpp | 4 - radio/src/pulses/afhds3_transport.cpp | 2 - 5 files changed, 55 insertions(+), 147 deletions(-) diff --git a/radio/src/gui/colorlcd/flysky_settings.cpp b/radio/src/gui/colorlcd/flysky_settings.cpp index 58b79c1b7..923db157c 100644 --- a/radio/src/gui/colorlcd/flysky_settings.cpp +++ b/radio/src/gui/colorlcd/flysky_settings.cpp @@ -88,131 +88,71 @@ FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g, grid(g) { setFlexLayout(); - - FormGroup::Line* line; - -#if defined(AFHDS2) - // RX options: - line = newLine(&grid); - afhds2OptionsLabel = new StaticText(line, rect_t{}, STR_OPTIONS, 0, COLOR_THEME_PRIMARY1); - - afhds2ProtoOpts = new FSProtoOpts( - line, [=]() { return md->flysky.mode; }, - [=](uint8_t v) { md->flysky.mode = v; }); - -#if defined(PCBNV14) - if (getNV14RfFwVersion() >= 0x1000E) { - line = newLine(&grid); - static const char* _rf_power[] = {"Default", "High"}; - afhds2RFPowerText = new StaticText(line, rect_t{}, STR_MULTI_RFPOWER); - afhds2RFPowerChoice = new Choice(line, rect_t{}, _rf_power, 0, 1, - GET_DEFAULT(md->flysky.rfPower), - [=](int32_t newValue) -> void { - md->flysky.rfPower = newValue; - resetPulsesAFHDS2(); - }); -#endif - } - - hideAFHDS2Options(); -#endif - -#if defined(AFHDS3) - // Status - line = newLine(&grid); - afhds3StatusLabel = new StaticText(line, rect_t{}, STR_MODULE_STATUS, 0, COLOR_THEME_PRIMARY1); - afhds3StatusText = new DynamicText(line, rect_t{}, [=] { - char msg[64] = ""; - getModuleStatusString(moduleIdx, msg); - return std::string(msg); - }); - - // TYPE - line = newLine(&grid); - afhds3TypeLabel = new StaticText(line, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1); - - afhds3TypeForm = new FormGroup(line, rect_t{}); - afhds3TypeForm->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP); - lv_obj_set_style_grid_cell_x_align(afhds3TypeForm->getLvObj(), LV_GRID_ALIGN_STRETCH, 0); - - new Choice(afhds3TypeForm, rect_t{}, _afhds3_phy_mode, 0, afhds3::PHYMODE_MAX, - GET_SET_DEFAULT(md->afhds3.phyMode)); - - new Choice(afhds3TypeForm, rect_t{}, _afhds3_region, - afhds3::LNK_ES_CE, afhds3::LNK_ES_FCC, - GET_SET_DEFAULT(md->afhds3.emi)); - - uint8_t module = moduleIdx; - new TextButton(afhds3TypeForm, rect_t{}, STR_MODULE_OPTIONS, - [=]() { - afhds3::applyModelConfig(module); - new AFHDS3_Options(module); - return 0; - }); - - hideAFHDS3Options(); -#endif } -#if defined(AFHDS2) -void FlySkySettings::hideAFHDS2Options() -{ - lv_obj_add_flag(afhds2OptionsLabel->getLvObj(), LV_OBJ_FLAG_HIDDEN); - lv_obj_add_flag(afhds2ProtoOpts->getLvObj(), LV_OBJ_FLAG_HIDDEN); -#if defined(PCBNV14) - if (afhds2RFPowerText != nullptr) - lv_obj_add_flag(afhds2RFPowerText->getLvObj(), LV_OBJ_FLAG_HIDDEN); - if (afhds2RFPowerChoice != nullptr) - lv_obj_add_flag(afhds2RFPowerChoice->getLvObj(), LV_OBJ_FLAG_HIDDEN); -#endif -} - -void FlySkySettings::showAFHDS2Options() -{ - lv_obj_clear_flag(afhds2OptionsLabel->getLvObj(), LV_OBJ_FLAG_HIDDEN); - lv_obj_clear_flag(afhds2ProtoOpts->getLvObj(), LV_OBJ_FLAG_HIDDEN); -#if defined(PCBNV14) - if (afhds2RFPowerText != nullptr) - lv_obj_clear_flag(afhds2RFPowerText->getLvObj(), LV_OBJ_FLAG_HIDDEN); - if (afhds2RFPowerChoice != nullptr) - lv_obj_clear_flag(afhds2RFPowerChoice->getLvObj(), LV_OBJ_FLAG_HIDDEN); -#endif -} -#endif - -#if defined(AFHDS3) -void FlySkySettings::hideAFHDS3Options() -{ - lv_obj_add_flag(afhds3StatusLabel->getLvObj(), LV_OBJ_FLAG_HIDDEN); - lv_obj_add_flag(afhds3StatusText->getLvObj(), LV_OBJ_FLAG_HIDDEN); - lv_obj_add_flag(afhds3TypeLabel->getLvObj(), LV_OBJ_FLAG_HIDDEN); - lv_obj_add_flag(afhds3TypeForm->getLvObj(), LV_OBJ_FLAG_HIDDEN); -} - -void FlySkySettings::showAFHDS3Options() -{ - lv_obj_clear_flag(afhds3StatusLabel->getLvObj(), LV_OBJ_FLAG_HIDDEN); - lv_obj_clear_flag(afhds3StatusText->getLvObj(), LV_OBJ_FLAG_HIDDEN); - lv_obj_clear_flag(afhds3TypeLabel->getLvObj(), LV_OBJ_FLAG_HIDDEN); - lv_obj_clear_flag(afhds3TypeForm->getLvObj(), LV_OBJ_FLAG_HIDDEN); -} -#endif - void FlySkySettings::update() { + clear(); + #if defined(AFHDS2) if (isModuleAFHDS2A(moduleIdx)) { - showAFHDS2Options(); - } else { - hideAFHDS2Options(); + // RX options: + auto line = newLine(&grid); + new StaticText(line, rect_t{}, STR_OPTIONS, 0, COLOR_THEME_PRIMARY1); + + new FSProtoOpts( + line, [=]() { return md->flysky.mode; }, + [=](uint8_t v) { md->flysky.mode = v; }); + +#if defined(AFHDS2) && defined(PCBNV14) + if (getNV14RfFwVersion() >= 0x1000E) { + line = newLine(&grid); + static const char* _rf_power[] = {"Default", "High"}; + new StaticText(line, rect_t{}, STR_MULTI_RFPOWER); + new Choice(line, rect_t{}, _rf_power, 0, 1, + GET_DEFAULT(md->flysky.rfPower), + [=](int32_t newValue) -> void { + md->flysky.rfPower = newValue; + resetPulsesAFHDS2(); + }); + } +#endif } #endif - #if defined(AFHDS3) if (isModuleAFHDS3(moduleIdx)) { - showAFHDS3Options(); - } else { - hideAFHDS3Options(); + + // Status + auto line = newLine(&grid); + new StaticText(line, rect_t{}, STR_MODULE_STATUS, 0, COLOR_THEME_PRIMARY1); + new DynamicText(line, rect_t{}, [=] { + char msg[64] = ""; + getModuleStatusString(moduleIdx, msg); + return std::string(msg); + }); + + // TYPE + line = newLine(&grid); + new StaticText(line, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1); + + auto box = new FormGroup(line, rect_t{}); + box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP); + lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0); + + new Choice(box, rect_t{}, _afhds3_phy_mode, 0, afhds3::PHYMODE_MAX, + GET_SET_DEFAULT(md->afhds3.phyMode)); + + new Choice(box, rect_t{}, _afhds3_region, + afhds3::LNK_ES_CE, afhds3::LNK_ES_FCC, + GET_SET_DEFAULT(md->afhds3.emi)); + + uint8_t module = moduleIdx; + new TextButton(box, rect_t{}, STR_MODULE_OPTIONS, + [=]() { + afhds3::applyModelConfig(module); + new AFHDS3_Options(module); + return 0; + }); } #endif } diff --git a/radio/src/gui/colorlcd/flysky_settings.h b/radio/src/gui/colorlcd/flysky_settings.h index 1230a1db7..d4e346d7e 100644 --- a/radio/src/gui/colorlcd/flysky_settings.h +++ b/radio/src/gui/colorlcd/flysky_settings.h @@ -32,26 +32,6 @@ class FlySkySettings : public FormGroup, public ModuleOptions ModuleData* md; FlexGridLayout grid; -#if defined(AFHDS2) - Window* afhds2OptionsLabel = nullptr; - Window* afhds2ProtoOpts = nullptr; -#if defined(PCBNV14) - Window* afhds2RFPowerText = nullptr; - Window* afhds2RFPowerChoice = nullptr; -#endif - void hideAFHDS2Options(); - void showAFHDS2Options(); -#endif - -#if defined(AFHDS3) - Window* afhds3StatusLabel = nullptr; - Window* afhds3StatusText = nullptr; - Window* afhds3TypeLabel = nullptr; - FormGroup* afhds3TypeForm = nullptr; - void hideAFHDS3Options(); - void showAFHDS3Options(); -#endif - void update() override; public: diff --git a/radio/src/hal/module_port.h b/radio/src/hal/module_port.h index a17c284af..80597179b 100644 --- a/radio/src/hal/module_port.h +++ b/radio/src/hal/module_port.h @@ -145,16 +145,10 @@ inline uint8_t modulePortGetType(const etx_module_driver_t& d) { } inline const etx_serial_driver_t* modulePortGetSerialDrv(const etx_module_driver_t& d) { -#if defined(SIMU) - if (d.port == nullptr) return nullptr; -#endif return d.port->drv.serial; } inline const etx_timer_driver_t* modulePortGetTimerDrv(const etx_module_driver_t& d) { -#if defined(SIMU) - if (d.port == nullptr) return nullptr; -#endif return d.port->drv.timer; } diff --git a/radio/src/pulses/afhds3.cpp b/radio/src/pulses/afhds3.cpp index ae38ad30e..ebdaa7615 100644 --- a/radio/src/pulses/afhds3.cpp +++ b/radio/src/pulses/afhds3.cpp @@ -857,10 +857,6 @@ void ProtoState::resetConfig(uint8_t version) void ProtoState::applyConfigFromModel() { uint8_t version = 0; -#if defined(SIMU) - // TODO: work out why this is not initialised in some cases - if (moduleData == nullptr) return; -#endif if (moduleData->afhds3.phyMode >= ROUTINE_FLCR1_18CH) { version = 1; } diff --git a/radio/src/pulses/afhds3_transport.cpp b/radio/src/pulses/afhds3_transport.cpp index 1a92afdb1..2442dfa65 100644 --- a/radio/src/pulses/afhds3_transport.cpp +++ b/radio/src/pulses/afhds3_transport.cpp @@ -264,11 +264,9 @@ void Transport::enqueue(COMMAND command, FRAME_TYPE frameType, bool useData, void Transport::sendBuffer() { -#if !defined(SIMU) auto drv = modulePortGetSerialDrv(mod_st->tx); auto ctx = modulePortGetCtx(mod_st->tx); drv->sendBuffer(ctx, (uint8_t*)trsp.trsp_buffer, trsp.getFrameSize()); -#endif } bool Transport::processQueue()