Skip to content

Commit

Permalink
fix(cpn): some trainer options not working (#5684)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfeerick authored Nov 29, 2024
1 parent 7594a47 commit 0ea41f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions companion/src/firmwares/boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
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_POCKET(board)) ||
IS_FAMILY_T16(board) || IS_FAMILY_HORUS(board) ||
(getCapability(board, HasExternalModuleSupport) && (IS_TARANIS(board) && !IS_FAMILY_T12(board))));

case LcdDepth:
Expand Down
3 changes: 2 additions & 1 deletion companion/src/firmwares/edgetx/yaml_modeldata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ static const YamlLookupTable trainerModeLut = {
{ TRAINER_MODE_SLAVE_JACK, "SLAVE" },
{ TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE, "MASTER_SBUS_EXT" },
{ TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE, "MASTER_CPPM_EXT" },
{ TRAINER_MODE_MASTER_SERIAL, "MASTER_BATT_COMP" },
{ TRAINER_MODE_MASTER_SERIAL, "MASTER_SERIAL" },
{ TRAINER_MODE_MASTER_SERIAL, "MASTER_BATT_COMP" }, // depreciated, kept for conversion from older settings
{ TRAINER_MODE_MASTER_BLUETOOTH, "MASTER_BT" },
{ TRAINER_MODE_SLAVE_BLUETOOTH, "SLAVE_BT" },
{ TRAINER_MODE_MULTI, "MASTER_MULTI" },
Expand Down
20 changes: 10 additions & 10 deletions companion/src/firmwares/modeldata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,16 @@ bool ModelData::isTrainerModeAvailable(const GeneralSettings & generalSettings,
generalSettings.bluetoothMode)
return false;

if (value == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE &&
!Boards::getCapability(board, Board::HasTrainerModuleSBUS))
return false;

if ((value == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || value == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE) &&
(Boards::getCapability(board, Board::HasTrainerModuleCPPM) ||
Boards::getCapability(board, Board::HasTrainerModuleSBUS)) &&
moduleData[1].protocol != PULSES_OFF)
return false;

if (value == TRAINER_MODE_MASTER_SERIAL &&
(generalSettings.serialPort[GeneralSettings::SP_AUX1] != GeneralSettings::AUX_SERIAL_SBUS_TRAINER &&
generalSettings.serialPort[GeneralSettings::SP_AUX2] != GeneralSettings::AUX_SERIAL_SBUS_TRAINER))
Expand All @@ -1669,16 +1679,6 @@ bool ModelData::isTrainerModeAvailable(const GeneralSettings & generalSettings,
!Boards::getCapability(board, Board::HasTrainerModuleCPPM))
return false;

if (value == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE &&
!Boards::getCapability(board, Board::HasTrainerModuleSBUS))
return false;

if ((value == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || value == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE) &&
(Boards::getCapability(board, Board::HasTrainerModuleCPPM) ||
Boards::getCapability(board, Board::HasTrainerModuleSBUS)) &&
moduleData[1].protocol != PULSES_OFF)
return false;

if (value == TRAINER_MODE_MULTI &&
((!Boards::getCapability(board, Board::HasInternalModuleSupport) &&
!Boards::getCapability(board, Board::HasExternalModuleSupport)) ||
Expand Down

0 comments on commit 0ea41f2

Please sign in to comment.