Skip to content

Commit

Permalink
feat: PL18 support
Browse files Browse the repository at this point in the history
  • Loading branch information
rotorman authored and raphaelcoeffic committed Sep 25, 2023
1 parent c87f911 commit 688948f
Show file tree
Hide file tree
Showing 99 changed files with 9,754 additions and 141 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
- tx16s
- nv14
- el18
- pl18
- t12
- t16
- t18
Expand Down Expand Up @@ -94,9 +95,9 @@ jobs:
matrix:
target:
- nv14;el18
- pl18
- t12
- t16
- t18
- t16;t18
- t8;zorro;pocket;commando8
- tlite;tlitef4;tpro;tprov2;lr3pro
- t20
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
matrix:
target:
- nv14;el18
- pl18
- t12
- t16
- t18
Expand Down
46 changes: 40 additions & 6 deletions companion/src/firmwares/boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ uint32_t Boards::getFourCC(Type board)
case BOARD_FLYSKY_NV14:
return 0x3A78746F;
case BOARD_FLYSKY_EL18:
return 0x3A78746F; // TODO: check this
return 0x3A78746F;
case BOARD_FLYSKY_PL18:
return 0x4878746F;
default:
return 0;
}
Expand Down Expand Up @@ -156,6 +158,7 @@ int Boards::getEEpromSize(Board::Type board)
case BOARD_RADIOMASTER_TX16S:
case BOARD_FLYSKY_NV14:
case BOARD_FLYSKY_EL18:
case BOARD_FLYSKY_PL18:
return 0;
default:
return 0;
Expand Down Expand Up @@ -200,6 +203,7 @@ int Boards::getFlashSize(Type board)
case BOARD_RADIOMASTER_TX16S:
case BOARD_FLYSKY_NV14:
case BOARD_FLYSKY_EL18:
case BOARD_FLYSKY_PL18:
return FSIZE_HORUS;
case BOARD_UNKNOWN:
return FSIZE_MAX;
Expand Down Expand Up @@ -360,6 +364,20 @@ SwitchInfo Boards::getSwitchInfo(Board::Type board, int index)
if (index < DIM(switches))
return switches[index];
}
else if (IS_FLYSKY_PL18(board)) {
const Board::SwitchInfo switches[] = {
{SWITCH_2POS, "SA"},
{SWITCH_3POS, "SB"},
{SWITCH_2POS, "SC"},
{SWITCH_3POS, "SD"},
{SWITCH_3POS, "SE"},
{SWITCH_2POS, "SF"},
{SWITCH_3POS, "SG"},
{SWITCH_3POS, "SH"}
};
if (index < DIM(switches))
return switches[index];
}
else if (IS_FAMILY_HORUS_OR_T16(board)) {
const Board::SwitchInfo switches[] = {
{SWITCH_3POS, "SA"},
Expand Down Expand Up @@ -440,6 +458,8 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return 3;
else if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))
return 2;
else if (IS_FLYSKY_PL18(board))
return 3;
else
return 3;

Expand All @@ -452,7 +472,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
case Sliders:
if (IS_HORUS_X12S(board) || IS_TARANIS_X9E(board))
return 4;
else if (IS_TARANIS_X9D(board) || IS_HORUS_X10(board) || IS_FAMILY_T16(board))
else if (IS_TARANIS_X9D(board) || IS_HORUS_X10(board) || IS_FAMILY_T16(board) || IS_FLYSKY_PL18(board))
return 2;
else
return 0;
Expand All @@ -474,7 +494,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
getCapability(board, Board::MouseAnalogs) + getCapability(board, Board::GyroAnalogs);

case MultiposPots:
if (IS_HORUS_OR_TARANIS(board) && !(IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)))
if (IS_HORUS_OR_TARANIS(board) && !(IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_FLYSKY_PL18(board)))
return getCapability(board, Board::Pots);
else
return 0;
Expand All @@ -499,6 +519,8 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return 4;
else if (board == BOARD_FLYSKY_NV14 || board == BOARD_FLYSKY_EL18)
return 8;
else if (board == BOARD_FLYSKY_PL18)
return 8;
else if (board == BOARD_RADIOMASTER_TX12_MK2 || board == BOARD_RADIOMASTER_BOXER)
return 6;
else if (IS_FAMILY_T12(board))
Expand Down Expand Up @@ -532,7 +554,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) || IS_FLYSKY_EL18(board))
if (IS_HORUS_OR_TARANIS(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_FLYSKY_PL18(board))
return getCapability(board, Board::Switches) * 3;
else
return 9;
Expand All @@ -542,7 +564,9 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)


