Skip to content

Commit

Permalink
feat(cpn): Jumper T20 support (#4227)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Feerick <[email protected]>
  • Loading branch information
3djc and pfeerick authored Oct 24, 2023
1 parent 16b9d72 commit a467d2c
Show file tree
Hide file tree
Showing 20 changed files with 256 additions and 25 deletions.
61 changes: 54 additions & 7 deletions companion/src/firmwares/boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ int Boards::getEEpromSize(Board::Type board)
case BOARD_BETAFPV_LR3PRO:
case BOARD_IFLIGHT_COMMANDO8:
case BOARD_JUMPER_T12:
case BOARD_JUMPER_T20:
case BOARD_JUMPER_TLITE:
case BOARD_JUMPER_TLITE_F4:
case BOARD_JUMPER_TPRO:
Expand Down Expand Up @@ -184,6 +185,7 @@ int Boards::getFlashSize(Type board)
case BOARD_BETAFPV_LR3PRO:
case BOARD_IFLIGHT_COMMANDO8:
case BOARD_JUMPER_T12:
case BOARD_JUMPER_T20:
case BOARD_JUMPER_TLITE:
case BOARD_JUMPER_TLITE_F4:
case BOARD_JUMPER_TPRO:
Expand Down Expand Up @@ -360,6 +362,22 @@ SwitchInfo Boards::getSwitchInfo(Board::Type board, int index)
if (index < DIM(switches))
return switches[index];
}
else if (IS_JUMPER_T20(board)) {
const Board::SwitchInfo switches[] = {
{SWITCH_2POS, "SA"},
{SWITCH_2POS, "SB"},
{SWITCH_3POS, "SC"},
{SWITCH_3POS, "SD"},
{SWITCH_2POS, "SE"},
{SWITCH_2POS, "SF"},
{SWITCH_TOGGLE, "SG"},
{SWITCH_TOGGLE, "SH"},
{SWITCH_TOGGLE, "SI"},
{SWITCH_TOGGLE, "SJ"},
};
if (index < DIM(switches))
return switches[index];
}
else if (IS_FLYSKY_NV14(board)) {
const Board::SwitchInfo switches[] = {
{SWITCH_2POS, "SA"},
Expand Down Expand Up @@ -458,16 +476,14 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return 0;
else if (IS_RADIOMASTER_BOXER(board))
return 3;
else if (IS_TARANIS_SMALL(board) || IS_JUMPER_TPRO(board))
else if (IS_TARANIS_SMALL(board) || IS_JUMPER_TPRO(board) || IS_FLYSKY_NV14(board) || IS_JUMPER_T20(board))
return 2;
else if (IS_TARANIS_X9E(board))
return 4;
else if (IS_HORUS_X10(board) || IS_FAMILY_T16(board))
return 7;
else if (IS_HORUS_X12S(board))
return 3;
else if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))
return 2;
else
return 3;

Expand All @@ -478,7 +494,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return getCapability(board, Pots);

case Sliders:
if (IS_HORUS_X12S(board) || IS_TARANIS_X9E(board))
if (IS_HORUS_X12S(board) || IS_TARANIS_X9E(board) || IS_JUMPER_T20(board))
return 4;
else if (IS_TARANIS_X9D(board) || IS_HORUS_X10(board) || IS_FAMILY_T16(board))
return 2;
Expand Down Expand Up @@ -539,13 +555,16 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return 9;
else if (IS_TARANIS(board))
return 8;
else if (IS_FAMILY_HORUS_OR_T16(board))
else if (IS_FAMILY_HORUS_OR_T16(board) || IS_JUMPER_T20(board))
return 10;
else
return 7;

case FunctionSwitches:
return (IS_JUMPER_TPRO(board) ? 6 : 0);
if (board == BOARD_JUMPER_TPRO || board == BOARD_JUMPER_TPROV2 || board == BOARD_JUMPER_T20)
return 6;
else
return 0;

case FactoryInstalledSwitches:
if (IS_TARANIS_X9E(board))
Expand Down Expand Up @@ -578,6 +597,8 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return 6;
else if (IS_IFLIGHT_COMMANDO8(board))
return 0;
else if (IS_JUMPER_T20(board))
return 8;
else
return 4;

Expand Down Expand Up @@ -731,7 +752,7 @@ StringTagMappingTable Boards::getAnalogNamesLookupTable(Board::Type board, const
{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)) {
} 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(), {
{tr("S1").toStdString(), "POT1"},
Expand Down Expand Up @@ -825,6 +846,15 @@ StringTagMappingTable Boards::getAnalogNamesLookupTable(Board::Type board, const
{tr("TltY").toStdString(), "TILT_Y", 16},
});
}
} else if (IS_JUMPER_T20(board)) {
tbl.insert(tbl.end(), {
{tr("S1").toStdString(), "P1", 4},
{tr("S2").toStdString(), "P2", 5},
{tr("S3").toStdString(), "SL1", 6},
{tr("S4").toStdString(), "SL2", 7},
{tr("SL").toStdString(), "SL3", 8},
{tr("SR").toStdString(), "SL4", 9},
});
}

