Skip to content

Commit

Permalink
feat: Flysky PL18 Support (EdgeTX#4105)
Browse files Browse the repository at this point in the history
Co-authored-by: raphaelcoeffic <[email protected]>
Co-authored-by: rotorman <[email protected]>
Co-authored-by: Xy201207 <[email protected]>
Co-authored-by: Peter Feerick <[email protected]>
  • Loading branch information
5 people authored and wimalopaan committed Dec 6, 2023
1 parent 6d56d43 commit abe9f61
Show file tree
Hide file tree
Showing 128 changed files with 9,179 additions and 172 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
- tx16s
- nv14
- el18
- pl18
- pl18ev
- t12
- t16
- t18
Expand Down Expand Up @@ -90,9 +92,9 @@ jobs:
matrix:
target:
- nv14;el18
- pl18;pl18ev
- t12
- t16
- t18
- t16;t18
- t8;zorro;pocket;mt12;commando8
- tlite;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 @@ -16,6 +16,7 @@ jobs:
matrix:
target:
- nv14;el18
- pl18;pl18ev
- t12
- t16
- t18
Expand Down
2 changes: 2 additions & 0 deletions companion/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ elseif(PCB STREQUAL X10 AND PCBREV STREQUAL T18)
set(FLAVOUR t18)
elseif(PCB STREQUAL NV14 AND PCBREV STREQUAL EL18)
set(FLAVOUR el18)
elseif(PCB STREQUAL PL18)
set(FLAVOUR pl18)
else()
string(TOLOWER ${PCB} FLAVOUR)
endif()
Expand Down
4 changes: 4 additions & 0 deletions companion/src/companion.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@
<file>images/simulator/NV14/right.png</file>
<file>images/simulator/NV14/top.png</file>
<file>images/simulator/NV14/bottom.png</file>
<file>images/simulator/PL18/left.png</file>
<file>images/simulator/PL18/right.png</file>
<file>images/simulator/PL18/top.png</file>
<file>images/simulator/PL18/bottom.png</file>
<file>images/wizard/ailerons.png</file>
<file>images/wizard/airbrakes.png</file>
<file>images/wizard/elevons.png</file>
Expand Down
49 changes: 42 additions & 7 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 @@ -159,6 +161,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 @@ -206,6 +209,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 @@ -419,6 +423,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 @@ -497,6 +515,8 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return 7;
else if (IS_HORUS_X12S(board))
return 3;
else if (IS_FLYSKY_PL18(board))
return 3;
else
return 3;

Expand All @@ -509,7 +529,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
case Sliders:
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))
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 @@ -531,7 +551,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 @@ -558,6 +578,8 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return 6;
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 || board == BOARD_JUMPER_TPRO)
return 6;
else if (board == BOARD_RADIOMASTER_POCKET)
Expand Down Expand Up @@ -600,7 +622,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 @@ -610,7 +632,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 @@ -626,7 +650,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 All @@ -647,7 +671,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
return false;

case SportMaxBaudRate:
if (IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_TARANIS_X7_ACCESS(board) ||
if (IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_FLYSKY_PL18(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
Expand Down Expand Up @@ -833,6 +857,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 @@ -964,6 +996,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 Expand Up @@ -1198,6 +1232,7 @@ int Boards::getDefaultInternalModules(Board::Type board)
case BOARD_JUMPER_TLITE_F4:
case BOARD_JUMPER_TPRO:
case BOARD_JUMPER_TPROV2:
case BOARD_FLYSKY_PL18:
return (int)MODULE_TYPE_MULTIMODULE;

case BOARD_BETAFPV_LR3PRO:
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 @@ -69,6 +69,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 @@ -398,6 +399,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 @@ -475,7 +481,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 @@ -485,7 +493,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
11 changes: 9 additions & 2 deletions companion/src/firmwares/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,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 @@ -269,7 +271,7 @@ void GeneralSettings::init()

internalModule = g.profile[g.sessionId()].defaultInternalModule();

if (IS_FLYSKY_NV14(board))
if (IS_FLYSKY_NV14(board) || IS_FLYSKY_PL18(board))
stickDeadZone = 2;

}
Expand All @@ -285,7 +287,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 @@ -294,6 +296,11 @@ 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;
potConfig[2] = 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 @@ -116,7 +116,7 @@ inline int MAX_POTS_STORAGE(Board::Type board, int version)
{
if (version <= 218 && IS_FAMILY_HORUS_OR_T16(board))
return 3;
if (version <= 220 && IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board))
if (version <= 220 && IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board) && !IS_FLYSKY_PL18(board))
return 5;
if (IS_FAMILY_T12(board))
return 2;
Expand Down Expand Up @@ -147,7 +147,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 @@ -183,7 +183,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 @@ -211,10 +211,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 @@ -2910,7 +2910,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 @@ -2957,7 +2957,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 @@ -3003,7 +3003,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 @@ -3067,11 +3067,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
Loading

0 comments on commit abe9f61

Please sign in to comment.