case NumTrims:
if (IS_FAMILY_HORUS_OR_T16(board) && !(IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)))
if (IS_FLYSKY_PL18(board))
return 8;
else if (IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board))
return 6;
else if (IS_IFLIGHT_COMMANDO8(board))
return 0;
Expand All @@ -556,7 +580,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return IS_STM32(board) ? true : false;

case HasColorLcd:
return IS_FAMILY_HORUS_OR_T16(board);
return IS_FAMILY_HORUS_OR_T16(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_PL18(board);

case HasSDCard:
return IS_STM32(board);
Expand Down Expand Up @@ -748,6 +772,14 @@ StringTagMappingTable Boards::getAnalogNamesLookupTable(Board::Type board, const
{tr("TltY").toStdString(), "TILT_Y", 14},
});
}
} else if (IS_FLYSKY_PL18(board)) {
tbl.insert(tbl.end(), {
{tr("VRA").toStdString(), "POT1"},
{tr("VRB").toStdString(), "POT2"},
{tr("VRC").toStdString(), "POT3"},
{tr("LS").toStdString(), "LS"},
{tr("RS").toStdString(), "RS"},
});
} else if (IS_HORUS_X10(board) || IS_FAMILY_T16(board)) {
if (version < adcVersion) {
tbl.insert(tbl.end(), {
Expand Down Expand Up @@ -864,6 +896,8 @@ QString Boards::getBoardName(Board::Type board)
return "FlySky NV14";
case BOARD_FLYSKY_EL18:
return "FlySky EL18";
case BOARD_FLYSKY_PL18:
return "FlySky PL18";
case BOARD_BETAFPV_LR3PRO:
return "BETAFPV LR3PRO";
case BOARD_IFLIGHT_COMMANDO8:
Expand Down
13 changes: 11 additions & 2 deletions companion/src/firmwares/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace Board {
BOARD_JUMPER_TLITE,
BOARD_JUMPER_TLITE_F4,
BOARD_FLYSKY_NV14,
BOARD_FLYSKY_PL18,
BOARD_RADIOMASTER_ZORRO,
BOARD_JUMPER_TPRO,
BOARD_BETAFPV_LR3PRO,
Expand Down Expand Up @@ -363,6 +364,11 @@ inline bool IS_FLYSKY_EL18(Board::Type board)
return (board == Board::BOARD_FLYSKY_EL18);
}

inline bool IS_FLYSKY_PL18(Board::Type board)
{
return (board == Board::BOARD_FLYSKY_PL18);
}

inline bool IS_TARANIS_XLITE(Board::Type board)
{
return board == Board::BOARD_TARANIS_XLITE || board == Board::BOARD_TARANIS_XLITES;
Expand Down Expand Up @@ -440,7 +446,9 @@ 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*/ || IS_FLYSKY_EL18(board)/*generally*/;
return IS_FAMILY_HORUS(board) || IS_FAMILY_T16(board) ||
IS_FLYSKY_NV14(board)/*generally*/ || IS_FLYSKY_EL18(board)/*generally*/
|| IS_FLYSKY_PL18(board);
}

inline bool IS_HORUS_OR_TARANIS(Board::Type board)
Expand All @@ -450,7 +458,8 @@ 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) || IS_FLYSKY_EL18(board);
return IS_TARANIS(board) || IS_FAMILY_HORUS_OR_T16(board) ||
IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_FLYSKY_PL18(board);
}

inline bool IS_ARM(Board::Type board)
Expand Down
8 changes: 7 additions & 1 deletion companion/src/firmwares/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ void GeneralSettings::init()
strcpy(bluetoothName, "t16");
else if (IS_FLYSKY_NV14(board))
strcpy(bluetoothName, "nv14");
else if (IS_FLYSKY_PL18(board))
strcpy(bluetoothName, "pl18");
else if (IS_FAMILY_HORUS_OR_T16(board))
strcpy(bluetoothName, "horus");
else if (IS_TARANIS_X9E(board) || IS_TARANIS_SMALL(board))
Expand Down Expand Up @@ -277,7 +279,7 @@ void GeneralSettings::setDefaultControlTypes(Board::Type board)
return;

// TODO: move to Boards, like with switches
if (IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board)) {
if (IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board) && !IS_FLYSKY_PL18(board)) {
potConfig[0] = Board::POT_WITH_DETENT;
potConfig[1] = Board::POT_MULTIPOS_SWITCH;
potConfig[2] = Board::POT_WITH_DETENT;
Expand All @@ -286,6 +288,10 @@ void GeneralSettings::setDefaultControlTypes(Board::Type board)
potConfig[0] = Board::POT_WITHOUT_DETENT;
potConfig[1] = Board::POT_WITHOUT_DETENT;
}
else if (IS_FLYSKY_PL18(board)) {
potConfig[0] = Board::POT_WITHOUT_DETENT;
potConfig[1] = Board::POT_WITHOUT_DETENT;
}
else if (IS_TARANIS_XLITE(board)) {
potConfig[0] = Board::POT_WITHOUT_DETENT;
potConfig[1] = Board::POT_WITHOUT_DETENT;
Expand Down
20 changes: 10 additions & 10 deletions companion/src/firmwares/opentx/opentxeeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ inline int MAX_XPOTS(Board::Type board, int version)

inline int MAX_SLIDERS_STORAGE(Board::Type board, int version)
{
if (version >= 219 && (IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board)))
if (version >= 219 && (IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board) && !IS_FLYSKY_PL18(board)))
return 4;
return Boards::getCapability(board, Board::Sliders);
}
Expand Down Expand Up @@ -180,7 +180,7 @@ inline int SWITCHES_CONFIG_SIZE(Board::Type board, int version)

