From c4f1e7127d4775106684766ea0d0beeadab2e5de Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 7 Sep 2023 11:24:03 +0200 Subject: [PATCH] chores(flysky): Separate AFHDS2A and AFHDS3 into 2 different module type (#3783) * chores(flysky): separate AFHDS2A and AFHDS3 into 2 different module type This should allow to remove some of the hacks added earlier. * chore: Add some EL18 CI bits * fix(afhds): cmake defs * fix(ci): add el18 to commit-tests.sh * chore(cpn): separate AFHDS2A and AFHDS3 * chore(cpn): remove binary import of afhds and legacy fxFreq field for afhds3 * fix(cpn): limit available internal afhds protocols to those supported by hardware * chore(cpn): update Flysky int module test * fix(cpn): compile error * fix(cpn): afhds2a max channels * fix: TR_MODULE_PROTOCOLS * enh(cpn): more support for afhds2a and 3 * fix(cpn): rebase compile error * fix(cpn): bit indexes * fix(cpn): emi toString * fix(cpn): limit available internal afhds protocols to those supported by hardware * enh(cpn): add support for Flysky EL18 * fix(cpn): available protocols * fix(cpn): rebase moduledata * chore(cpn): add module fields to model print * Separate AFHDS2A and AFHDS3 UI settings. * Fix AFHDS3 conversion from old subtype value. Fix 'Channel Range' layout on portrait LCD. * Fix name. --------- Co-authored-by: Peter Feerick Co-authored-by: elecpower Co-authored-by: Phil Mitchell --- .github/workflows/actions.yml | 7 +- .github/workflows/nightly.yml | 2 +- companion/src/CMakeLists.txt | 2 + companion/src/firmwares/CMakeLists.txt | 1 - companion/src/firmwares/afhds3.cpp | 12 - companion/src/firmwares/afhds3.h | 12 - companion/src/firmwares/boards.cpp | 69 +++--- companion/src/firmwares/boards.h | 4 +- .../firmwares/edgetx/yaml_generalsettings.cpp | 4 +- .../src/firmwares/edgetx/yaml_moduledata.cpp | 85 ++++++-- companion/src/firmwares/moduledata.cpp | 110 ++++++++-- companion/src/firmwares/moduledata.h | 52 ++++- .../src/firmwares/opentx/opentxeeprom.cpp | 35 --- companion/src/firmwares/opentx/opentxeeprom.h | 4 - .../src/firmwares/opentx/opentxinterface.cpp | 37 +++- companion/src/modeledit/setup.cpp | 87 ++++++-- companion/src/modeledit/setup_module.ui | 37 +++- companion/src/modelprinter.cpp | 12 +- companion/src/simulation/CMakeLists.txt | 2 + companion/src/simulation/simulateduiwidget.h | 15 +- .../src/simulation/simulateduiwidgetEL18.cpp | 76 +++++++ .../src/simulation/simulateduiwidgetEL18.ui | 206 ++++++++++++++++++ companion/src/simulation/simulatorwidget.cpp | 3 + fw.json | 2 +- radio/src/datastructs_private.h | 2 +- radio/src/gui/colorlcd/CMakeLists.txt | 12 +- radio/src/gui/colorlcd/afhds2a_settings.cpp | 141 ++++++++++++ radio/src/gui/colorlcd/afhds2a_settings.h | 51 +++++ ...lysky_settings.cpp => afhds3_settings.cpp} | 130 +---------- .../{flysky_settings.h => afhds3_settings.h} | 17 +- radio/src/gui/colorlcd/channel_range.cpp | 6 + radio/src/gui/colorlcd/module_setup.cpp | 54 ++--- radio/src/gui/gui_common.cpp | 22 +- radio/src/pulses/modules_constants.h | 8 +- radio/src/pulses/modules_helpers.h | 53 ++--- radio/src/pulses/pulses.cpp | 16 +- .../storage/yaml/yaml_datastructs_128x64.cpp | 5 +- .../storage/yaml/yaml_datastructs_funcs.cpp | 42 +++- .../storage/yaml/yaml_datastructs_nv14.cpp | 5 +- .../src/storage/yaml/yaml_datastructs_t20.cpp | 5 +- .../storage/yaml/yaml_datastructs_tpro.cpp | 5 +- .../src/storage/yaml/yaml_datastructs_x10.cpp | 5 +- .../storage/yaml/yaml_datastructs_x12s.cpp | 5 +- .../src/storage/yaml/yaml_datastructs_x9d.cpp | 5 +- .../src/storage/yaml/yaml_datastructs_x9e.cpp | 5 +- .../storage/yaml/yaml_datastructs_x9lite.cpp | 5 +- .../storage/yaml/yaml_datastructs_xlites.cpp | 5 +- radio/src/targets/nv14/CMakeLists.txt | 21 +- radio/src/targets/nv14/board.h | 10 +- radio/src/telemetry/telemetry.cpp | 9 +- radio/src/translations.cpp | 1 - radio/src/translations.h | 1 - radio/src/translations/untranslated.h | 4 +- radio/util/hw_defs/legacy_names.py | 2 +- radio/util/hw_defs/pot_config.py | 8 + radio/util/hw_defs/switch_config.py | 10 + tools/build-flysky.py | 5 + tools/build-gh.sh | 3 + tools/commit-tests.sh | 3 + 59 files changed, 1096 insertions(+), 461 deletions(-) delete mode 100644 companion/src/firmwares/afhds3.cpp delete mode 100644 companion/src/firmwares/afhds3.h create mode 100644 companion/src/simulation/simulateduiwidgetEL18.cpp create mode 100644 companion/src/simulation/simulateduiwidgetEL18.ui create mode 100644 radio/src/gui/colorlcd/afhds2a_settings.cpp create mode 100644 radio/src/gui/colorlcd/afhds2a_settings.h rename radio/src/gui/colorlcd/{flysky_settings.cpp => afhds3_settings.cpp} (59%) rename radio/src/gui/colorlcd/{flysky_settings.h => afhds3_settings.h} (75%) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index c9cd80fc72f..16546872fe2 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -46,7 +46,10 @@ jobs: strategy: matrix: target: + - x9dp2019 + - tx16s - nv14 + - el18 - t12 - t16 - t18 @@ -54,13 +57,11 @@ jobs: - tlite - t20 - tx12 - - tx16s - x10 - x12s - x7 - x9d - x9dp - - x9dp2019 - x9e - x9lite - x9lites @@ -92,7 +93,7 @@ jobs: strategy: matrix: target: - - nv14 + - nv14;el18 - t12 - t16 - t18 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index adb4a706100..e9c70748345 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: target: - - nv14 + - nv14;el18 - t12 - t16 - t18 diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 6f97b8e911b..839d48e1289 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -346,6 +346,8 @@ elseif(PCB STREQUAL X10 AND PCBREV STREQUAL TX16S) set(FLAVOUR tx16s) elseif(PCB STREQUAL X10 AND PCBREV STREQUAL T18) set(FLAVOUR t18) +elseif(PCB STREQUAL NV14 AND PCBREV STREQUAL EL18) + set(FLAVOUR el18) else() string(TOLOWER ${PCB} FLAVOUR) endif() diff --git a/companion/src/firmwares/CMakeLists.txt b/companion/src/firmwares/CMakeLists.txt index 0724ea28606..a96617f9933 100644 --- a/companion/src/firmwares/CMakeLists.txt +++ b/companion/src/firmwares/CMakeLists.txt @@ -24,7 +24,6 @@ set(firmwares_SRCS sensordata.cpp telem_data.cpp timerdata.cpp - afhds3.cpp ersky9x/ersky9xeeprom.cpp ersky9x/ersky9xinterface.cpp opentx/opentxeeprom.cpp diff --git a/companion/src/firmwares/afhds3.cpp b/companion/src/firmwares/afhds3.cpp deleted file mode 100644 index 000fb252c0a..00000000000 --- a/companion/src/firmwares/afhds3.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "afhds3.h" -#include "macros.h" - -QString Afhds3Data::protocolToString(unsigned int protocol) { - const char * const afhds3Protocols[] = { - "PWM/IBUS", - "PWM/SBUS", - "PPM/IBUS", - "PPM/SBUS", - }; - return CHECK_IN_ARRAY(afhds3Protocols, protocol); -} diff --git a/companion/src/firmwares/afhds3.h b/companion/src/firmwares/afhds3.h deleted file mode 100644 index ea4257fba7e..00000000000 --- a/companion/src/firmwares/afhds3.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef AFHDS3_H -#define AFHDS3_H - -#include - -class Afhds3Data -{ - Q_DECLARE_TR_FUNCTIONS(Afhds3) -public: - static QString protocolToString(unsigned int protocol); -}; -#endif // AFHDS3_H diff --git a/companion/src/firmwares/boards.cpp b/companion/src/firmwares/boards.cpp index 391ed93f4b2..9f3326f4953 100644 --- a/companion/src/firmwares/boards.cpp +++ b/companion/src/firmwares/boards.cpp @@ -109,6 +109,8 @@ uint32_t Boards::getFourCC(Type board) return 0x4378746F; case BOARD_FLYSKY_NV14: return 0x3A78746F; + case BOARD_FLYSKY_EL18: + return 0x3A78746F; // TODO: check this default: return 0; } @@ -153,6 +155,7 @@ int Boards::getEEpromSize(Board::Type board) case BOARD_JUMPER_T18: case BOARD_RADIOMASTER_TX16S: case BOARD_FLYSKY_NV14: + case BOARD_FLYSKY_EL18: return 0; default: return 0; @@ -196,6 +199,7 @@ int Boards::getFlashSize(Type board) case BOARD_JUMPER_T18: case BOARD_RADIOMASTER_TX16S: case BOARD_FLYSKY_NV14: + case BOARD_FLYSKY_EL18: return FSIZE_HORUS; case BOARD_UNKNOWN: return FSIZE_MAX; @@ -342,7 +346,7 @@ SwitchInfo Boards::getSwitchInfo(Board::Type board, int index) if (index < DIM(switches)) return switches[index]; } - else if (IS_FLYSKY_NV14(board)) { + else if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) { const Board::SwitchInfo switches[] = { {SWITCH_2POS, "SA"}, {SWITCH_3POS, "SB"}, @@ -434,7 +438,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) return 7; else if (IS_HORUS_X12S(board)) return 3; - else if (IS_FLYSKY_NV14(board)) + else if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) return 2; else return 3; @@ -466,10 +470,11 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) return 0; case MaxAnalogs: - return getCapability(board, Board::Sticks) + getCapability(board, Board::Pots) + getCapability(board, Board::Sliders) + getCapability(board, Board::MouseAnalogs) + getCapability(board, Board::GyroAnalogs); + return getCapability(board, Board::Sticks) + getCapability(board, Board::Pots) + getCapability(board, Board::Sliders) + + getCapability(board, Board::MouseAnalogs) + getCapability(board, Board::GyroAnalogs); case MultiposPots: - if (IS_HORUS_OR_TARANIS(board) && !IS_FLYSKY_NV14(board)) + if (IS_HORUS_OR_TARANIS(board) && !(IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))) return getCapability(board, Board::Pots); else return 0; @@ -492,7 +497,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) board == BOARD_JUMPER_TPRO || board == BOARD_BETAFPV_LR3PRO || board == BOARD_IFLIGHT_COMMANDO8) return 4; - else if (board == BOARD_FLYSKY_NV14) + else if (board == BOARD_FLYSKY_NV14 || board == BOARD_FLYSKY_EL18) return 8; else if (board == BOARD_RADIOMASTER_TX12_MK2 || board == BOARD_RADIOMASTER_BOXER) return 6; @@ -527,7 +532,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) return getCapability(board, Board::Switches); case SwitchPositions: - if (IS_HORUS_OR_TARANIS(board) || IS_FLYSKY_NV14(board)) + if (IS_HORUS_OR_TARANIS(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) return getCapability(board, Board::Switches) * 3; else return 9; @@ -537,7 +542,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) case NumTrims: - if (IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board)) + if (IS_FAMILY_HORUS_OR_T16(board) && !(IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))) return 6; else if (IS_IFLIGHT_COMMANDO8(board)) return 0; @@ -563,12 +568,12 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) return (IS_STM32(board) && !IS_RADIOMASTER_T8(board)); case HasAudioMuteGPIO: - // All color lcd (including NV14) except Horus X12S + // All color lcd (including NV14 and EL18) except Horus X12S // TX12, TX12MK2, ZORRO, BOXER, T8, TLITE, TPRO, LR3PRO, COMMANDO8 return (IS_FAMILY_HORUS_OR_T16(board) && !IS_HORUS_X12S(board)) || IS_FAMILY_T12(board); case SportMaxBaudRate: - if (IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board) || IS_TARANIS_X7_ACCESS(board) || + if (IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_TARANIS_X7_ACCESS(board) || (IS_TARANIS(board) && !IS_TARANIS_XLITE(board) && !IS_TARANIS_X7(board) && !IS_TARANIS_X9LITE(board))) return 400000; // 400K and higher else @@ -685,31 +690,16 @@ StringTagMappingTable Boards::getAnalogNamesLookupTable(Board::Type board, const }); } } else if (IS_RADIOMASTER_BOXER(board)) { - if (version < adcVersion) { - tbl.insert(tbl.end(), { - {tr("S1").toStdString(), "POT1"}, - {tr("S2").toStdString(), "POT2"}, - {tr("S3").toStdString(), "POT3"}, - }); - } else { - tbl.insert(tbl.end(), { - {tr("S1").toStdString(), "P1", 4}, - {tr("S2").toStdString(), "P2", 5}, - {tr("S3").toStdString(), "P3", 6}, - }); - } - } else if ((IS_TARANIS_SMALL(board) && !IS_JUMPER_TLITE(board)) || IS_FLYSKY_NV14(board)) { - if (version < adcVersion) { - tbl.insert(tbl.end(), { - {tr("S1").toStdString(), "POT1"}, - {tr("S2").toStdString(), "POT2"}, - }); - } else { - tbl.insert(tbl.end(), { - {tr("S1").toStdString(), "P1", 4}, - {tr("S2").toStdString(), "P2", 5}, - }); - } + tbl.insert(tbl.end(), { + {tr("S1").toStdString(), "POT1"}, + {tr("S2").toStdString(), "POT2"}, + {tr("S3").toStdString(), "POT3"}, + }); + } else if ((IS_TARANIS_SMALL(board) && !IS_JUMPER_TLITE(board)) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) { + tbl.insert(tbl.end(), { + {tr("S1").toStdString(), "POT1"}, + {tr("S2").toStdString(), "POT2"}, + }); } else if (IS_TARANIS_X9(board)) { if (version < adcVersion) { tbl.insert(tbl.end(), { @@ -872,6 +862,8 @@ QString Boards::getBoardName(Board::Type board) return "Radiomaster T8"; case BOARD_FLYSKY_NV14: return "FlySky NV14"; + case BOARD_FLYSKY_EL18: + return "FlySky EL18"; case BOARD_BETAFPV_LR3PRO: return "BETAFPV LR3PRO"; case BOARD_IFLIGHT_COMMANDO8: @@ -1043,7 +1035,9 @@ QList Boards::getSupportedInternalModules(Board::Type board) if (IS_TARANIS_X9DP_2019(board) || IS_TARANIS_X7_ACCESS(board)) { modules.append({(int)MODULE_TYPE_ISRM_PXX2}); } else if (IS_FLYSKY_NV14(board)) { - modules.append({(int)MODULE_TYPE_FLYSKY}); + modules.append({(int)MODULE_TYPE_FLYSKY_AFHDS2A}); + } else if (IS_FLYSKY_EL18(board)) { + modules.append({(int)MODULE_TYPE_FLYSKY_AFHDS3}); } else if (IS_FAMILY_HORUS_OR_T16(board) || IS_FAMILY_T12(board) || (IS_TARANIS_SMALL(board) && IS_ACCESS_RADIO(board))) { modules.append({ @@ -1098,7 +1092,10 @@ int Boards::getDefaultInternalModules(Board::Type board) return (int)MODULE_TYPE_CROSSFIRE; case BOARD_FLYSKY_NV14: - return (int)MODULE_TYPE_FLYSKY; + return (int)MODULE_TYPE_FLYSKY_AFHDS2A; + + case BOARD_FLYSKY_EL18: + return (int)MODULE_TYPE_FLYSKY_AFHDS3; default: return (int)MODULE_TYPE_NONE; diff --git a/companion/src/firmwares/boards.h b/companion/src/firmwares/boards.h index f0274e74220..940b7dad1f1 100644 --- a/companion/src/firmwares/boards.h +++ b/companion/src/firmwares/boards.h @@ -440,7 +440,7 @@ inline bool IS_FAMILY_HORUS(Board::Type board) inline bool IS_FAMILY_HORUS_OR_T16(Board::Type board) { - return IS_FAMILY_HORUS(board) || IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board)/*generally*/; + return IS_FAMILY_HORUS(board) || IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board)/*generally*/ || IS_FLYSKY_EL18(board)/*generally*/; } inline bool IS_HORUS_OR_TARANIS(Board::Type board) @@ -450,7 +450,7 @@ inline bool IS_HORUS_OR_TARANIS(Board::Type board) inline bool IS_STM32(Board::Type board) { - return IS_TARANIS(board) || IS_FAMILY_HORUS_OR_T16(board) || IS_FLYSKY_NV14(board); + return IS_TARANIS(board) || IS_FAMILY_HORUS_OR_T16(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board); } inline bool IS_ARM(Board::Type board) diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp index 748d91c855d..6e0cd4eee3c 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp @@ -112,7 +112,9 @@ const YamlLookupTable internalModuleLut = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, + { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, }; YamlTelemetryBaudrate::YamlTelemetryBaudrate( diff --git a/companion/src/firmwares/edgetx/yaml_moduledata.cpp b/companion/src/firmwares/edgetx/yaml_moduledata.cpp index 588562bdfe1..6a535008f74 100644 --- a/companion/src/firmwares/edgetx/yaml_moduledata.cpp +++ b/companion/src/firmwares/edgetx/yaml_moduledata.cpp @@ -54,8 +54,8 @@ // channelsStart: 0 // channelsCount: 18 // failsafeMode: NOT_SET -// mod: -// afhds3: +// mod: +// afhds3: // emi: 2 // telemetry: 1 // phyMode: 2 @@ -78,10 +78,15 @@ static const YamlLookupTable protocolLut = { { PULSES_ACCESS_R9M_LITE_PRO, "TYPE_R9M_LITE_PRO_PXX2" }, { PULSES_SBUS, "TYPE_SBUS" }, { PULSES_XJT_LITE_X16, "TYPE_XJT_LITE_PXX2" }, - { PULSES_AFHDS3, "TYPE_FLYSKY" }, + { PULSES_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { PULSES_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { PULSES_LEMON_DSMP, "TYPE_LEMON_DSMP" }, }; +static const YamlLookupTable oldprotocolLut = { + { PULSES_FLYSKY_AFHDS2A, "TYPE_FLYSKY" }, +}; + static const YamlLookupTable xjtLut = { { 0, "D16" }, { 1, "D8" }, @@ -111,9 +116,10 @@ static const YamlLookupTable dsmLut = { { 2, "DSMX" }, }; +// depreciated - used for decoding and converting module subtype to protocol static const YamlLookupTable afhdsLut = { - { 0, "AFHDS3" }, - { 1, "AFHDS2A" } // could be complete nonsense, CHECK IT! + { 0, "AFHDS2A" }, + { 1, "AFHDS3" } }; static const YamlLookupTable failsafeLut = { @@ -166,7 +172,7 @@ Node convert::encode(const ModuleData& rhs) break; case PULSES_PPM: node["subType"] = LookupValue(ppmLut, subtype); - break; + break; case PULSES_MULTIMODULE: { int rfProtocol = rhs.multi.rfProtocol + 1; int subType = rhs.subType; @@ -175,10 +181,6 @@ Node convert::encode(const ModuleData& rhs) st_str += std::to_string(subType); node["subType"] = st_str; } break; - case PULSES_AFHDS3: { - node["subType"] = LookupValue(afhdsLut, subtype); - break; - } } node["channelsStart"] = rhs.channelsStart; @@ -246,9 +248,20 @@ Node convert::encode(const ModuleData& rhs) dsmp["flags"] = rhs.dsmp.flags; mod["dsmp"] = dsmp; } break; - // TODO: flysky - // TODO: afhds3 - case PULSES_AFHDS3: { + case PULSES_FLYSKY_AFHDS2A: { + Node flysky; + for (int i = 0; i < 4; i++) { + flysky["rx_id"][std::to_string(i)]["val"] = rhs.flysky.rxId[i]; + } + flysky["mode"] = rhs.flysky.mode; + flysky["rfPower"] = rhs.flysky.rfPower; + flysky["reserved"] = rhs.flysky.reserved; + for (int i = 0; i < 2; i++) { + flysky["rx_freq"][std::to_string(i)]["val"] = rhs.flysky.rxFreq[i]; + } + mod["flysky"] = flysky; + } break; + case PULSES_FLYSKY_AFHDS3: { Node afhds3; afhds3["emi"] = rhs.afhds3.emi; afhds3["telemetry"] = rhs.afhds3.telemetry; @@ -275,6 +288,8 @@ Node convert::encode(const ModuleData& rhs) bool convert::decode(const Node& node, ModuleData& rhs) { node["type"] >> protocolLut >> rhs.protocol; + if (rhs.protocol < 0) + node["type"] >> oldprotocolLut >> rhs.protocol; Node subType; node["subType"] >> subType; @@ -319,6 +334,12 @@ bool convert::decode(const Node& node, ModuleData& rhs) } catch(...) {} } } break; + case PULSES_FLYSKY_AFHDS2A: { + int subProto = 0; + subType >> afhdsLut >> subProto; + rhs.protocol += subProto; + rhs.subType = 0; + } break; } node["channelsStart"] >> rhs.channelsStart; @@ -381,15 +402,37 @@ bool convert::decode(const Node& node, ModuleData& rhs) Node dsmp = mod["dsmp"]; dsmp["flags"] >> rhs.dsmp.flags; } else if (mod["flysky"]) { - // TODO: flysky + Node flysky = mod["flysky"]; + for (int i = 0; i < 4; i++) { + if (flysky["rx_id"][std::to_string(i)]) { + Node rxid = flysky["rx_id"][std::to_string(i)]; + if (rxid.IsMap()) { + if (rxid["val"]) { + rxid["val"] >> rhs.flysky.rxId[i]; + } + } + } + } + flysky["mode"] >> rhs.flysky.mode; + flysky["rfPower"] >> rhs.flysky.rfPower; + flysky["reserved"] >> rhs.flysky.reserved; + for (int i = 0; i < 2; i++) { + if (flysky["rx_freq"][std::to_string(i)]) { + Node rxfreq = flysky["rx_freq"][std::to_string(i)]; + if (rxfreq.IsMap()) { + if (rxfreq["val"]) { + rxfreq["val"] >> rhs.flysky.rxFreq[i]; + } + } + } + } } else if (mod["afhds3"]) { - // TODO: afhds3 - Node afhds3 = mod["afhds3"]; - afhds3["emi"] >> rhs.afhds3.emi; - afhds3["telemetry"] >> rhs.afhds3.telemetry; - afhds3["phyMode"] >> rhs.afhds3.phyMode; - afhds3["reserved"] >> rhs.afhds3.reserved; - afhds3["rfPower"] >> rhs.afhds3.rfPower; + Node afhds3 = mod["afhds3"]; + afhds3["emi"] >> rhs.afhds3.emi; + afhds3["telemetry"] >> rhs.afhds3.telemetry; + afhds3["phyMode"] >> rhs.afhds3.phyMode; + afhds3["reserved"] >> rhs.afhds3.reserved; + afhds3["rfPower"] >> rhs.afhds3.rfPower; } } diff --git a/companion/src/firmwares/moduledata.cpp b/companion/src/firmwares/moduledata.cpp index 14276c9b22e..07e6953aded 100644 --- a/companion/src/firmwares/moduledata.cpp +++ b/companion/src/firmwares/moduledata.cpp @@ -21,11 +21,11 @@ #include "moduledata.h" #include "eeprominterface.h" #include "multiprotocols.h" -#include "afhds3.h" #include "radiodataconversionstate.h" #include "compounditemmodels.h" #include "generalsettings.h" #include "appdata.h" +#include "helpers.h" #include #include @@ -90,8 +90,10 @@ bool ModuleData::isAvailable(PulsesProtocol proto, int port) return fw->getCapability(HasIntModuleMulti); case PULSES_CROSSFIRE: return fw->getCapability(HasIntModuleCRSF) || fw->getCapability(HasIntModuleELRS); - case PULSES_AFHDS3: - return fw->getCapability(HasIntModuleFlySky); + case PULSES_FLYSKY_AFHDS2A: + return IS_FLYSKY_NV14(board); + case PULSES_FLYSKY_AFHDS3: + return IS_FLYSKY_EL18(board); default: return false; } @@ -112,7 +114,8 @@ bool ModuleData::isAvailable(PulsesProtocol proto, int port) case PULSES_SBUS: case PULSES_MULTIMODULE: case PULSES_CROSSFIRE: - case PULSES_AFHDS3: + case PULSES_FLYSKY_AFHDS2A: + case PULSES_FLYSKY_AFHDS3: case PULSES_GHOST: return true; case PULSES_ACCESS_R9M: @@ -263,8 +266,6 @@ QString ModuleData::subTypeToString(int type) const return CHECK_IN_ARRAY(ppmSubTypeStrings, type); case PULSES_PXX_R9M: return CHECK_IN_ARRAY(strings, type); - case PULSES_AFHDS3: - return Afhds3Data::protocolToString(type); default: return CPN_STR_UNKNOWN_ITEM; } @@ -273,7 +274,7 @@ QString ModuleData::subTypeToString(int type) const QString ModuleData::powerValueToString(Firmware * fw) const { const QStringList & strRef = powerValueStrings((enum PulsesProtocol)protocol, subType, fw); - return strRef.value(protocol == PULSES_AFHDS3 ? afhds3.rfPower : pxx.power, CPN_STR_UNKNOWN_ITEM); + return strRef.value(protocol == PULSES_FLYSKY_AFHDS3 ? afhds3.rfPower : pxx.power, CPN_STR_UNKNOWN_ITEM); } // static @@ -313,7 +314,7 @@ QString ModuleData::protocolToString(unsigned int protocol) tr("FrSky ACCESS R9M Lite"), tr("FrSky ACCESS R9M Lite Pro"), tr("FrSky XJT lite (D16)"), tr("FrSky XJT lite (D8)"), tr("FrSky XJT lite (LR12)"), - tr("AFHDS3"), + tr("Flysky AFHDS2A"), tr("Flysky AFHDS3"), tr("Ghost"), tr("Lemon-Rx DSMP"), }; @@ -335,7 +336,7 @@ QStringList ModuleData::powerValueStrings(enum PulsesProtocol protocol, int subT }; switch(protocol) { - case PULSES_AFHDS3: + case PULSES_FLYSKY_AFHDS3: return afhds3Strings; default: int strIdx = 0; @@ -359,7 +360,8 @@ bool ModuleData::hasFailsafes(Firmware * fw) const protocol == PULSES_ACCESS_R9M_LITE_PRO || protocol == PULSES_XJT_LITE_X16 || protocol == PULSES_MULTIMODULE || - protocol == PULSES_AFHDS3 + protocol == PULSES_FLYSKY_AFHDS2A || + protocol == PULSES_FLYSKY_AFHDS3 ); } @@ -397,7 +399,9 @@ int ModuleData::getMaxChannelCount() else return 16; break; - case PULSES_AFHDS3: + case PULSES_FLYSKY_AFHDS2A: + return 14; + case PULSES_FLYSKY_AFHDS3: return 18; case PULSES_LEMON_DSMP: return 12; @@ -450,7 +454,8 @@ int ModuleData::getTypeFromProtocol(unsigned int protocol) { PULSES_XJT_LITE_D8, MODULE_TYPE_XJT_LITE_PXX2 }, { PULSES_XJT_LITE_LR12, MODULE_TYPE_XJT_LITE_PXX2 }, - { PULSES_AFHDS3, MODULE_TYPE_FLYSKY }, + { PULSES_FLYSKY_AFHDS2A, MODULE_TYPE_FLYSKY_AFHDS2A }, + { PULSES_FLYSKY_AFHDS3, MODULE_TYPE_FLYSKY_AFHDS3 }, { PULSES_LEMON_DSMP, MODULE_TYPE_LEMON_DSMP }, }; @@ -495,7 +500,8 @@ QString ModuleData::typeToString(int type) "R9MLP ACCESS", "SBUS", "XJT Lite", - "FLYSKY", + "Flysky AFHDS2A", + "Flysky AFHDS3", "Lemon-Rx DSMP", }; @@ -548,7 +554,8 @@ bool ModuleData::isProtocolAvailable(int moduleidx, unsigned int protocol, Gener case MODULE_TYPE_CROSSFIRE: case MODULE_TYPE_MULTIMODULE: case MODULE_TYPE_GHOST: - case MODULE_TYPE_FLYSKY: + case MODULE_TYPE_FLYSKY_AFHDS2A: + case MODULE_TYPE_FLYSKY_AFHDS3: case MODULE_TYPE_LEMON_DSMP: case MODULE_TYPE_R9M_LITE_PXX1: case MODULE_TYPE_R9M_LITE_PXX2: @@ -570,7 +577,8 @@ bool ModuleData::isProtocolAvailable(int moduleidx, unsigned int protocol, Gener case MODULE_TYPE_CROSSFIRE: case MODULE_TYPE_MULTIMODULE: case MODULE_TYPE_GHOST: - case MODULE_TYPE_FLYSKY: + case MODULE_TYPE_FLYSKY_AFHDS2A: + case MODULE_TYPE_FLYSKY_AFHDS3: case MODULE_TYPE_LEMON_DSMP: return true; default: @@ -683,3 +691,75 @@ AbstractStaticItemModel * ModuleData::telemetryBaudrateItemModel(unsigned int p mdl->loadItemList(); return mdl; } + +QString ModuleData::afhds2aMode1ToString() const +{ + return afhds2aMode1List.at(Helpers::getBitmappedValue(flysky.mode, 0)); +} + +QString ModuleData::afhds2aMode2ToString() const +{ + return afhds2aMode2List.at(Helpers::getBitmappedValue(flysky.mode, 1)); +} + +QString ModuleData::afhds3PhyModeToString() const +{ + return afhds3PhyModeList.at(afhds3.phyMode); +} + +QString ModuleData::afhds3EmiToString() const +{ + return afhds3EmiList.at(afhds3.emi - 1); +} + +AbstractStaticItemModel * ModuleData::afhds2aMode1ItemModel() +{ + AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); + mdl->setName("moduledata.afhds2aMode1"); + + for (int i = 0; i < afhds2aMode1List.size(); i++) { + mdl->appendToItemList(afhds2aMode1List.at(i), i); + } + + mdl->loadItemList(); + return mdl; +} + +AbstractStaticItemModel * ModuleData::afhds2aMode2ItemModel() +{ + AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); + mdl->setName("moduledata.afhds2aMode2"); + + for (int i = 0; i < afhds2aMode2List.size(); i++) { + mdl->appendToItemList(afhds2aMode2List.at(i), i); + } + + mdl->loadItemList(); + return mdl; +} + +AbstractStaticItemModel * ModuleData::afhds3PhyModeItemModel() +{ + AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); + mdl->setName("moduledata.afhds3PhyMode"); + + for (int i = 0; i < afhds3PhyModeList.size(); i++) { + mdl->appendToItemList(afhds3PhyModeList.at(i), i); + } + + mdl->loadItemList(); + return mdl; +} + +AbstractStaticItemModel * ModuleData::afhds3EmiItemModel() +{ + AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); + mdl->setName("moduledata.afhds3Emi"); + + for (int i = 0; i < afhds3EmiList.size(); i++) { + mdl->appendToItemList(afhds3EmiList.at(i), i + 1); // Note: 1 based + } + + mdl->loadItemList(); + return mdl; +} diff --git a/companion/src/firmwares/moduledata.h b/companion/src/firmwares/moduledata.h index 712221bd112..1f750f3b9f7 100644 --- a/companion/src/firmwares/moduledata.h +++ b/companion/src/firmwares/moduledata.h @@ -47,7 +47,8 @@ enum ModuleType { MODULE_TYPE_R9M_LITE_PRO_PXX2, MODULE_TYPE_SBUS, MODULE_TYPE_XJT_LITE_PXX2, - MODULE_TYPE_FLYSKY, //no more protocols possible because of 4 bits value + MODULE_TYPE_FLYSKY_AFHDS2A, + MODULE_TYPE_FLYSKY_AFHDS3, MODULE_TYPE_LEMON_DSMP, MODULE_TYPE_COUNT, MODULE_TYPE_MAX = MODULE_TYPE_COUNT - 1 @@ -83,7 +84,8 @@ enum PulsesProtocol { PULSES_XJT_LITE_X16, PULSES_XJT_LITE_D8, PULSES_XJT_LITE_LR12, - PULSES_AFHDS3, + PULSES_FLYSKY_AFHDS2A, + PULSES_FLYSKY_AFHDS3, PULSES_GHOST, PULSES_LEMON_DSMP, PULSES_PROTOCOL_LAST @@ -102,6 +104,11 @@ enum ModuleSubtypeR9M { constexpr int PXX2_MAX_RECEIVERS_PER_MODULE = 3; constexpr int PXX2_LEN_RX_NAME = 8; +static const QStringList afhds2aMode1List({"PWM", "PPM"}); +static const QStringList afhds2aMode2List({"IBUS", "SBUS"}); +static const QStringList afhds3PhyModeList({"Classic 18ch", "C-Fast 10ch", "Routine 18ch", "Fast 8ch", "Lora 12ch"}); +static const QStringList afhds3EmiList({"CE", "FCC"}); + class ModuleData { Q_DECLARE_TR_FUNCTIONS(ModuleData) @@ -118,7 +125,7 @@ class ModuleData { unsigned int subType; bool invertedSerial; unsigned int channelsStart; - int channelsCount; // 0=8 channels + int channelsCount; unsigned int failsafeMode; struct PPM { @@ -137,13 +144,36 @@ class ModuleData { int optionValue; } multi; - struct Afhds3 { - unsigned int rxFreq; + struct Flysky { + unsigned int rxId[4]; + unsigned int mode; unsigned int rfPower; + unsigned int reserved; + unsigned int rxFreq[2]; + + void setDefault() { + rxId[0] = rxId[1] = rxId[2] = rxId[3] = 0; + mode = 3; + rfPower = 0; + rxFreq[0] = 50; + rxFreq[1] = 0; + } + } flysky; + + struct Afhds3 { unsigned int emi; unsigned int telemetry; unsigned int phyMode; unsigned int reserved; + unsigned int rfPower; + + void setDefault() { + emi = 1; + telemetry = 0; + phyMode = 0; + reserved = 0; + rfPower = 0; + } } afhds3; struct PXX { @@ -191,6 +221,16 @@ class ModuleData { static AbstractStaticItemModel * internalModuleItemModel(int board = -1); static bool isProtocolAvailable(int moduleidx, unsigned int protocol, GeneralSettings & generalSettings); static AbstractStaticItemModel * protocolItemModel(GeneralSettings & settings); - static AbstractStaticItemModel * telemetryBaudrateItemModel(unsigned int protocol); + static AbstractStaticItemModel * telemetryBaudrateItemModel(unsigned int protocol); static bool isAvailable(PulsesProtocol proto, int port = 0); // moved from OpenTxFirmware EdgeTX v2.9 - TODO remove and use isProtocolAvailable + + QString afhds2aMode1ToString() const; + QString afhds2aMode2ToString() const; + QString afhds3PhyModeToString() const; + QString afhds3EmiToString() const; + + static AbstractStaticItemModel * afhds2aMode1ItemModel(); + static AbstractStaticItemModel * afhds2aMode2ItemModel(); + static AbstractStaticItemModel * afhds3PhyModeItemModel(); + static AbstractStaticItemModel * afhds3EmiItemModel(); }; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 71545c14c75..d6247523368 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2211,40 +2211,6 @@ class ModuleUnionField: public UnionField { unsigned int version; }; - class Afhds3Field: public UnionField::TransformedMember { - public: - Afhds3Field(DataField * parent, ModuleData& module): - UnionField::TransformedMember(parent, internalField), - internalField(this, "AFHDS3") - { - ModuleData::Afhds3& afhds3 = module.afhds3; - internalField.Append(new UnsignedField<3>(this, minBindPower)); - internalField.Append(new UnsignedField<3>(this, afhds3.rfPower)); - internalField.Append(new UnsignedField<1>(this, emissionFCC)); - internalField.Append(new BoolField<1>(this, operationModeUnicast)); - internalField.Append(new BoolField<1>(this, operationModeUnicast)); - internalField.Append(new UnsignedField<16>(this, defaultFailSafeTimout)); - internalField.Append(new UnsignedField<16>(this, afhds3.rxFreq)); - } - - bool select(const unsigned int& attr) const override { - return attr == PULSES_AFHDS3; - } - - void beforeExport() override {} - - void afterImport() override {} - - private: - StructField internalField; - - unsigned int minBindPower = 0; - unsigned int emissionFCC = 0; - unsigned int defaultFailSafeTimout = 1000; - bool operationModeUnicast = true; - }; - - class AccessField: public UnionField::TransformedMember { public: AccessField(DataField * parent, ModuleData& module): @@ -2331,7 +2297,6 @@ class ModuleUnionField: public UnionField { { if (version >= 219) { Append(new AccessField(parent, module)); - Append(new Afhds3Field(parent, module)); Append(new GhostField(parent, module)); } Append(new PxxField(parent, module, version)); diff --git a/companion/src/firmwares/opentx/opentxeeprom.h b/companion/src/firmwares/opentx/opentxeeprom.h index 5e026d84ad7..813b4e66974 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.h +++ b/companion/src/firmwares/opentx/opentxeeprom.h @@ -112,10 +112,6 @@ class ProtocolsConversionTable: public ConversionTable addConversion(PULSES_XJT_LITE_X16, val); addConversion(PULSES_XJT_LITE_D8, val); addConversion(PULSES_XJT_LITE_LR12, val++); - - if (version >= 219) { - addConversion(PULSES_AFHDS3, val++); - } } }; diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index aff7f3909cd..7bf3ed0a664 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -116,6 +116,8 @@ const char * OpenTxEepromInterface::getName() return "EdgeTX for FrSky X10 Express"; case BOARD_FLYSKY_NV14: return "EdgeTX for FlySky NV14"; + case BOARD_FLYSKY_EL18: + return "EdgeTX for FlySky EL18"; case BOARD_BETAFPV_LR3PRO: return "EdgeTx for BETAFPV LR3PRO"; case BOARD_IFLIGHT_COMMANDO8: @@ -656,7 +658,7 @@ int OpenTxFirmware::getCapability(::Capability capability) case HasSDLogs: return true; case LcdWidth: - if (IS_FLYSKY_NV14(board)) + if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) return 320; else if (IS_FAMILY_HORUS_OR_T16(board)) return 480; @@ -667,7 +669,7 @@ int OpenTxFirmware::getCapability(::Capability capability) else return 128; case LcdHeight: - if (IS_FLYSKY_NV14(board)) + if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) return 480; else if (IS_FAMILY_HORUS_OR_T16(board)) return 272; @@ -761,7 +763,7 @@ int OpenTxFirmware::getCapability(::Capability capability) else return 40; case HasAuxSerialMode: - return (IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board)) || + return (IS_FAMILY_HORUS_OR_T16(board) && !(IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))) || (IS_TARANIS_X9(board) && !IS_TARANIS_X9DP_2019(board)) || IS_RADIOMASTER_ZORRO(board) || IS_RADIOMASTER_TX12_MK2(board); case HasAux2SerialMode: @@ -770,7 +772,8 @@ int OpenTxFirmware::getCapability(::Capability capability) return IS_FAMILY_HORUS_OR_T16(board) || IS_RADIOMASTER_ZORRO(board) || IS_JUMPER_TPRO(board) || IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_BOXER(board); case HasBluetooth: - return (IS_FAMILY_HORUS_OR_T16(board) || IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board)|| IS_TARANIS_X9E(board) || IS_TARANIS_X9DP_2019(board) || IS_FLYSKY_NV14(board)) ? true : false; + return (IS_FAMILY_HORUS_OR_T16(board) || IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board)|| IS_TARANIS_X9E(board) || + IS_TARANIS_X9DP_2019(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) ? true : false; case HasADCJitterFilter: return IS_HORUS_OR_TARANIS(board); case HasTelemetryBaudrate: @@ -801,7 +804,8 @@ int OpenTxFirmware::getCapability(::Capability capability) return id.contains("internalelrs") || IS_RADIOMASTER_TX12_MK2(board) || IS_IFLIGHT_COMMANDO8(board) || IS_RADIOMASTER_BOXER(board); case HasIntModuleFlySky: - return id.contains("afhds3") || IS_FLYSKY_NV14(board); + return id.contains("afhds2a") || id.contains("afhds3") || + IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board); default: return 0; } @@ -1136,13 +1140,15 @@ enum RfOptions { NONE = 0, EU = 1 << 0, FLEX = 1 << 1, - AFHDS3 = 1 << 2 + AFHDS2A = 1 << 2, + AFHDS3 = 1 << 3, }; void addOpenTxRfOptions(OpenTxFirmware * firmware, uint8_t options) { static const Firmware::Option opt_eu("eu", Firmware::tr("Removes D8 FrSky protocol support which is not legal for use in the EU on radios sold after Jan 1st, 2015")); static const Firmware::Option opt_fl("flexr9m", Firmware::tr("Enable non certified firmwares")); + static const Firmware::Option opt_afhds2a("afhds2a", Firmware::tr("Enable AFHDS2A support")); static const Firmware::Option opt_afhds3("afhds3", Firmware::tr("Enable AFHDS3 support")); @@ -1152,6 +1158,8 @@ void addOpenTxRfOptions(OpenTxFirmware * firmware, uint8_t options) firmware->addOption(opt_eu); else if ((options & FLEX) != 0) firmware->addOption(opt_fl); + if ((options & AFHDS2A) != 0) + firmware->addOption(opt_afhds2a); if ((options & AFHDS3) != 0) firmware->addOption(opt_afhds3); } @@ -1205,7 +1213,7 @@ void registerOpenTxFirmwares() firmware->addOption("noras", Firmware::tr("Disable RAS (SWR)")); addOpenTxTaranisOptions(firmware); registerOpenTxFirmware(firmware); - addOpenTxRfOptions(firmware, EU + FLEX + AFHDS3); + addOpenTxRfOptions(firmware, EU + FLEX + AFHDS2A + AFHDS3); /* FrSky Taranis X9D+ 2019 board */ firmware = new OpenTxFirmware(FIRMWAREID("x9d+2019"), Firmware::tr("FrSky Taranis X9D+ 2019"), BOARD_TARANIS_X9DP_2019, "x9dp2019"); @@ -1219,7 +1227,7 @@ void registerOpenTxFirmwares() firmware->addOption("haptic", Firmware::tr("Haptic module installed")); addOpenTxTaranisOptions(firmware); registerOpenTxFirmware(firmware); - addOpenTxRfOptions(firmware, EU + FLEX + AFHDS3); + addOpenTxRfOptions(firmware, EU + FLEX + AFHDS2A + AFHDS3); /* FrSky Taranis X9E board */ firmware = new OpenTxFirmware(FIRMWAREID("x9e"), Firmware::tr("FrSky Taranis X9E"), BOARD_TARANIS_X9E); @@ -1365,7 +1373,7 @@ void registerOpenTxFirmwares() firmware->addOption("internalelrs", Firmware::tr("Select if internal ELRS module is installed")); addOpenTxFontOptions(firmware); registerOpenTxFirmware(firmware); - addOpenTxRfOptions(firmware, FLEX + AFHDS3); + addOpenTxRfOptions(firmware, FLEX + AFHDS2A + AFHDS3); /* Radiomaster Boxer board */ firmware = new OpenTxFirmware(FIRMWAREID("boxer"), QCoreApplication::translate("Firmware", "Radiomaster Boxer"), Board::BOARD_RADIOMASTER_BOXER); @@ -1375,7 +1383,7 @@ void registerOpenTxFirmwares() firmware->addOption("lua", Firmware::tr("Enable Lua custom scripts screen")); addOpenTxFontOptions(firmware); registerOpenTxFirmware(firmware); - addOpenTxRfOptions(firmware, FLEX + AFHDS3); + addOpenTxRfOptions(firmware, FLEX + AFHDS2A + AFHDS3); /* Radiomaster T8 board */ firmware = new OpenTxFirmware(FIRMWAREID("t8"), QCoreApplication::translate("Firmware", "Radiomaster T8"), BOARD_RADIOMASTER_T8); @@ -1409,7 +1417,14 @@ void registerOpenTxFirmwares() firmware = new OpenTxFirmware(FIRMWAREID("nv14"), QCoreApplication::translate("Firmware", "FlySky NV14"), BOARD_FLYSKY_NV14); addOpenTxFrskyOptions(firmware); firmware->addOption("bluetooth", Firmware::tr("Support for bluetooth module")); - addOpenTxRfOptions(firmware, FLEX + AFHDS3); + addOpenTxRfOptions(firmware, FLEX + AFHDS2A + AFHDS3); + registerOpenTxFirmware(firmware); + + /* FlySky EL18 board */ + firmware = new OpenTxFirmware(FIRMWAREID("el18"), QCoreApplication::translate("Firmware", "FlySky EL18"), BOARD_FLYSKY_EL18); + addOpenTxFrskyOptions(firmware); + firmware->addOption("bluetooth", Firmware::tr("Support for bluetooth module")); + addOpenTxRfOptions(firmware, FLEX + AFHDS2A + AFHDS3); registerOpenTxFirmware(firmware); /* BETAFPV LR3PRO board */ diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 6cf44641f65..cf5aaa0d42a 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -225,6 +225,7 @@ void TimerPanel::onModeChanged(int index) #define MASK_MULTI_DSM_OPT (1<<19) #define MASK_CHANNELMAP (1<<20) #define MASK_MULTI_BAYANG_OPT (1<<21) +#define MASK_AFHDS (1<<22) quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT; @@ -320,9 +321,32 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul connect(ui->clearRx1, SIGNAL(clicked()), this, SLOT(onClearAccessRxClicked())); connect(ui->clearRx2, SIGNAL(clicked()), this, SLOT(onClearAccessRxClicked())); connect(ui->clearRx3, SIGNAL(clicked()), this, SLOT(onClearAccessRxClicked())); + connect(ui->cboAfhdsOpt1, static_cast(&QComboBox::currentIndexChanged), [=] (int index) + { + if (lock) + return; - lock = false; + if (this->module.protocol == PULSES_FLYSKY_AFHDS2A) + Helpers::setBitmappedValue(this->module.flysky.mode, ui->cboAfhdsOpt1->currentData().toInt(), 1); + else + this->module.afhds3.phyMode = ui->cboAfhdsOpt1->currentData().toInt(); + + emit modified(); + }); + connect(ui->cboAfhdsOpt2, static_cast(&QComboBox::currentIndexChanged), [=] (int index) + { + if (lock) + return; + + if (this->module.protocol == PULSES_FLYSKY_AFHDS2A) + Helpers::setBitmappedValue(this->module.flysky.mode, ui->cboAfhdsOpt2->currentData().toInt(), 0); + else + this->module.afhds3.emi = ui->cboAfhdsOpt2->currentData().toInt(); + + emit modified(); + }); + lock = false; } ModulePanel::~ModulePanel() @@ -529,10 +553,10 @@ void ModulePanel::update() if (pdef.disableChannelMap) mask |= MASK_CHANNELMAP; break; - case PULSES_AFHDS3: - module.channelsCount = 18; - mask |= MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT | MASK_FAILSAFES; - mask |= MASK_SUBTYPES | MASK_RX_FREQ | MASK_RF_POWER; + case PULSES_FLYSKY_AFHDS3: + mask |= MASK_RX_NUMBER; + case PULSES_FLYSKY_AFHDS2A: + mask |= MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT | MASK_FAILSAFES | MASK_AFHDS; break; case PULSES_LEMON_DSMP: mask |= MASK_CHANNELS_RANGE; @@ -638,9 +662,6 @@ void ModulePanel::update() if (firmware->getCapability(HasModuleR9MFlex)) i = 2; break; - case PULSES_AFHDS3: - numEntries = 4; - break; case PULSES_PPM: numEntries = PPM_NUM_SUBTYPES; break; @@ -755,11 +776,33 @@ void ModulePanel::update() ui->clearRx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2))); ui->rx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2))); + // AFHFS + if (mask & MASK_AFHDS) { + if (protocol == PULSES_FLYSKY_AFHDS2A) { + ui->label_afhds->setText(tr("Options")); + ui->cboAfhdsOpt1->setModel(ModuleData::afhds2aMode1ItemModel()); + ui->cboAfhdsOpt1->setCurrentIndex(Helpers::getBitmappedValue(module.flysky.mode, 1)); + + ui->cboAfhdsOpt2->setModel(ModuleData::afhds2aMode2ItemModel()); + ui->cboAfhdsOpt2->setCurrentIndex(Helpers::getBitmappedValue(module.flysky.mode, 0)); + } + else { + ui->label_afhds->setText(tr("Type")); + ui->cboAfhdsOpt1->setModel(ModuleData::afhds3PhyModeItemModel()); + ui->cboAfhdsOpt1->setCurrentIndex(ui->cboAfhdsOpt1->findData(module.afhds3.phyMode)); + + ui->cboAfhdsOpt2->setModel(ModuleData::afhds3EmiItemModel()); + ui->cboAfhdsOpt2->setCurrentIndex(ui->cboAfhdsOpt2->findData(module.afhds3.emi)); + } + } + + ui->label_afhds->setVisible(mask & MASK_AFHDS); + ui->cboAfhdsOpt1->setVisible(mask & MASK_AFHDS); + ui->cboAfhdsOpt2->setVisible(mask & MASK_AFHDS); + // Failsafes ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES); ui->failsafeMode->setVisible(mask & MASK_FAILSAFES); - //hide reciever mode for afhds3 - qobject_cast(ui->failsafeMode->view())->setRowHidden(FAILSAFE_RECEIVER, protocol == PULSES_AFHDS3); if ((mask & MASK_FAILSAFES) && module.failsafeMode == FAILSAFE_CUSTOM) { if (ui->failsafesGroupBox->isHidden()) { @@ -813,6 +856,12 @@ void ModulePanel::onProtocolChanged(int index) ui->telemetryBaudrate->setCurrentIndex(1); } } + else if (module.protocol == PULSES_FLYSKY_AFHDS2A) { + module.flysky.setDefault(); + } + else if (module.protocol == PULSES_FLYSKY_AFHDS3) { + module.afhds3.setDefault(); + } emit protocolChanged(); emit updateItemModels(); @@ -832,7 +881,11 @@ void ModulePanel::on_r9mPower_currentIndexChanged(int index) { if (!lock) { - if (module.protocol == PULSES_AFHDS3 && module.afhds3.rfPower != (unsigned int)index) { + if (module.protocol == PULSES_FLYSKY_AFHDS2A && module.flysky.rfPower != (unsigned int)index) { + module.flysky.rfPower = index; + emit modified(); + } + else if (module.protocol == PULSES_FLYSKY_AFHDS3 && module.afhds3.rfPower != (unsigned int)index) { module.afhds3.rfPower = index; emit modified(); } @@ -978,19 +1031,17 @@ void ModulePanel::onSubTypeChanged() if (!lock && module.subType != type) { lock=true; module.subType = type; - if (module.protocol != PULSES_AFHDS3) { - update(); - } emit modified(); lock = false; } } void ModulePanel::onRfFreqChanged(int freq) { - if (module.afhds3.rxFreq != (unsigned int)freq) { - module.afhds3.rxFreq = (unsigned int)freq; - emit modified(); - } + // TODO fix for AFHDS2A + //if (module.afhds3.rxFreq != (unsigned int)freq) { + // module.afhds3.rxFreq = (unsigned int)freq; + // emit modified(); + //} } void ModulePanel::on_disableTelem_stateChanged(int state) diff --git a/companion/src/modeledit/setup_module.ui b/companion/src/modeledit/setup_module.ui index 3adbb69e569..51e71f6f9c3 100644 --- a/companion/src/modeledit/setup_module.ui +++ b/companion/src/modeledit/setup_module.ui @@ -232,7 +232,7 @@ - + @@ -276,7 +276,7 @@ - + @@ -292,7 +292,7 @@ - + @@ -336,7 +336,7 @@ - + @@ -352,7 +352,7 @@ - + @@ -371,35 +371,35 @@ - + Disable Telemetry - + Disable Ch. Map - + Racing Mode - + Raw 12 bits - + Qt::Horizontal @@ -412,6 +412,23 @@ + + + + Options + + + + + + + + + + + + + diff --git a/companion/src/modelprinter.cpp b/companion/src/modelprinter.cpp index 7e851205700..64113fc95f2 100644 --- a/companion/src/modelprinter.cpp +++ b/companion/src/modelprinter.cpp @@ -215,7 +215,8 @@ QString ModelPrinter::printModule(int idx) str << printLabelValue(tr("Delay"), QString("%1us").arg(module.ppm.delay)); } else { - if (!(module.protocol == PULSES_PXX_XJT_D8 || module.protocol == PULSES_CROSSFIRE || module.protocol == PULSES_GHOST || module.protocol == PULSES_SBUS)) { + if (!(module.protocol == PULSES_PXX_XJT_D8 || module.protocol == PULSES_CROSSFIRE || + module.protocol == PULSES_GHOST || module.protocol == PULSES_SBUS || module.protocol == PULSES_FLYSKY_AFHDS2A)) { str << printLabelValue(tr("Receiver"), QString::number(module.modelId)); } if (module.protocol == PULSES_MULTIMODULE) { @@ -227,10 +228,11 @@ QString ModelPrinter::printModule(int idx) str << printLabelValue(tr("Sub Type"), module.subTypeToString()); str << printLabelValue(tr("RF Output Power"), module.powerValueToString(firmware)); } - if (module.protocol == PULSES_AFHDS3) { - str << printLabelValue(tr("Output Type"), module.subTypeToString()); - str << printLabelValue(tr("RF Output Power"), module.powerValueToString(firmware)); - str << printLabelValue(tr("RX Output Frequency"), QString("%1Hz").arg(module.afhds3.rxFreq)); + if (module.protocol == PULSES_FLYSKY_AFHDS2A) { + str << printLabelValue(tr("Options"), module.afhds2aMode1ToString() + " " + module.afhds2aMode2ToString()); + } + if (module.protocol == PULSES_FLYSKY_AFHDS3) { + str << printLabelValue(tr("Type"), module.afhds3PhyModeToString() + " " + module.afhds3EmiToString()); } if (module.protocol == PULSES_GHOST) { str << printLabelValue(tr("Raw 12 bits"), printBoolean(module.ghost.raw12bits, BOOLEAN_YN)); diff --git a/companion/src/simulation/CMakeLists.txt b/companion/src/simulation/CMakeLists.txt index 34f190f42f9..1335b8b4f3f 100644 --- a/companion/src/simulation/CMakeLists.txt +++ b/companion/src/simulation/CMakeLists.txt @@ -25,6 +25,7 @@ set(simulation_SRCS simulateduiwidgetT8.cpp simulateduiwidgetTX16S.cpp simulateduiwidgetNV14.cpp + simulateduiwidgetEL18.cpp simulatorinterface.cpp simulatormainwindow.cpp simulatorstartupdialog.cpp @@ -61,6 +62,7 @@ set(simulation_UIS simulateduiwidgetT8.ui simulateduiwidgetTX16S.ui simulateduiwidgetNV14.ui + simulateduiwidgetEL18.ui simulatormainwindow.ui simulatorstartupdialog.ui simulatorwidget.ui diff --git a/companion/src/simulation/simulateduiwidget.h b/companion/src/simulation/simulateduiwidget.h index e4eb209ff6d..a3856aa86a1 100644 --- a/companion/src/simulation/simulateduiwidget.h +++ b/companion/src/simulation/simulateduiwidget.h @@ -124,6 +124,7 @@ namespace Ui { class SimulatedUIWidgetBoxer; class SimulatedUIWidgetT8; class SimulatedUIWidgetNV14; + class SimulatedUIWidgetEL18; } class SimulatedUIWidget9X: public SimulatedUIWidget @@ -241,7 +242,7 @@ class SimulatedUIWidgetX12: public SimulatedUIWidget class SimulatedUIWidgetLR3PRO: public SimulatedUIWidget { Q_OBJECT - + public: explicit SimulatedUIWidgetLR3PRO(SimulatorInterface * simulator, QWidget * parent = NULL); virtual ~SimulatedUIWidgetLR3PRO(); @@ -394,4 +395,16 @@ class SimulatedUIWidgetNV14: public SimulatedUIWidget Ui::SimulatedUIWidgetNV14 * ui; }; +class SimulatedUIWidgetEL18: public SimulatedUIWidget +{ + Q_OBJECT + + public: + explicit SimulatedUIWidgetEL18(SimulatorInterface * simulator, QWidget * parent = nullptr); + virtual ~SimulatedUIWidgetEL18(); + + private: + Ui::SimulatedUIWidgetEL18 * ui; +}; + #endif // SIMULATEDUIWIDGET_H diff --git a/companion/src/simulation/simulateduiwidgetEL18.cpp b/companion/src/simulation/simulateduiwidgetEL18.cpp new file mode 100644 index 00000000000..9285f1f6ccc --- /dev/null +++ b/companion/src/simulation/simulateduiwidgetEL18.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * 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. + */ + +// NOTE: RadioUiAction(NUMBER,...): NUMBER relates to enum EnumKeys in the specific board.h + +#include "simulateduiwidget.h" +#include "ui_simulateduiwidgetEL18.h" + +SimulatedUIWidgetEL18::SimulatedUIWidgetEL18(SimulatorInterface *simulator, QWidget * parent): + SimulatedUIWidget(simulator, parent), + ui(new Ui::SimulatedUIWidgetEL18) +{ + RadioUiAction * act; + + ui->setupUi(this); + + // add actions in order of appearance on the help menu + + // Note: the EL18 has no physical buttons though at some point the trim joystick is repurposed + // allow for colorlcd key events and see what works + // the mouse click areas do not map to visual buttons on the background images + + act = new RadioUiAction(12, QList() << Qt::Key_Up, SIMU_STR_HLP_KEY_UP, SIMU_STR_HLP_ACT_MDL); + addRadioWidget(ui->rightbuttons->addArea(QRect(10, 1, 80, 35), "NV14/left.png", act)); + + m_mouseMidClickAction = new RadioUiAction(2, QList() << Qt::Key_Enter << Qt::Key_Return, SIMU_STR_HLP_KEYS_ACTIVATE, SIMU_STR_HLP_ACT_ROT_DN); + addRadioWidget(ui->rightbuttons->addArea(QRect(10, 40, 80, 35), "NV14/left.png", m_mouseMidClickAction)); + + act = new RadioUiAction(14, QList() << Qt::Key_Left, SIMU_STR_HLP_KEY_LFT, SIMU_STR_HLP_ACT_SYS); + addRadioWidget(ui->leftbuttons->addArea(QRect(10, 80, 80, 35), "NV14/left.png", act)); + + act = new RadioUiAction(13, QList() << Qt::Key_Right, SIMU_STR_HLP_KEY_RGT, SIMU_STR_HLP_ACT_TELE); + addRadioWidget(ui->leftbuttons->addArea(QRect(10, 120, 80, 35), "NV14/left.png", act)); + + act = new RadioUiAction(5, QList() << Qt::Key_PageDown, SIMU_STR_HLP_KEY_PGDN, SIMU_STR_HLP_ACT_PGDN); + addRadioWidget(ui->leftbuttons->addArea(QRect(10, 160, 80, 35), "NV14/left.png", act)); + + act = new RadioUiAction(4, QList() << Qt::Key_PageUp, SIMU_STR_HLP_KEY_PGUP, SIMU_STR_HLP_ACT_PGUP); + addRadioWidget(ui->leftbuttons->addArea(QRect(10, 200, 80, 35), "NV14/left.png", act)); + + act = new RadioUiAction(1, QList() << Qt::Key_Down << Qt::Key_Delete << Qt::Key_Escape << Qt::Key_Backspace, + SIMU_STR_HLP_KEY_DN % "
" % SIMU_STR_HLP_KEYS_EXIT, SIMU_STR_HLP_ACT_RTN); + addRadioWidget(ui->leftbuttons->addArea(QRect(10, 240, 80, 35), "NV14/left.png", act)); + + m_scrollUpAction = new RadioUiAction(-1, QList() << Qt::Key_Minus, SIMU_STR_HLP_KEY_MIN % "|" % SIMU_STR_HLP_MOUSE_UP, SIMU_STR_HLP_ACT_ROT_LFT); + m_scrollDnAction = new RadioUiAction(-1, QList() << Qt::Key_Plus << Qt::Key_Equal, SIMU_STR_HLP_KEY_PLS % "|" % SIMU_STR_HLP_MOUSE_DN, SIMU_STR_HLP_ACT_ROT_RGT); + connectScrollActions(); + + addRadioWidget(ui->leftbuttons->addArea(QRect(10, 280, 30, 30), "NV14/left.png", m_screenshotAction)); + + m_backlightColors << QColor(47, 123, 227); + + setLcd(ui->lcd); +} + +SimulatedUIWidgetEL18::~SimulatedUIWidgetEL18() +{ + delete ui; +} diff --git a/companion/src/simulation/simulateduiwidgetEL18.ui b/companion/src/simulation/simulateduiwidgetEL18.ui new file mode 100644 index 00000000000..af70d45c50d --- /dev/null +++ b/companion/src/simulation/simulateduiwidgetEL18.ui @@ -0,0 +1,206 @@ + + + SimulatedUIWidgetEL18 + + + + 0 + 0 + 520 + 500 + + + + + 0 + 0 + + + + + 520 + 500 + + + + + 520 + 500 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 100 + 500 + + + + + 100 + 500 + + + + background:url(:/images/simulator/NV14/right.png) + + + + + + + + 0 + 0 + + + + + 320 + 480 + + + + + 320 + 480 + + + + + 5 + + + + + + + + + 0 + 0 + + + + + 100 + 500 + + + + + 100 + 500 + + + + true + + + background:url(:/images/simulator/NV14/left.png); + + + + + + + + 0 + 0 + + + + + 320 + 10 + + + + + 320 + 10 + + + + + 5 + + + + background:url(:/images/simulator/NV14/top.png) + + + + + + + + 0 + 0 + + + + + 320 + 10 + + + + + 320 + 10 + + + + + 5 + false + + + + background:url(:/images/simulator/NV14/bottom.png) + + + + + + + + LcdWidget + QWidget +
lcdwidget.h
+ 1 +
+ + ButtonsWidget + QWidget +
buttonswidget.h
+ 1 +
+
+ + +
diff --git a/companion/src/simulation/simulatorwidget.cpp b/companion/src/simulation/simulatorwidget.cpp index de23e3d6c0f..0586f35dd13 100644 --- a/companion/src/simulation/simulatorwidget.cpp +++ b/companion/src/simulation/simulatorwidget.cpp @@ -128,6 +128,9 @@ SimulatorWidget::SimulatorWidget(QWidget * parent, SimulatorInterface * simulato case Board::BOARD_FLYSKY_NV14: radioUiWidget = new SimulatedUIWidgetNV14(simulator, this); break; + case Board::BOARD_FLYSKY_EL18: + radioUiWidget = new SimulatedUIWidgetEL18(simulator, this); + break; default: radioUiWidget = new SimulatedUIWidget9X(simulator, this); break; diff --git a/fw.json b/fw.json index 790bc202311..c9cfd836e5c 100644 --- a/fw.json +++ b/fw.json @@ -1,7 +1,7 @@ { "targets": [ ["BETAFPV LiteRadio 3 Pro", "lr3pro-"], - ["Flysky EL18", "nv14-"], + ["Flysky EL18", "el18-"], ["Flysky NV14", "nv14-"], ["FrSky Horus X10", "x10-"], ["FrSky Horus X10 Access", "x10-access-"], diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index b1012ae31cc..0dd13401e08 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -455,7 +455,7 @@ PACK(struct PpmModule { }); PACK(struct ModuleData { - uint8_t type ENUM(ModuleType); + uint8_t type ENUM(ModuleType) CUST(r_moduleType, w_moduleType); CUST_ATTR(subType,r_modSubtype,w_modSubtype); uint8_t channelsStart; int8_t channelsCount CUST(r_channelsCount,w_channelsCount); // 0=8 channels diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index f84f13302e7..087fb0c14e8 100644 --- a/radio/src/gui/colorlcd/CMakeLists.txt +++ b/radio/src/gui/colorlcd/CMakeLists.txt @@ -138,11 +138,13 @@ if(CROSSFIRE) add_gui_src(crossfire_settings.cpp) endif() -if(AFHDS2 OR AFHDS3) - add_gui_src(flysky_settings.cpp) - if(AFHDS3) - add_gui_src(afhds3_options.cpp) - endif() +if(AFHDS2) + add_gui_src(afhds2a_settings.cpp) +endif() + +if(AFHDS3) + add_gui_src(afhds3_settings.cpp) + add_gui_src(afhds3_options.cpp) endif() if(MULTIMODULE) diff --git a/radio/src/gui/colorlcd/afhds2a_settings.cpp b/radio/src/gui/colorlcd/afhds2a_settings.cpp new file mode 100644 index 00000000000..7b926d9c430 --- /dev/null +++ b/radio/src/gui/colorlcd/afhds2a_settings.cpp @@ -0,0 +1,141 @@ +/* + * 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 "afhds2a_settings.h" +#include "opentx.h" + +#include "pulses/flysky.h" + +#define SET_DIRTY() storageDirty(EE_MODEL) + +class FSProtoOpts : public FormWindow +{ + std::function _getMode; + std::function _setMode; + +public: + FSProtoOpts(Window* parent, std::function getMode, + std::function setMode); +}; + +FSProtoOpts::FSProtoOpts(Window* parent, std::function getMode, + std::function setMode) : + FormWindow(parent, rect_t{}), + _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, + [=]() -> 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, + [=]() -> int { return _getMode() & 1; }, + [=](int v) { + _setMode((_getMode() & 2) | (v & 1)); + SET_DIRTY(); + }); +} + +AFHDS2ASettings::AFHDS2ASettings(Window* parent, const FlexGridLayout& g, + uint8_t moduleIdx) : + FormWindow(parent, rect_t{}), + moduleIdx(moduleIdx), + md(&g_model.moduleData[moduleIdx]), + grid(g) +{ + setFlexLayout(); + + FormWindow::Line* line; + + // 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(); +} + +void AFHDS2ASettings::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 AFHDS2ASettings::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); + lv_event_send(afhds2RFPowerChoice->getLvObj(), LV_EVENT_VALUE_CHANGED, nullptr); + } +#endif +} + +void AFHDS2ASettings::checkEvents() { + FormWindow::checkEvents(); +} + +void AFHDS2ASettings::update() +{ + lastRefresh = get_tmr10ms(); + if (isModuleAFHDS2A(moduleIdx)) { + showAFHDS2Options(); + } else { + hideAFHDS2Options(); + } +} diff --git a/radio/src/gui/colorlcd/afhds2a_settings.h b/radio/src/gui/colorlcd/afhds2a_settings.h new file mode 100644 index 00000000000..4c278d7f131 --- /dev/null +++ b/radio/src/gui/colorlcd/afhds2a_settings.h @@ -0,0 +1,51 @@ +/* + * 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 "form.h" +#include "choice.h" +#include "module_setup.h" + +struct ModuleData; + +class AFHDS2ASettings : public FormWindow, public ModuleOptions +{ + uint8_t moduleIdx; + ModuleData* md; + FlexGridLayout grid; + tmr10ms_t lastRefresh = 0; + + Window* afhds2OptionsLabel = nullptr; + Window* afhds2ProtoOpts = nullptr; +#if defined(PCBNV14) + Window* afhds2RFPowerText = nullptr; + Window* afhds2RFPowerChoice = nullptr; +#endif + void hideAFHDS2Options(); + void showAFHDS2Options(); + + void checkEvents() override; + void update() override; + +public: + AFHDS2ASettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx); +}; diff --git a/radio/src/gui/colorlcd/flysky_settings.cpp b/radio/src/gui/colorlcd/afhds3_settings.cpp similarity index 59% rename from radio/src/gui/colorlcd/flysky_settings.cpp rename to radio/src/gui/colorlcd/afhds3_settings.cpp index 6760e538f09..f214db8bf38 100644 --- a/radio/src/gui/colorlcd/flysky_settings.cpp +++ b/radio/src/gui/colorlcd/afhds3_settings.cpp @@ -19,18 +19,9 @@ * GNU General Public License for more details. */ -#include "flysky_settings.h" -#include "opentx.h" - -#if defined(AFHDS3) +#include "afhds3_settings.h" #include "afhds3_options.h" -#endif - -#include "pulses/flysky.h" -#include "pulses/afhds3.h" -#include "pulses/afhds3_config.h" - -#define SET_DIRTY() storageDirty(EE_MODEL) +#include "opentx.h" static const char* _afhds3_region[] = { "CE", "FCC" }; @@ -44,44 +35,13 @@ static const char* _afhds3_phy_mode[] = { "Lora 12ch", }; -class FSProtoOpts : public FormWindow -{ - std::function _getMode; - std::function _setMode; - -public: - FSProtoOpts(Window* parent, std::function getMode, - std::function setMode); -}; - -FSProtoOpts::FSProtoOpts(Window* parent, std::function getMode, - std::function setMode) : - FormWindow(parent, rect_t{}), - _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, - [=]() -> int { return _getMode() >> 1; }, - [=](int v) { - _setMode((_getMode() & 1) | ((v & 1) << 1)); - SET_DIRTY(); - }); +#include "pulses/flysky.h" +#include "pulses/afhds3.h" +#include "pulses/afhds3_config.h" - // SBUS / iBUS - new Choice( - this, rect_t{}, STR_FLYSKY_SERIAL_PROTO, 0, 1, - [=]() -> int { return _getMode() & 1; }, - [=](int v) { - _setMode((_getMode() & 2) | (v & 1)); - SET_DIRTY(); - }); -} +#define SET_DIRTY() storageDirty(EE_MODEL) -FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g, +AFHDS3Settings::AFHDS3Settings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx) : FormWindow(parent, rect_t{}), moduleIdx(moduleIdx), @@ -92,33 +52,6 @@ FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g, FormWindow::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); @@ -164,40 +97,9 @@ FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g, } 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); - lv_event_send(afhds2RFPowerChoice->getLvObj(), LV_EVENT_VALUE_CHANGED, nullptr); - } -#endif -} -#endif - -#if defined(AFHDS3) -void FlySkySettings::hideAFHDS3Options() +void AFHDS3Settings::hideAFHDS3Options() { lv_obj_add_flag(afhds3StatusLabel->getLvObj(), LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(afhds3StatusText->getLvObj(), LV_OBJ_FLAG_HIDDEN); @@ -205,7 +107,7 @@ void FlySkySettings::hideAFHDS3Options() lv_obj_add_flag(afhds3TypeForm->getLvObj(), LV_OBJ_FLAG_HIDDEN); } -void FlySkySettings::showAFHDS3Options() +void AFHDS3Settings::showAFHDS3Options() { lv_obj_clear_flag(afhds3StatusLabel->getLvObj(), LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(afhds3StatusText->getLvObj(), LV_OBJ_FLAG_HIDDEN); @@ -228,31 +130,21 @@ void FlySkySettings::showAFHDS3Options() lv_obj_clear_state(afhds3Emi->getLvObj(), LV_STATE_DISABLED); } } -#endif -void FlySkySettings::checkEvents() { +void AFHDS3Settings::checkEvents() { if (afhds3::getConfig(moduleIdx)->others.lastUpdated > lastRefresh) { update(); } FormWindow::checkEvents(); } -void FlySkySettings::update() +void AFHDS3Settings::update() { lastRefresh = get_tmr10ms(); -#if defined(AFHDS2) - if (isModuleAFHDS2A(moduleIdx)) { - showAFHDS2Options(); - } else { - hideAFHDS2Options(); - } -#endif -#if defined(AFHDS3) if (isModuleAFHDS3(moduleIdx)) { showAFHDS3Options(); } else { hideAFHDS3Options(); } -#endif } diff --git a/radio/src/gui/colorlcd/flysky_settings.h b/radio/src/gui/colorlcd/afhds3_settings.h similarity index 75% rename from radio/src/gui/colorlcd/flysky_settings.h rename to radio/src/gui/colorlcd/afhds3_settings.h index 8c095be3c39..02e3112edd0 100644 --- a/radio/src/gui/colorlcd/flysky_settings.h +++ b/radio/src/gui/colorlcd/afhds3_settings.h @@ -27,25 +27,13 @@ struct ModuleData; -class FlySkySettings : public FormWindow, public ModuleOptions +class AFHDS3Settings : public FormWindow, public ModuleOptions { uint8_t moduleIdx; ModuleData* md; FlexGridLayout grid; tmr10ms_t lastRefresh = 0; -#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; @@ -55,11 +43,10 @@ class FlySkySettings : public FormWindow, public ModuleOptions Choice *afhds3RfPower = nullptr; void hideAFHDS3Options(); void showAFHDS3Options(); -#endif void checkEvents() override; void update() override; public: - FlySkySettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx); + AFHDS3Settings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx); }; diff --git a/radio/src/gui/colorlcd/channel_range.cpp b/radio/src/gui/colorlcd/channel_range.cpp index 2345a42df94..d2ea6c291cd 100644 --- a/radio/src/gui/colorlcd/channel_range.cpp +++ b/radio/src/gui/colorlcd/channel_range.cpp @@ -57,12 +57,18 @@ void ChannelRange::build() chStart = new NumberEdit(this, rect_t{}, 1, 1, GET_DEFAULT(1 + getChannelsStart())); chStart->setSetValueHandler([=](int newValue) { setStart(newValue); }); chStart->setPrefix(STR_CH); +#if LCD_H > LCD_W + chStart->setWidth(LCD_W/3-10); +#endif chEnd = new NumberEdit(this, rect_t{}, 8, 8, GET_DEFAULT(getChannelsStart() + 8 + getChannelsCount())); chEnd->setPrefix(STR_CH); chEnd->setSetValueHandler([=](int newValue) { setEnd(newValue); }); +#if LCD_H > LCD_W + chEnd->setWidth(LCD_W/3-10); +#endif } void ChannelRange::setStart(uint8_t newValue) diff --git a/radio/src/gui/colorlcd/module_setup.cpp b/radio/src/gui/colorlcd/module_setup.cpp index 30f2c95d5e4..c6b85be21dc 100644 --- a/radio/src/gui/colorlcd/module_setup.cpp +++ b/radio/src/gui/colorlcd/module_setup.cpp @@ -46,8 +46,12 @@ #include "crossfire_settings.h" #endif -#if defined(AFHDS2) || defined(AFHDS3) -#include "flysky_settings.h" +#if defined(AFHDS2) +#include "afhds2a_settings.h" +#endif + +#if defined(AFHDS3) +#include "afhds3_settings.h" #endif #if defined(AFHDS2) @@ -213,9 +217,14 @@ void ModuleWindow::updateModule() modOpts = new CrossfireSettings(this, grid, moduleIdx); } #endif -#if defined(AFHDS2) || defined(AFHDS3) - else if (isModuleFlySky(moduleIdx)) { - modOpts = new FlySkySettings(this, grid, moduleIdx); +#if defined(AFHDS2) + else if (isModuleAFHDS2A(moduleIdx)) { + modOpts = new AFHDS2ASettings(this, grid, moduleIdx); + } +#endif +#if defined(AFHDS3) + else if (isModuleAFHDS3(moduleIdx)) { + modOpts = new AFHDS3Settings(this, grid, moduleIdx); } #endif #if defined(MULTIMODULE) @@ -306,7 +315,7 @@ void ModuleWindow::updateModule() } #endif #if defined(AFHDS2) - if (isModuleFlySky(moduleIdx)) resetPulsesAFHDS2(); + if (isModuleAFHDS2A(moduleIdx)) resetPulsesAFHDS2(); #endif if (isModuleDSMP(moduleIdx)) restartModule(moduleIdx); return 0; @@ -325,7 +334,7 @@ void ModuleWindow::updateModule() #endif moduleState[moduleIdx].mode = MODULE_MODE_BIND; #if defined(AFHDS2) - if (isModuleFlySky(moduleIdx)) { + if (isModuleAFHDS2A(moduleIdx)) { resetPulsesAFHDS2(); } #endif @@ -363,13 +372,13 @@ void ModuleWindow::updateModule() } else { moduleState[moduleIdx].mode = MODULE_MODE_RANGECHECK; #if defined(AFHDS2) - if (isModuleFlySky(moduleIdx)) { + if (isModuleAFHDS2A(moduleIdx)) { resetPulsesAFHDS2(); } #endif startRSSIDialog([=]() { #if defined(AFHDS2) - if (isModuleFlySky(moduleIdx)) { + if (isModuleAFHDS2A(moduleIdx)) { resetPulsesAFHDS2(); } #endif @@ -626,33 +635,6 @@ void ModuleSubTypeChoice::update() setTextHandler(nullptr); } #endif -#if defined(AFHDS2) || defined(AFHDS3) - else if (isModuleFlySky(moduleIdx)) { - setMin(0); - setMax(FLYSKY_SUBTYPE_AFHDS2A); - setValues(STR_FLYSKY_PROTOCOLS); - setGetValueHandler(GET_DEFAULT(md->subType)); - setSetValueHandler(SET_DEFAULT(md->subType)); - -#if defined(PCBNV14) && !defined(SIMU) - if (moduleIdx == INTERNAL_MODULE) { - if (hardwareOptions.pcbrev == PCBREV_NV14) { - md->subType = FLYSKY_SUBTYPE_AFHDS2A; - setAvailableHandler([](int v) { return v == FLYSKY_SUBTYPE_AFHDS2A; }); - } else { - md->subType = FLYSKY_SUBTYPE_AFHDS3; - setAvailableHandler([](int v) { return v == FLYSKY_SUBTYPE_AFHDS3; }); - } - } -#elif !defined(SIMU) - md->subType = FLYSKY_SUBTYPE_AFHDS3; - setAvailableHandler([](int v) { return v == FLYSKY_SUBTYPE_AFHDS3; }); -#else - setAvailableHandler(nullptr); -#endif - setTextHandler(nullptr); - } -#endif #if defined(MULTIMODULE) else if (isModuleMultimodule(moduleIdx)) { setMin(0); diff --git a/radio/src/gui/gui_common.cpp b/radio/src/gui/gui_common.cpp index 7069efc00d9..3163ea86c29 100644 --- a/radio/src/gui/gui_common.cpp +++ b/radio/src/gui/gui_common.cpp @@ -773,7 +773,8 @@ bool isModuleUsingSport(uint8_t moduleBay, uint8_t moduleType) case MODULE_TYPE_ISRM_PXX2: case MODULE_TYPE_R9M_LITE_PXX2: case MODULE_TYPE_R9M_LITE_PRO_PXX2: - case MODULE_TYPE_FLYSKY: + case MODULE_TYPE_FLYSKY_AFHDS2A: + case MODULE_TYPE_FLYSKY_AFHDS3: return false; case MODULE_TYPE_XJT_PXX1: @@ -823,8 +824,11 @@ bool isInternalModuleSupported(int moduleType) #if defined(INTERNAL_MODULE_PPM) case MODULE_TYPE_PPM: return true; #endif -#if defined(INTERNAL_MODULE_AFHDS2A) || defined(INTERNAL_MODULE_AFHDS3) - case MODULE_TYPE_FLYSKY: return true; +#if defined(INTERNAL_MODULE_AFHDS2A) + case MODULE_TYPE_FLYSKY_AFHDS2A: return true; +#endif +#if defined(INTERNAL_MODULE_AFHDS3) + case MODULE_TYPE_FLYSKY_AFHDS3: return true; #endif } return false; @@ -963,7 +967,17 @@ bool isExternalModuleAvailable(int moduleType) #endif #if !defined(AFHDS3) - if (moduleType == MODULE_TYPE_FLYSKY) + if (moduleType == MODULE_TYPE_FLYSKY_AFHDS3) + return false; +#endif + +#if !defined(AFHDS2) + if (moduleType == MODULE_TYPE_FLYSKY_AFHDS2A) + return false; +#endif + +#if !defined(AFHDS3) + if (moduleType == MODULE_TYPE_FLYSKY_AFHDS3) return false; #endif diff --git a/radio/src/pulses/modules_constants.h b/radio/src/pulses/modules_constants.h index a9aba62947b..6572ce71a98 100644 --- a/radio/src/pulses/modules_constants.h +++ b/radio/src/pulses/modules_constants.h @@ -40,7 +40,8 @@ enum ModuleType { MODULE_TYPE_R9M_LITE_PRO_PXX2, MODULE_TYPE_SBUS, MODULE_TYPE_XJT_LITE_PXX2, - MODULE_TYPE_FLYSKY, + MODULE_TYPE_FLYSKY_AFHDS2A, + MODULE_TYPE_FLYSKY_AFHDS3, MODULE_TYPE_LEMON_DSMP, MODULE_TYPE_COUNT SKIP, MODULE_TYPE_MAX SKIP = MODULE_TYPE_COUNT - 1 @@ -132,11 +133,6 @@ enum ModuleSubtypeDSM2 { DSM2_PROTO_DSMX, }; -enum ModuleSubtypeFlysky { - FLYSKY_SUBTYPE_AFHDS3=0, - FLYSKY_SUBTYPE_AFHDS2A -}; - enum FailsafeModes { FAILSAFE_NOT_SET, FAILSAFE_HOLD, diff --git a/radio/src/pulses/modules_helpers.h b/radio/src/pulses/modules_helpers.h index e5c918e918f..808ddbcb061 100644 --- a/radio/src/pulses/modules_helpers.h +++ b/radio/src/pulses/modules_helpers.h @@ -33,7 +33,7 @@ #include "telemetry/multi.h" #endif -#if defined(PCBNV14) +#if defined(PCBNV14) && defined(AFHDS2) extern uint32_t NV14internalModuleFwVersion; #endif @@ -398,22 +398,19 @@ inline bool isModuleSBUS(uint8_t moduleIdx) return g_model.moduleData[moduleIdx].type == MODULE_TYPE_SBUS; } -inline bool isModuleFlySky(uint8_t idx) +inline bool isModuleAFHDS2A(uint8_t idx) { - return - (g_model.moduleData[idx].type == MODULE_TYPE_FLYSKY); + return (g_model.moduleData[idx].type == MODULE_TYPE_FLYSKY_AFHDS2A); } -inline bool isModuleAFHDS2A(uint8_t idx) +inline bool isModuleAFHDS3(uint8_t idx) { - return isModuleFlySky(idx) - && (g_model.moduleData[idx].subType == FLYSKY_SUBTYPE_AFHDS2A); + return (g_model.moduleData[idx].type == MODULE_TYPE_FLYSKY_AFHDS3); } -inline bool isModuleAFHDS3(uint8_t idx) +inline bool isModuleFlySky(uint8_t idx) { - return isModuleFlySky(idx) - && (g_model.moduleData[idx].subType == FLYSKY_SUBTYPE_AFHDS3); + return (isModuleAFHDS2A(idx) || isModuleAFHDS3(idx)); } inline bool isModuleDSMP(uint8_t idx) @@ -439,7 +436,8 @@ static const int8_t maxChannelsModules_M8[] = { 0, // MODULE_TYPE_R9M_LITE_PRO_PXX2: index NOT USED 8, // MODULE_TYPE_SBUS 0, // MODULE_TYPE_XJT_LITE_PXX2: index NOT USED - 6, // MODULE_TYPE_FLYSKY: 14 channels for AFHDS2A, AFHDS3 special cased + 6, // MODULE_TYPE_FLYSKY_AFHDS2A: 14 channels + 10,// MODULE_TYPE_FLYSKY_AFHDS3: 18 channels 4, // MODULE_TYPE_LEMON_DSMP: 12 channels for DSMX }; @@ -484,8 +482,6 @@ inline int8_t maxModuleChannels_M8(uint8_t moduleIdx) } else { return 8; // always 16 channels in FCC / FLEX } - } else if (isModuleAFHDS3(moduleIdx)) { - return 10; } else if (isModuleMultimoduleDSM2(moduleIdx)) { return 4; // 12 channels } else if (isModuleDSMP(moduleIdx) && @@ -641,7 +637,7 @@ inline bool isModuleBindRangeAvailable(uint8_t moduleIdx) inline uint32_t getNV14RfFwVersion() { -#if defined(PCBNV14) +#if defined(PCBNV14) && defined(AFHDS2) return NV14internalModuleFwVersion; #else return 0; @@ -651,11 +647,11 @@ inline uint32_t getNV14RfFwVersion() inline bool isModuleRangeAvailable(uint8_t moduleIdx) { bool ret = isModuleBindRangeAvailable(moduleIdx) && !IS_RX_MULTI(moduleIdx); -#if defined(PCBNV14) +#if defined(PCBNV14) && defined(AFHDS2) ret = ret && - (!isModuleFlySky(moduleIdx) || NV14internalModuleFwVersion >= 0x1000E); -#else - ret = ret && (!isModuleFlySky(moduleIdx)); + (!isModuleAFHDS2A(moduleIdx) || NV14internalModuleFwVersion >= 0x1000E); +#elif defined(AFHDS3) + ret = ret && (!isModuleAFHDS3(moduleIdx)); #endif return ret; } @@ -805,22 +801,26 @@ inline void resetAccessAuthenticationCount() globalData.authenticationCount = 0; } -inline void resetAfhdsOptions(uint8_t moduleIdx) +inline void resetAfhds3Options(uint8_t moduleIdx) { #if defined(AFHDS3) auto & data = g_model.moduleData[moduleIdx]; - data.subType = FLYSKY_SUBTYPE_AFHDS3; + data.subType = 0; data.afhds3.emi = 2; // FCC data.afhds3.telemetry = 1; data.afhds3.phyMode = 0; -#elif defined(AFHDS2) +#endif +} + +inline void resetAfhds2AOptions(uint8_t moduleIdx) +{ +#if defined(AFHDS2) auto & data = g_model.moduleData[moduleIdx]; - data.subType = FLYSKY_SUBTYPE_AFHDS2A; + data.subType = 0; data.flysky.setDefault(); #endif } - inline void setModuleType(uint8_t moduleIdx, uint8_t moduleType) { ModuleData & moduleData = g_model.moduleData[moduleIdx]; @@ -831,8 +831,11 @@ inline void setModuleType(uint8_t moduleIdx, uint8_t moduleType) moduleData.sbus.refreshRate = -31; else if (moduleData.type == MODULE_TYPE_PPM) setDefaultPpmFrameLength(moduleIdx); - else if (moduleData.type == MODULE_TYPE_FLYSKY) { - resetAfhdsOptions(moduleIdx); + else if (moduleData.type == MODULE_TYPE_FLYSKY_AFHDS2A) { + resetAfhds2AOptions(moduleIdx); + } + else if (moduleData.type == MODULE_TYPE_FLYSKY_AFHDS3) { + resetAfhds3Options(moduleIdx); } else resetAccessAuthenticationCount(); diff --git a/radio/src/pulses/pulses.cpp b/radio/src/pulses/pulses.cpp index 7a5091909a7..ab30ffebe93 100755 --- a/radio/src/pulses/pulses.cpp +++ b/radio/src/pulses/pulses.cpp @@ -329,13 +329,15 @@ uint8_t getRequiredProtocol(uint8_t module) break; #endif -#if defined(AFHDS3) || defined(AFHDS2) - case MODULE_TYPE_FLYSKY: - if (isModuleAFHDS3(module)) { - protocol = PROTOCOL_CHANNELS_AFHDS3; - } else if (isModuleAFHDS2A(module)) { - protocol = PROTOCOL_CHANNELS_AFHDS2A; - } +#if defined(AFHDS2) + case MODULE_TYPE_FLYSKY_AFHDS2A: + protocol = PROTOCOL_CHANNELS_AFHDS2A; + break; +#endif + +#if defined(AFHDS3) + case MODULE_TYPE_FLYSKY_AFHDS3: + protocol = PROTOCOL_CHANNELS_AFHDS3; break; #endif diff --git a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp index b17837ef75b..788689002cd 100644 --- a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -616,7 +617,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp index 3f482609b7d..0bbd2fea4a4 100644 --- a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp @@ -531,9 +531,10 @@ static uint8_t select_mod_type(void* user, uint8_t* data, uint32_t bitoffs) case MODULE_TYPE_R9M_LITE_PRO_PXX2: case MODULE_TYPE_XJT_LITE_PXX2: return 5; - case MODULE_TYPE_FLYSKY: - if (mod_data->subType == FLYSKY_SUBTYPE_AFHDS2A) return 6; - if (mod_data->subType == FLYSKY_SUBTYPE_AFHDS3) return 7; + case MODULE_TYPE_FLYSKY_AFHDS2A: + return 6; + case MODULE_TYPE_FLYSKY_AFHDS3: + return 7; break; case MODULE_TYPE_GHOST: return 8; @@ -1888,6 +1889,28 @@ static bool w_thrSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, return w_mixSrcRaw(nullptr, src, wf, opaque); } +extern const struct YamlIdStr enum_ModuleType[]; + +static const struct YamlIdStr enum_old_ModuleType[] = { + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY" }, + { 0, NULL } +}; + +static uint32_t r_moduleType(const YamlNode* node, const char* val, uint8_t val_len) +{ + uint32_t type = yaml_parse_enum(enum_ModuleType, val, val_len); + if (!type && val_len > 0) { + type = yaml_parse_enum(enum_old_ModuleType, val, val_len); + } + return type; +} + +bool w_moduleType(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque) +{ + const char* str = yaml_output_enum(val, enum_ModuleType); + return str ? wf(opaque, str, strlen(str)) : true; +} + static const struct YamlIdStr enum_XJT_Subtypes[] = { { MODULE_SUBTYPE_PXX1_ACCST_D16, "D16" }, { MODULE_SUBTYPE_PXX1_ACCST_D8, "D8" }, @@ -1912,9 +1935,11 @@ static const struct YamlIdStr enum_R9M_Subtypes[] = { { 0, NULL } }; +enum ModuleSubtypeFlysky { FLYSKY_SUBTYPE_AFHDS3 = 0, FLYSKY_SUBTYPE_AFHDS2A }; + static const struct YamlIdStr enum_FLYSKY_Subtypes[] = { - { FLYSKY_SUBTYPE_AFHDS3, "AFHDS3" }, { FLYSKY_SUBTYPE_AFHDS2A, "AFHDS2A" }, + { FLYSKY_SUBTYPE_AFHDS3, "AFHDS3" }, { 0, NULL } }; @@ -1944,8 +1969,11 @@ static void r_modSubtype(void* user, uint8_t* data, uint32_t bitoffs, md->subType = yaml_parse_enum(enum_ISRM_Subtypes, val, val_len); } else if (isModuleTypeR9MNonAccess(md->type)) { md->subType = yaml_parse_enum(enum_R9M_Subtypes, val, val_len); - } else if (md->type == MODULE_TYPE_FLYSKY) { - md->subType = yaml_parse_enum(enum_FLYSKY_Subtypes, val, val_len); + } else if (md->type == MODULE_TYPE_FLYSKY_AFHDS2A) { + // Flysky sub-types have been converted into separate module types + auto sub_type = yaml_parse_enum(enum_FLYSKY_Subtypes, val, val_len); + if (sub_type == FLYSKY_SUBTYPE_AFHDS3) + md->type = MODULE_TYPE_FLYSKY_AFHDS3; } else if (md->type == MODULE_TYPE_MULTIMODULE) { #if defined(MULTIMODULE) // Read type/subType by the book (see MPM documentation) @@ -2002,8 +2030,6 @@ static bool w_modSubtype(void* user, uint8_t* data, uint32_t bitoffs, str = yaml_output_enum(val, enum_ISRM_Subtypes); } else if (md->type == MODULE_TYPE_R9M_PXX1 || md->type == MODULE_TYPE_R9M_LITE_PXX1) { str = yaml_output_enum(val, enum_R9M_Subtypes); - } else if (md->type == MODULE_TYPE_FLYSKY) { - str = yaml_output_enum(val, enum_FLYSKY_Subtypes); } else if (md->type == MODULE_TYPE_MULTIMODULE) { #if defined(MULTIMODULE) // Use type/subType by the book (see MPM documentation) diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index 8dfb4db3655..7ea0b13d64d 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -654,7 +655,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/storage/yaml/yaml_datastructs_t20.cpp b/radio/src/storage/yaml/yaml_datastructs_t20.cpp index e2dadece514..2a788f32ca4 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t20.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t20.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -614,7 +615,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp index 5277f1e879c..aa71fec527d 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -614,7 +615,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/storage/yaml/yaml_datastructs_x10.cpp b/radio/src/storage/yaml/yaml_datastructs_x10.cpp index 041e3e0d407..488babb5803 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x10.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x10.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -661,7 +662,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp index 041e3e0d407..488babb5803 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -661,7 +662,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp index 5a6298cb68a..23d550fae88 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -617,7 +618,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp index 896cd03a253..aaf7829a11d 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -617,7 +618,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp index d770b61429d..40dc7073a66 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -614,7 +615,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp index 090bb3fed31..e83c8f101f1 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp @@ -35,7 +35,8 @@ const struct YamlIdStr enum_ModuleType[] = { { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, { MODULE_TYPE_SBUS, "TYPE_SBUS" }, { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, - { MODULE_TYPE_FLYSKY, "TYPE_FLYSKY" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, { 0, NULL } }; @@ -620,7 +621,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = { }; static const struct YamlNode struct_ModuleData[] = { YAML_IDX, - YAML_ENUM("type", 8, enum_ModuleType), + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), YAML_UNSIGNED( "channelsStart", 8 ), YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), diff --git a/radio/src/targets/nv14/CMakeLists.txt b/radio/src/targets/nv14/CMakeLists.txt index c90b1883a10..14d07b8d9c3 100644 --- a/radio/src/targets/nv14/CMakeLists.txt +++ b/radio/src/targets/nv14/CMakeLists.txt @@ -2,7 +2,6 @@ option(DISK_CACHE "Enable SD card disk cache" ON) option(UNEXPECTED_SHUTDOWN "Enable the Unexpected Shutdown screen" ON) option(STICKS_DEAD_ZONE "Enable sticks dead zone" YES) option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" ON) -option(AFHDS2 "Support for AFHDS2" ON) option(GHOST "Ghost TX Module" ON) option(PXX1 "PXX1 protocol support" ON) option(PXX2 "PXX2 protocol support" OFF) @@ -39,13 +38,22 @@ set(RF_BAUD_RATE 921600 230400 115200 57600 38400 19200 9600 4800 2400 1200) set(PCB_RF_BAUD 921600 CACHE STRING "INTERNAL_MODULE_BAUDRATE: ${RF_BAUD_RATE}") set_property(CACHE PCB_RF_BAUD PROPERTY STRINGS ${RF_BAUD_RATE}) -set(FLAVOUR nv14) add_definitions(-DPCBNV14 -DPCBFLYSKY -DAFHDS2_BAUDRATE=${PCB_RF_BAUD}) add_definitions(-DBATTERY_CHARGE -DUSE_TRIMS_AS_BUTTONS) -# defines existing internal modules -set(INTERNAL_MODULES AFHDS2A;AFHDS3 CACHE STRING "Internal modules") -set(DEFAULT_INTERNAL_MODULE FLYSKY CACHE STRING "Default internal module") +if (PCBREV STREQUAL EL18) + set(FLAVOUR el18) + # defines existing internal modules + set(INTERNAL_MODULES AFHDS3 CACHE STRING "Internal modules") + set(DEFAULT_INTERNAL_MODULE FLYSKY_AFHDS3 CACHE STRING "Default internal module") + set(AFHDS3 ON) +else() + set(FLAVOUR nv14) + # defines existing internal modules + set(INTERNAL_MODULES AFHDS2A CACHE STRING "Internal modules") + set(DEFAULT_INTERNAL_MODULE FLYSKY_AFHDS2A CACHE STRING "Default internal module") + set(AFHDS2 ON) +endif() set(BITMAPS_TARGET nv14_bitmaps) set(FONTS_TARGET x12_fonts) @@ -81,9 +89,6 @@ if(STICKS_DEAD_ZONE) add_definitions(-DSTICK_DEAD_ZONE) endif() -set(AFHDS2 ON) -set(AFHDS3 ON) - # VCP CLI set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough") set(CLI ON CACHE BOOL "Enable CLI") diff --git a/radio/src/targets/nv14/board.h b/radio/src/targets/nv14/board.h index 971d6819a27..af66f9c1472 100644 --- a/radio/src/targets/nv14/board.h +++ b/radio/src/targets/nv14/board.h @@ -234,9 +234,15 @@ bool isBacklightEnabled(); #if !defined(SIMU) void usbJoystickUpdate(); #endif -#define USB_NAME "FlySky NV14" -#define USB_MANUFACTURER 'F', 'l', 'y', 'S', 'k', 'y', ' ', ' ' /* 8 bytes */ +#if (PCBREV == EL18) +#define USB_NAME "Flysky EL18" +#define USB_MANUFACTURER 'F', 'l', 'y', 's', 'k', 'y', ' ', ' ' /* 8 bytes */ +#define USB_PRODUCT 'E', 'L', '1', '8', ' ', ' ', ' ', ' ' /* 8 Bytes */ +#else +#define USB_NAME "Flysky NV14" +#define USB_MANUFACTURER 'F', 'l', 'y', 's', 'k', 'y', ' ', ' ' /* 8 bytes */ #define USB_PRODUCT 'N', 'V', '1', '4', ' ', ' ', ' ', ' ' /* 8 Bytes */ +#endif #if defined(__cplusplus) && !defined(SIMU) } diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index 4bad6091dd7..847d38c8932 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -139,19 +139,18 @@ rxStatStruct *getRxStatLabels() { rxStat.unit = STR_RXSTAT_UNIT_PERCENT; break; - case MODULE_TYPE_FLYSKY: - #if defined (PCBNV14) +#if defined (PCBNV14) && defined(AFHDS2) + case MODULE_TYPE_FLYSKY_AFHDS2A: extern uint32_t NV14internalModuleFwVersion; if(moduleToUse == INTERNAL_MODULE) { - if(g_model.moduleData[INTERNAL_MODULE].subType == FLYSKY_SUBTYPE_AFHDS2A && - NV14internalModuleFwVersion >= 0x1000E) { + if(NV14internalModuleFwVersion >= 0x1000E) { rxStat.label = STR_RXSTAT_LABEL_SIGNAL; rxStat.unit = STR_RXSTAT_UNIT_NOUNIT ; } } - #endif break; +#endif } return &rxStat; diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 25f5f7bcbd8..786a78a5627 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -70,7 +70,6 @@ ISTR(USBMODES); ISTR(JACK_MODES); ISTR(VFAILSAFE); ISTR(VTRAINERMODES); -ISTR(FLYSKY_PROTOCOLS); ISTR(MODULE_PROTOCOLS); ISTR(R9M_REGION); ISTR(R9M_FCC_POWER_VALUES); diff --git a/radio/src/translations.h b/radio/src/translations.h index d2670cfa2db..8f80abcf6b4 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -201,7 +201,6 @@ extern const char* const STR_ISRM_RF_PROTOCOLS[]; extern const char* const STR_R9M_PXX2_RF_PROTOCOLS[]; extern const char* const STR_PPM_PROTOCOLS[]; extern const char* const STR_DSM_PROTOCOLS[]; -extern const char* const STR_FLYSKY_PROTOCOLS[]; extern const char* const STR_CRSF_BAUDRATE[]; extern const char* const STR_PPM_POL[]; extern const char* const STR_SBUS_INVERSION_VALUES[]; diff --git a/radio/src/translations/untranslated.h b/radio/src/translations/untranslated.h index b29ac6ec51c..47ac2007683 100644 --- a/radio/src/translations/untranslated.h +++ b/radio/src/translations/untranslated.h @@ -65,10 +65,10 @@ "R9MLP ACCESS", \ "SBUS", \ "XJT Lite", \ - "FLYSKY", \ + "AFHDS2A", \ + "AFHDS3", \ TR("Lemon DSMP","LemonRx DSMP") -#define TR_FLYSKY_PROTOCOLS "AFHDS3","AFHDS2A" #define TR_XJT_ACCST_RF_PROTOCOLS "D16","D8","LR12" #define TR_ISRM_RF_PROTOCOLS "ACCESS","D16","LR12" diff --git a/radio/util/hw_defs/legacy_names.py b/radio/util/hw_defs/legacy_names.py index 3e72e44d709..61b052ae197 100644 --- a/radio/util/hw_defs/legacy_names.py +++ b/radio/util/hw_defs/legacy_names.py @@ -258,7 +258,7 @@ "targets": { "commando8", "lr3pro", - "nv14", + "nv14", "el18", "t8", "t12", "tlite", "tlitef4", "tpro", "tprov2", "tx12", "tx12mk2", diff --git a/radio/util/hw_defs/pot_config.py b/radio/util/hw_defs/pot_config.py index f0fda26f2b1..a9e905200fb 100644 --- a/radio/util/hw_defs/pot_config.py +++ b/radio/util/hw_defs/pot_config.py @@ -6,6 +6,14 @@ "P2": {"default": "WITH_DETENT"}, "P3": {"default": "MULTIPOS_SWITCH"} }, + "el18": { + "P1": { "default": "WITHOUT_DETENT"}, + "P2": { "default": "WITHOUT_DETENT"} + }, + "nv14": { + "P1": { "default": "WITHOUT_DETENT"}, + "P2": { "default": "WITHOUT_DETENT"} + }, "tpro": { "P1": {"default": "WITH_DETENT"}, "P2": {"default": "WITH_DETENT"} diff --git a/radio/util/hw_defs/switch_config.py b/radio/util/hw_defs/switch_config.py index 02e3728f303..dc13a97e2c4 100644 --- a/radio/util/hw_defs/switch_config.py +++ b/radio/util/hw_defs/switch_config.py @@ -19,6 +19,16 @@ "SB": {"default": "3POS", "display": [1, 0]}, "SD": {"default": "2POS", "display": [1, 1]} }, + "el18": { + "SA": { "default": "2POS" }, + "SB": { "default": "3POS" }, + "SC": { "default": "3POS" }, + "SD": { "default": "2POS" }, + "SE": { "default": "2POS" }, + "SF": { "default": "3POS" }, + "SG": { "default": "3POS" }, + "SH": { "default": "TOGGLE" } + }, "lr3pro": { # left side "SA": {"default": "3POS", "display": [0, 0]}, diff --git a/tools/build-flysky.py b/tools/build-flysky.py index 47220180f9e..c6c60ad74d0 100644 --- a/tools/build-flysky.py +++ b/tools/build-flysky.py @@ -13,6 +13,11 @@ "PCB": "NV14", "DEFAULT_MODE": "1", }, + "EL18": { + "PCB": "NV14", + "PCBREV": "EL18", + "DEFAULT_MODE": "1", + }, } translations = [ diff --git a/tools/build-gh.sh b/tools/build-gh.sh index 324ad1db21c..a0020a27cdf 100755 --- a/tools/build-gh.sh +++ b/tools/build-gh.sh @@ -185,6 +185,9 @@ do nv14) BUILD_OPTIONS+="-DPCB=NV14" ;; + el18) + BUILD_OPTIONS+="-DPCB=NV14 -DPCBREV=EL18" + ;; commando8) BUILD_OPTIONS+="-DPCB=X7 -DPCBREV=COMMANDO8" ;; diff --git a/tools/commit-tests.sh b/tools/commit-tests.sh index f8ece0f706e..66ea77e8516 100755 --- a/tools/commit-tests.sh +++ b/tools/commit-tests.sh @@ -145,6 +145,9 @@ do nv14) BUILD_OPTIONS+="-DPCB=NV14" ;; + el18) + BUILD_OPTIONS+="-DPCB=NV14 -DPCBREV=EL18" + ;; commando8) BUILD_OPTIONS+="-DPCB=X7 -DPCBREV=COMMANDO8" ;;