return tbl;
Expand Down Expand Up @@ -893,6 +923,8 @@ QString Boards::getBoardName(Board::Type board)
return "Jumper T16";
case BOARD_JUMPER_T18:
return "Jumper T18";
case BOARD_JUMPER_T20:
return "Jumper T20";
case BOARD_RADIOMASTER_TX16S:
return "Radiomaster TX16S";
case BOARD_RADIOMASTER_TX12:
Expand Down Expand Up @@ -1051,6 +1083,14 @@ StringTagMappingTable Boards::getTrimSwitchesLookupTable(Board::Type board)
{std::to_string(TRIM_SW_T6_INC), "TrimT6Up"},
});

if (getCapability(board, Board::NumTrims) > 6)
tbl.insert(tbl.end(), {
{std::to_string(TRIM_SW_T7_INC), "TrimT7Up"},
{std::to_string(TRIM_SW_T7_DEC), "TrimT7Down"},
{std::to_string(TRIM_SW_T8_INC), "TrimT8Up"},
{std::to_string(TRIM_SW_T8_DEC), "TrimT8Down"},
});

return tbl;
}

Expand All @@ -1072,6 +1112,11 @@ StringTagMappingTable Boards::getTrimSourcesLookupTable(Board::Type board)
{std::to_string(TRIM_AXIS_T6), "TrimT6"},
});

if (getCapability(board, Board::NumTrims) > 6)
tbl.insert(tbl.end(), {
{std::to_string(TRIM_AXIS_T7), "TrimT7"},
{std::to_string(TRIM_AXIS_T8), "TrimT8"},
});
return tbl;
}

Expand Down Expand Up @@ -1137,6 +1182,7 @@ int Boards::getDefaultInternalModules(Board::Type board)
case BOARD_RADIOMASTER_BOXER:
case BOARD_RADIOMASTER_TX12_MK2:
case BOARD_IFLIGHT_COMMANDO8:
case BOARD_JUMPER_T20:
return (int)MODULE_TYPE_CROSSFIRE;

case BOARD_FLYSKY_NV14:
Expand Down Expand Up @@ -1167,6 +1213,7 @@ int Boards::getDefaultExternalModuleSize(Board::Type board)
IS_RADIOMASTER_ZORRO(board) ||
IS_JUMPER_TLITE(board) ||
IS_JUMPER_TPRO(board) ||
IS_JUMPER_T20(board) ||
IS_BETAFPV_LR3PRO(board))
return EXTMODSIZE_SMALL;

Expand Down
21 changes: 17 additions & 4 deletions companion/src/firmwares/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace Board {
BOARD_JUMPER_T16,
BOARD_RADIOMASTER_TX16S,
BOARD_JUMPER_T18,
BOARD_JUMPER_T20,
BOARD_RADIOMASTER_TX12,
BOARD_RADIOMASTER_TX12_MK2,
BOARD_RADIOMASTER_BOXER,
Expand Down Expand Up @@ -119,6 +120,8 @@ namespace Board {
TRIM_AXIS_RH,
TRIM_AXIS_T5,
TRIM_AXIS_T6,
TRIM_AXIS_T7,
TRIM_AXIS_T8,
TRIM_AXIS_COUNT
};

Expand All @@ -136,6 +139,10 @@ namespace Board {
TRIM_SW_T5_INC,
TRIM_SW_T6_DEC,
TRIM_SW_T6_INC,
TRIM_SW_T7_DEC,
TRIM_SW_T7_INC,
TRIM_SW_T8_DEC,
TRIM_SW_T8_INC,
TRIM_SW_COUNT
};

Expand Down Expand Up @@ -316,6 +323,11 @@ inline bool IS_JUMPER_T18(Board::Type board)
return board == Board::BOARD_JUMPER_T18;
}

inline bool IS_JUMPER_T20(Board::Type board)
{
return board == Board::BOARD_JUMPER_T20;
}