inline int MAX_MOUSE_ANALOG_SOURCES(Board::Type board, int version)
{
if (IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board))
if (IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board) && !IS_FLYSKY_PL18(board))
return 2;
else
return 0;
Expand Down Expand Up @@ -208,10 +208,10 @@ inline int MAX_GYRO_ANALOGS(Board::Type board, int version)
#define MAX_CURVES(board, version) ((version >= 219 || HAS_LARGE_LCD(board)) ? 32 : 16)
#define MAX_GVARS(board, version) 9
#define MAX_SCRIPTS(board) (IS_FAMILY_HORUS_OR_T16(board) ? 9 : 7)
#define MAX_TELEMETRY_SENSORS(board, version) (version <= 218 ? 32 : ((IS_FAMILY_HORUS_OR_T16(board) || IS_TARANIS_X9(board) || IS_FLYSKY_NV14(board)) ? 60 : 40))
#define MAX_TELEMETRY_SENSORS(board, version) (version <= 218 ? 32 : ((IS_FAMILY_HORUS_OR_T16(board) || IS_TARANIS_X9(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_PL18(board)) ? 60 : 40))
#define NUM_PPM_INPUTS(board, version) 16
#define ROTENC_COUNT(board, version) ((IS_STM32(board) && version >= 218) ? 0 : 1)
#define MAX_AUX_TRIMS(board) ((IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board)) ? 2 : 0)
#define MAX_AUX_TRIMS(board) ((IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board) && !IS_FLYSKY_PL18(board)) ? 2 : 0)
#define MAX_SOURCE_TYPE_SPECIAL(board, version) SOURCE_TYPE_SPECIAL_COUNT

inline int switchIndex(int i, Board::Type board, unsigned int version)
Expand Down Expand Up @@ -2605,7 +2605,7 @@ class TopBarField: public StructField {
TopBarField(DataField * parent, TopBarPersistentData & topBar, Board::Type board, unsigned int version):
StructField(parent, "Top Bar")
{
Append(new WidgetsContainerPersistentField<TopBarPersistentData>(this, topBar, IS_FLYSKY_NV14(board) ? 2 : 4, MAX_TOPBAR_OPTIONS, board, version));
Append(new WidgetsContainerPersistentField<TopBarPersistentData>(this, topBar, (IS_FLYSKY_NV14(board) || IS_FLYSKY_PL18(board)) ? 2 : 4, MAX_TOPBAR_OPTIONS, board, version));
//dump();
}
};
Expand Down Expand Up @@ -2907,7 +2907,7 @@ void OpenTxModelData::beforeExport()

// TODO remove when enum not radio specific requires eeprom change and conversion
// Note: this must mirror reverse afterImport
if (!IS_FLYSKY_NV14(board))
if (!IS_FLYSKY_NV14(board) && !IS_FLYSKY_PL18(board))
modelData.trainerMode -= 1;

