From a4a0ad93f8bc1e5dc0fe4c1147366423a517f8b0 Mon Sep 17 00:00:00 2001 From: 3djc Date: Sun, 29 Oct 2023 02:58:11 +0100 Subject: [PATCH] feat(cpn): Radiomaster Pocket support (#4241) Co-authored-by: Peter Feerick --- companion/src/CMakeLists.txt | 2 ++ companion/src/firmwares/boards.cpp | 29 +++++++++++++++++-- companion/src/firmwares/boards.h | 8 +++++ companion/src/firmwares/generalsettings.cpp | 3 ++ .../src/firmwares/opentx/opentxinterface.cpp | 22 +++++++++++--- tools/build-companion.sh | 2 +- 6 files changed, 59 insertions(+), 7 deletions(-) diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 07f56c47222..2cbef76434b 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -299,6 +299,8 @@ elseif(PCB STREQUAL X7 AND PCBREV STREQUAL ZORRO) set(FLAVOUR zorro) elseif(PCB STREQUAL X7 AND PCBREV STREQUAL BOXER) set(FLAVOUR boxer) +elseif(PCB STREQUAL X7 AND PCBREV STREQUAL POCKET) + set(FLAVOUR pocket) elseif(PCB STREQUAL X7 AND PCBREV STREQUAL LR3PRO) set(FLAVOUR lr3pro) elseif(PCB STREQUAL X7 AND PCBREV STREQUAL COMMANDO8) diff --git a/companion/src/firmwares/boards.cpp b/companion/src/firmwares/boards.cpp index b4a35bf5f8f..08e058ac863 100644 --- a/companion/src/firmwares/boards.cpp +++ b/companion/src/firmwares/boards.cpp @@ -147,6 +147,7 @@ int Boards::getEEpromSize(Board::Type board) case BOARD_RADIOMASTER_T8: case BOARD_RADIOMASTER_ZORRO: case BOARD_RADIOMASTER_BOXER: + case BOARD_RADIOMASTER_POCKET: return EESIZE_TARANIS; case BOARD_UNKNOWN: return EESIZE_MAX; @@ -195,6 +196,7 @@ int Boards::getFlashSize(Type board) case BOARD_RADIOMASTER_ZORRO: case BOARD_RADIOMASTER_BOXER: case BOARD_RADIOMASTER_T8: + case BOARD_RADIOMASTER_POCKET: return FSIZE_TARANIS; case BOARD_HORUS_X12S: case BOARD_X10: @@ -330,6 +332,17 @@ SwitchInfo Boards::getSwitchInfo(Board::Type board, int index) if (index < DIM(switches)) return switches[index]; } + else if (IS_RADIOMASTER_POCKET(board)) { + const Board::SwitchInfo switches[] = { + {SWITCH_2POS, "SA"}, + {SWITCH_3POS, "SB"}, + {SWITCH_3POS, "SC"}, + {SWITCH_2POS, "SD"}, + {SWITCH_TOGGLE, "SE"} + }; + if (index < DIM(switches)) + return switches[index]; + } else if (IS_RADIOMASTER_T8(board)) { const Board::SwitchInfo switches[] = { {SWITCH_TOGGLE, "SA"}, @@ -470,7 +483,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) return 4; case Pots: - if (IS_TARANIS_X9LITE(board)) + if (IS_TARANIS_X9LITE(board) || IS_RADIOMASTER_POCKET(board)) return 1; else if (IS_JUMPER_TLITE(board) || IS_BETAFPV_LR3PRO(board) || IS_IFLIGHT_COMMANDO8(board)) return 0; @@ -547,6 +560,8 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) return 8; else if (board == BOARD_RADIOMASTER_TX12_MK2 || board == BOARD_RADIOMASTER_BOXER || board == BOARD_JUMPER_TPRO) return 6; + else if (board == BOARD_RADIOMASTER_POCKET) + return 5; else if (IS_FAMILY_T12(board)) return 8; else if (IS_TARANIS_XLITE(board)) @@ -575,6 +590,8 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) return 4; else if(IS_RADIOMASTER_ZORRO(board)) return 8; + else if (board == BOARD_RADIOMASTER_POCKET) + return 5; else if (IS_FAMILY_T12(board)) return 6; else if (IS_HORUS_X12S(board)) @@ -642,7 +659,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) case HasTrainerModuleSBUS: return ((IS_TARANIS_X9LITE(board) || (IS_TARANIS_XLITE(board) && !IS_TARANIS_X9LITES(board)) || IS_TARANIS_X9DP_2019(board) || IS_TARANIS_X7_ACCESS(board) || IS_RADIOMASTER_ZORRO(board) || - IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_BOXER(board)) || + IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_POCKET(board)) || (getCapability(board, HasExternalModuleSupport) && (IS_TARANIS(board) && !IS_FAMILY_T12(board)))); default: @@ -752,6 +769,10 @@ StringTagMappingTable Boards::getAnalogNamesLookupTable(Board::Type board, const {tr("S2").toStdString(), "POT2"}, {tr("S3").toStdString(), "POT3"}, }); + } else if (IS_RADIOMASTER_POCKET(board)) { + tbl.insert(tbl.end(), { + {tr("S1").toStdString(), "P1", 4}, + }); } else if ((IS_TARANIS_SMALL(board) && !IS_JUMPER_TLITE(board) && !IS_JUMPER_T20(board)) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) { if (version < adcVersion) { tbl.insert(tbl.end(), { @@ -935,6 +956,8 @@ QString Boards::getBoardName(Board::Type board) return "Radiomaster Zorro"; case BOARD_RADIOMASTER_BOXER: return "Radiomaster Boxer"; + case BOARD_RADIOMASTER_POCKET: + return "Radiomaster Pocket"; case BOARD_RADIOMASTER_T8: return "Radiomaster T8"; case BOARD_FLYSKY_NV14: @@ -1180,6 +1203,7 @@ int Boards::getDefaultInternalModules(Board::Type board) case BOARD_BETAFPV_LR3PRO: case BOARD_RADIOMASTER_ZORRO: case BOARD_RADIOMASTER_BOXER: + case BOARD_RADIOMASTER_POCKET: case BOARD_RADIOMASTER_TX12_MK2: case BOARD_IFLIGHT_COMMANDO8: case BOARD_JUMPER_T20: @@ -1211,6 +1235,7 @@ int Boards::getDefaultExternalModuleSize(Board::Type board) if (IS_TARANIS_X9LITE(board) || IS_RADIOMASTER_ZORRO(board) || + IS_RADIOMASTER_POCKET(board) || IS_JUMPER_TLITE(board) || IS_JUMPER_TPRO(board) || IS_JUMPER_T20(board) || diff --git a/companion/src/firmwares/boards.h b/companion/src/firmwares/boards.h index 1fa8e7884a1..75c6473c918 100644 --- a/companion/src/firmwares/boards.h +++ b/companion/src/firmwares/boards.h @@ -75,6 +75,7 @@ namespace Board { BOARD_IFLIGHT_COMMANDO8, BOARD_FLYSKY_EL18, BOARD_JUMPER_TPROV2, + BOARD_RADIOMASTER_POCKET, BOARD_TYPE_COUNT, BOARD_TYPE_MAX = BOARD_TYPE_COUNT - 1 }; @@ -353,6 +354,12 @@ inline bool IS_RADIOMASTER_BOXER(Board::Type board) return board == Board::BOARD_RADIOMASTER_BOXER; } +inline bool IS_RADIOMASTER_POCKET(Board::Type board) +{ + return board == Board::BOARD_RADIOMASTER_POCKET; +} + + inline bool IS_RADIOMASTER_T8(Board::Type board) { return board == Board::BOARD_RADIOMASTER_T8; @@ -375,6 +382,7 @@ inline bool IS_FAMILY_T12(Board::Type board) board == Board::BOARD_RADIOMASTER_TX12_MK2 || board == Board::BOARD_RADIOMASTER_ZORRO || board == Board::BOARD_RADIOMASTER_BOXER || + board == Board::BOARD_RADIOMASTER_POCKET || board == Board::BOARD_RADIOMASTER_T8 || board == Board::BOARD_BETAFPV_LR3PRO || board == Board::BOARD_IFLIGHT_COMMANDO8; diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index f9dca964fa7..44cef50b997 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -305,6 +305,9 @@ void GeneralSettings::setDefaultControlTypes(Board::Type board) potConfig[1] = Board::POT_WITH_DETENT; potConfig[2] = Board::POT_MULTIPOS_SWITCH; } + else if(IS_RADIOMASTER_POCKET(board)) { + potConfig[0] = Board::POT_WITHOUT_DETENT; + } else if(IS_JUMPER_T20(board)) { potConfig[0] = Board::POT_WITHOUT_DETENT; potConfig[1] = Board::POT_WITHOUT_DETENT; diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index d372fbd7bd2..b6b2badbea7 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -84,6 +84,8 @@ const char * OpenTxEepromInterface::getName() return "EdgeTX for Radiomaster Zorro"; case BOARD_RADIOMASTER_BOXER: return "EdgeTX for Radiomaster Boxer"; + case BOARD_RADIOMASTER_POCKET: + return "EdgeTX for Radiomaster Pocket"; case BOARD_RADIOMASTER_T8: return "EdgeTX for Radiomaster T8"; case BOARD_TARANIS_X9D: @@ -772,7 +774,7 @@ int OpenTxFirmware::getCapability(::Capability capability) return IS_FAMILY_T16(board); case HasVCPSerialMode: return IS_FAMILY_HORUS_OR_T16(board) || IS_RADIOMASTER_ZORRO(board) || - IS_JUMPER_TPRO(board) || IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_BOXER(board); + IS_JUMPER_TPRO(board) || IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_POCKET(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) || IS_FLYSKY_EL18(board)) ? true : false; @@ -792,20 +794,22 @@ int OpenTxFirmware::getCapability(::Capability capability) IS_TARANIS_X9LITE(board) || IS_RADIOMASTER_TX12(board) || IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_ZORRO(board) || IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_TX16S(board) || - IS_JUMPER_T18(board)) || IS_JUMPER_T20(board); + IS_JUMPER_T18(board) || IS_JUMPER_T20(board) || + IS_RADIOMASTER_POCKET(board)); case HasSoftwareSerialPower: return IS_RADIOMASTER_TX16S(board); case HasIntModuleMulti: return id.contains("internalmulti") || IS_RADIOMASTER_TX16S(board) || IS_JUMPER_T18(board) || IS_RADIOMASTER_TX12(board) || IS_JUMPER_TLITE(board) || IS_BETAFPV_LR3PRO(board) || (IS_RADIOMASTER_ZORRO(board) && !id.contains("internalelrs")) || - (IS_RADIOMASTER_BOXER(board) && !id.contains("internalelrs")); + (IS_RADIOMASTER_BOXER(board) && !id.contains("internalelrs")) || + (IS_RADIOMASTER_POCKET(board) && !id.contains("internalelrs")); case HasIntModuleCRSF: return id.contains("internalcrsf"); case HasIntModuleELRS: return id.contains("internalelrs") || IS_RADIOMASTER_TX12_MK2(board) || IS_IFLIGHT_COMMANDO8(board) || IS_RADIOMASTER_BOXER(board) || - IS_JUMPER_T20(board); + IS_RADIOMASTER_POCKET(board) || IS_JUMPER_T20(board); case HasIntModuleFlySky: return id.contains("afhds2a") || id.contains("afhds3") || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board); @@ -1410,6 +1414,16 @@ void registerOpenTxFirmwares() registerOpenTxFirmware(firmware); addOpenTxRfOptions(firmware, FLEX + AFHDS2A + AFHDS3); + /* Radiomaster Pocket board */ + firmware = new OpenTxFirmware(FIRMWAREID("pocket"), QCoreApplication::translate("Firmware", "Radiomaster Pocket"), Board::BOARD_RADIOMASTER_POCKET); + addOpenTxCommonOptions(firmware); + firmware->addOption("noheli", Firmware::tr("Disable HELI menu and cyclic mix support")); + firmware->addOption("nogvars", Firmware::tr("Disable Global variables")); + firmware->addOption("lua", Firmware::tr("Enable Lua custom scripts screen")); + addOpenTxFontOptions(firmware); + registerOpenTxFirmware(firmware); + addOpenTxRfOptions(firmware, FLEX + AFHDS2A + AFHDS3); + /* Radiomaster T8 board */ firmware = new OpenTxFirmware(FIRMWAREID("t8"), QCoreApplication::translate("Firmware", "Radiomaster T8"), BOARD_RADIOMASTER_T8); addOpenTxCommonOptions(firmware); diff --git a/tools/build-companion.sh b/tools/build-companion.sh index a664d1ea539..a51e47a2855 100755 --- a/tools/build-companion.sh +++ b/tools/build-companion.sh @@ -66,7 +66,7 @@ cd build declare -a simulator_plugins=(x9lite x9lites x7 x7-access t8 t12 tx12 tx12mk2 - zorro pocket commando8 boxer + zorro commando8 boxer tlite tpro lr3pro x9d x9dp x9dp2019 x9e xlite xlites