inline bool IS_RADIOMASTER_TX16S(Board::Type board)
{
return board == Board::BOARD_RADIOMASTER_TX16S;
Expand Down Expand Up @@ -354,15 +366,16 @@ inline bool IS_FAMILY_T16(Board::Type board)
inline bool IS_FAMILY_T12(Board::Type board)
{
return board == Board::BOARD_JUMPER_T12 ||
board == Board::BOARD_JUMPER_T20 ||
board == Board::BOARD_JUMPER_TLITE ||
board == Board::BOARD_JUMPER_TLITE_F4 ||
board == Board::BOARD_JUMPER_TPRO ||
board == Board::BOARD_JUMPER_TPROV2 ||
board == Board::BOARD_RADIOMASTER_TX12 ||
board == Board::BOARD_RADIOMASTER_TX12_MK2 ||
board == Board::BOARD_RADIOMASTER_ZORRO ||
board == Board::BOARD_RADIOMASTER_BOXER ||
board == Board::BOARD_RADIOMASTER_T8 ||
board == Board::BOARD_JUMPER_TLITE ||
board == Board::BOARD_JUMPER_TLITE_F4 ||
board == Board::BOARD_JUMPER_TPRO ||
board == Board::BOARD_JUMPER_TPROV2 ||
board == Board::BOARD_BETAFPV_LR3PRO ||
board == Board::BOARD_IFLIGHT_COMMANDO8;
}
Expand Down
6 changes: 5 additions & 1 deletion companion/src/firmwares/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ void GeneralSettings::setDefaultControlTypes(Board::Type board)
potConfig[1] = Board::POT_WITH_DETENT;
potConfig[2] = Board::POT_MULTIPOS_SWITCH;
}
else if(IS_JUMPER_T20(board)) {
potConfig[0] = Board::POT_WITHOUT_DETENT;
potConfig[1] = Board::POT_WITHOUT_DETENT;
}
else if (IS_FAMILY_T12(board)) {
potConfig[0] = Board::POT_WITH_DETENT;
potConfig[1] = Board::POT_WITH_DETENT;
Expand All @@ -319,7 +323,7 @@ void GeneralSettings::setDefaultControlTypes(Board::Type board)
potConfig[2] = Board::POT_WITHOUT_DETENT;
}

if (IS_HORUS_X12S(board) || IS_TARANIS_X9E(board)) {
if (IS_HORUS_X12S(board) || IS_TARANIS_X9E(board) || IS_JUMPER_T20(board)) {
sliderConfig[0] = Board::SLIDER_WITH_DETENT;
sliderConfig[1] = Board::SLIDER_WITH_DETENT;
sliderConfig[2] = Board::SLIDER_WITH_DETENT;
Expand Down
16 changes: 13 additions & 3 deletions companion/src/firmwares/opentx/opentxinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ const char * OpenTxEepromInterface::getName()
return "EdgeTX for Jumper T16";
case BOARD_JUMPER_T18:
return "EdgeTX for Jumper T18";
case BOARD_JUMPER_T20:
return "EdgeTX for Jumper T20";
case BOARD_RADIOMASTER_TX16S:
return "EdgeTX for Radiomaster TX16S";
case BOARD_RADIOMASTER_TX12:
Expand Down Expand Up @@ -790,19 +792,20 @@ 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_T18(board)) || IS_JUMPER_T20(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);
(IS_RADIOMASTER_BOXER(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_IFLIGHT_COMMANDO8(board) || IS_RADIOMASTER_BOXER(board) ||
IS_JUMPER_T20(board);
case HasIntModuleFlySky:
return id.contains("afhds2a") || id.contains("afhds3") ||
IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board);
Expand Down Expand Up @@ -1359,6 +1362,13 @@ void registerOpenTxFirmwares()
addOpenTxRfOptions(firmware, FLEX);
registerOpenTxFirmware(firmware);

/* Jumper T20 board */
firmware = new OpenTxFirmware(FIRMWAREID("t20"), Firmware::tr("Jumper T20"), BOARD_JUMPER_T20);
addOpenTxFrskyOptions(firmware);
firmware->addOption("internalelrs", Firmware::tr("Select if internal ELRS module is installed"));
addOpenTxRfOptions(firmware, NONE);
registerOpenTxFirmware(firmware);

/* Radiomaster TX12 board */
firmware = new OpenTxFirmware(FIRMWAREID("tx12"), QCoreApplication::translate("Firmware", "Radiomaster TX12"), BOARD_RADIOMASTER_TX12);
addOpenTxCommonOptions(firmware);
Expand Down
2 changes: 1 addition & 1 deletion companion/src/firmwares/rawsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
}

static const QString trims[] = {
tr("TrmR"), tr("TrmE"), tr("TrmT"), tr("TrmA"), tr("Trm5"), tr("Trm6")
tr("TrmR"), tr("TrmE"), tr("TrmT"), tr("TrmA"), tr("Trm5"), tr("Trm6"), tr("Trm7"), tr("Trm8")
};

static const QString trims2[] = {
Expand Down
4 changes: 3 additions & 1 deletion companion/src/firmwares/rawswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen
tr("ThrTrim Down"), tr("ThrTrim Up"),
tr("AilTrim Left"), tr("AilTrim Right"),
tr("Trim 5 Down"), tr("Trim 5 Up"),
tr("Trim 6 Down"), tr("Trim 6 Up")
tr("Trim 6 Down"), tr("Trim 6 Up"),
tr("Trim 7 Down"), tr("Trim 7 Up"),
tr("Trim 8 Down"), tr("Trim 8 Up")
};

static const QString trimsSwitches2[] = {
Expand Down
Loading

0 comments on commit a467d2c

Please sign in to comment.