if (modelData.trainerMode > TRAINER_MODE_SLAVE_JACK) {
Expand Down Expand Up @@ -2954,7 +2954,7 @@ void OpenTxModelData::afterImport()

// TODO remove when enum not radio specific requires eeprom change and conversion
// Note: this must mirror reverse beforeExport
if (!IS_FLYSKY_NV14(board))
if (!IS_FLYSKY_NV14(board) && !IS_FLYSKY_PL18(board))
modelData.trainerMode += 1;

if (modelData.trainerMode > TRAINER_MODE_SLAVE_JACK) {
Expand Down Expand Up @@ -3000,7 +3000,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type

internalField.Append(new UnsignedField<16>(this, chkSum));

if (!IS_FAMILY_HORUS_OR_T16(board) || (IS_FLYSKY_NV14(board))) {
if (!IS_FAMILY_HORUS_OR_T16(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_PL18(board)) {
internalField.Append(new UnsignedField<8>(this, generalData.currModelIndex));
internalField.Append(new UnsignedField<8>(this, generalData.contrast));
}
Expand Down Expand Up @@ -3064,11 +3064,11 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
internalField.Append(new SignedField<8>(this, generalData.PPM_Multiplier));
internalField.Append(new SignedField<8>(this, generalData.hapticLength));

if (version < 218 || (!IS_TARANIS(board) && !IS_FAMILY_HORUS_OR_T16(board)) || IS_FLYSKY_NV14(board)) {
if (version < 218 || (!IS_TARANIS(board) && !IS_FAMILY_HORUS_OR_T16(board)) || IS_FLYSKY_NV14(board) || IS_FLYSKY_PL18(board)) {
internalField.Append(new UnsignedField<8>(this, generalData.reNavigation));
}

if ((!IS_TARANIS(board) && !IS_FAMILY_HORUS_OR_T16(board)) || IS_FLYSKY_NV14(board)) {
if ((!IS_TARANIS(board) && !IS_FAMILY_HORUS_OR_T16(board)) || IS_FLYSKY_NV14(board) || IS_FLYSKY_PL18(board)) {
internalField.Append(new UnsignedField<8>(this, generalData.stickReverse));
}

Expand Down
15 changes: 14 additions & 1 deletion companion/src/firmwares/opentx/opentxinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ const char * OpenTxEepromInterface::getName()
return "EdgeTX for FlySky NV14";
case BOARD_FLYSKY_EL18:
return "EdgeTX for FlySky EL18";
case BOARD_FLYSKY_PL18:
return "EdgeTX for FlySky PL18";
case BOARD_BETAFPV_LR3PRO:
return "EdgeTx for BETAFPV LR3PRO";
case BOARD_IFLIGHT_COMMANDO8:
Expand Down Expand Up @@ -660,6 +662,8 @@ int OpenTxFirmware::getCapability(::Capability capability)
case LcdWidth:
if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))
return 320;
else if (IS_FLYSKY_PL18(board))
return 480;
else if (IS_FAMILY_HORUS_OR_T16(board))
return 480;
else if (IS_TARANIS_SMALL(board))
Expand All @@ -671,6 +675,8 @@ int OpenTxFirmware::getCapability(::Capability capability)
case LcdHeight:
if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))
return 480;
else if (IS_FLYSKY_PL18(board))
return 320;
else if (IS_FAMILY_HORUS_OR_T16(board))
return 272;
else
Expand Down Expand Up @@ -773,7 +779,7 @@ int OpenTxFirmware::getCapability(::Capability capability)
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) || IS_FLYSKY_EL18(board)) ? true : false;
IS_TARANIS_X9DP_2019(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_FLYSKY_PL18(board)) ? true : false;
case HasADCJitterFilter:
return IS_HORUS_OR_TARANIS(board);
case HasTelemetryBaudrate:
Expand Down Expand Up @@ -1427,6 +1433,13 @@ void registerOpenTxFirmwares()
addOpenTxRfOptions(firmware, FLEX + AFHDS2A + AFHDS3);
registerOpenTxFirmware(firmware);

/* FlySky PL18 board */
firmware = new OpenTxFirmware("opentx-pl18", QCoreApplication::translate("Firmware", "FlySky PL18"), BOARD_FLYSKY_PL18);
addOpenTxFrskyOptions(firmware);
firmware->addOption("bluetooth", Firmware::tr("Support for bluetooth module"));
addOpenTxRfOptions(firmware, FLEX + AFHDS3);
registerOpenTxFirmware(firmware);

/* BETAFPV LR3PRO board */
firmware = new OpenTxFirmware(FIRMWAREID("lr3pro"), QCoreApplication::translate("Firmware", "BETAFPV LiteRadio3 Pro"), BOARD_BETAFPV_LR3PRO);
addOpenTxCommonOptions(firmware);
Expand Down
Binary file added companion/src/images/simulator/PL18/bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added companion/src/images/simulator/PL18/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added companion/src/images/simulator/PL18/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added companion/src/images/simulator/PL18/top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions companion/src/simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set(simulation_SRCS
simulateduiwidgetTX16S.cpp
simulateduiwidgetNV14.cpp
simulateduiwidgetEL18.cpp
simulateduiwidgetPL18.cpp
simulatorinterface.cpp
simulatormainwindow.cpp
simulatorstartupdialog.cpp
Expand Down Expand Up @@ -63,6 +64,7 @@ set(simulation_UIS
simulateduiwidgetTX16S.ui
simulateduiwidgetNV14.ui
simulateduiwidgetEL18.ui
simulateduiwidgetPL18.ui
simulatormainwindow.ui
simulatorstartupdialog.ui
simulatorwidget.ui
Expand Down
Loading

0 comments on commit 688948f

Please sign in to comment.