From 810d2d79788d15efffe229ef811f35b59085af33 Mon Sep 17 00:00:00 2001 From: 3djc Date: Tue, 26 Nov 2019 14:53:45 +0100 Subject: [PATCH] Various fixes around Companion trainer mode (#7116) Various fixes around Companion trainer mode Fixes #7091 --- companion/src/firmwares/modeldata.h | 3 +++ companion/src/generaledit/hardware.cpp | 2 +- companion/src/modeledit/setup.cpp | 15 +++++++++++++-- companion/src/modeledit/setup_module.ui | 15 +++++++++++++++ radio/src/dataconstants.h | 6 +----- radio/src/gui/480x272/model_setup.cpp | 2 +- radio/src/translations/untranslated.h | 12 +++--------- 7 files changed, 37 insertions(+), 18 deletions(-) diff --git a/companion/src/firmwares/modeldata.h b/companion/src/firmwares/modeldata.h index 2d384415f..c4959d456 100644 --- a/companion/src/firmwares/modeldata.h +++ b/companion/src/firmwares/modeldata.h @@ -123,6 +123,9 @@ enum TrainerMode { TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE, TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE, TRAINER_MODE_MASTER_BATTERY_COMPARTMENT, + TRAINER_MODE_MASTER_BLUETOOTH, + TRAINER_MODE_SLAVE_BLUETOOTH, + TRAINER_MODE_MULTI }; class ModelData { diff --git a/companion/src/generaledit/hardware.cpp b/companion/src/generaledit/hardware.cpp index 33273d48d..737882d78 100644 --- a/companion/src/generaledit/hardware.cpp +++ b/companion/src/generaledit/hardware.cpp @@ -172,7 +172,7 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings ui->txCurrentCalibrationLabel->hide(); } - if (IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board)|| IS_TARANIS_X9E(board) || IS_HORUS(board) || IS_JUMPER_T12(board)) { + if (IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board)|| IS_TARANIS_X9E(board) || IS_HORUS(board)) { ui->bluetoothMode->addItem(tr("OFF"), 0); if (IS_TARANIS_X9E(board)) { ui->bluetoothMode->addItem(tr("Enabled"), 1); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index d5e11d59c..8ad4e8932 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -195,13 +195,24 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul ui->label_module->setText(ModuleData::indexToString(moduleIdx, firmware)); if (moduleIdx < 0) { - if (IS_HORUS(firmware->getBoard())) { + if (!IS_TARANIS(firmware->getBoard())) { ui->trainerMode->setItemData(TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE, 0, Qt::UserRole - 1); ui->trainerMode->setItemData(TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE, 0, Qt::UserRole - 1); + ui->trainerMode->setItemData(TRAINER_MODE_MASTER_BATTERY_COMPARTMENT, 0, Qt::UserRole - 1); } - if (generalSettings.auxSerialMode != UART_MODE_SBUS_TRAINER) { + else if (generalSettings.auxSerialMode != UART_MODE_SBUS_TRAINER) { ui->trainerMode->setItemData(TRAINER_MODE_MASTER_BATTERY_COMPARTMENT, 0, Qt::UserRole - 1); } + + if (generalSettings.bluetoothMode != 2) { + ui->trainerMode->setItemData(TRAINER_MODE_MASTER_BLUETOOTH, 0, Qt::UserRole - 1); + ui->trainerMode->setItemData(TRAINER_MODE_SLAVE_BLUETOOTH, 0, Qt::UserRole - 1); + } + + if (!IS_JUMPER_T16(firmware->getBoard())) { + ui->trainerMode->setItemData(TRAINER_MODE_MULTI, 0, Qt::UserRole - 1); + } + ui->trainerMode->setCurrentIndex(model.trainerMode); if (!IS_HORUS_OR_TARANIS(firmware->getBoard())) { ui->label_trainerMode->hide(); diff --git a/companion/src/modeledit/setup_module.ui b/companion/src/modeledit/setup_module.ui index 80433a472..c0a54d024 100644 --- a/companion/src/modeledit/setup_module.ui +++ b/companion/src/modeledit/setup_module.ui @@ -934,6 +934,21 @@ Master/SBUS in battery compartment + + + Master/Bluetooth + + + + + Slave/Bluetooth + + + + + Master/Multi + + diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 46bb4dbaa..c747b39bb 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -193,10 +193,8 @@ enum TrainerMode { TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE, TRAINER_MODE_MASTER_BATTERY_COMPARTMENT, #endif -#if defined(BLUETOOTH) TRAINER_MODE_MASTER_BLUETOOTH, TRAINER_MODE_SLAVE_BLUETOOTH, -#endif TRAINER_MODE_MULTI, }; #elif defined(PCBSKY9X) @@ -207,12 +205,10 @@ enum TrainerMode { }; #endif -#if defined(MULTIMODULE) +#if defined(RADIO_T16) #define TRAINER_MODE_MAX() TRAINER_MODE_MULTI #elif defined(BLUETOOTH) #define TRAINER_MODE_MAX() TRAINER_MODE_SLAVE_BLUETOOTH -#elif defined(RADIO_T16) - #define TRAINER_MODE_MAX() TRAINER_MODE_SLAVE #elif defined(PCBX7) || defined(PCBXLITE) #define TRAINER_MODE_MAX() TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE #else diff --git a/radio/src/gui/480x272/model_setup.cpp b/radio/src/gui/480x272/model_setup.cpp index c70ea488c..15f1b58c6 100644 --- a/radio/src/gui/480x272/model_setup.cpp +++ b/radio/src/gui/480x272/model_setup.cpp @@ -1209,7 +1209,7 @@ bool menuModelSetup(event_t event) case ITEM_MODEL_SETUP_TRAINER_MODE: lcdDrawText(MENUS_MARGIN_LEFT + INDENT_WIDTH, y, STR_MODE); - g_model.trainerData.mode = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_VTRAINERMODES, g_model.trainerData.mode, 0, TRAINER_MODE_MAX(), attr, event); + g_model.trainerData.mode = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_VTRAINERMODES, g_model.trainerData.mode, 0, TRAINER_MODE_MAX(), attr, event, isTrainerModeAvailable); #if defined(BLUETOOTH) if (attr && checkIncDec_Ret) { bluetooth.state = BLUETOOTH_STATE_OFF; diff --git a/radio/src/translations/untranslated.h b/radio/src/translations/untranslated.h index 5c55aad6d..95fc0c716 100644 --- a/radio/src/translations/untranslated.h +++ b/radio/src/translations/untranslated.h @@ -68,18 +68,12 @@ #define TR_VSWITCHES "---" "ID0""ID1""ID2" "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #endif -#if defined(PCBHORUS) && !defined(BLUETOOTH) - #define TR_VTRAINERMODES TR_VTRAINER_MASTER_JACK TR_VTRAINER_SLAVE_JACK TR_VTRAINER_MULTI -#elif defined(PCBHORUS) +#if defined(PCBHORUS) #define TR_VTRAINERMODES TR_VTRAINER_MASTER_JACK TR_VTRAINER_SLAVE_JACK TR_VTRAINER_BLUETOOTH TR_VTRAINER_MULTI -#elif defined(PCBX9E) - #define TR_VTRAINERMODES TR_VTRAINER_MASTER_JACK TR_VTRAINER_SLAVE_JACK TR_VTRAINER_MASTER_SBUS_MODULE TR_VTRAINER_MASTER_CPPM_MODULE TR_VTRAINER_MASTER_BATTERY TR_VTRAINER_BLUETOOTH TR_VTRAINER_MULTI -#elif defined(PCBTARANIS) && defined(BLUETOOTH) - #define TR_VTRAINERMODES TR_VTRAINER_MASTER_JACK TR_VTRAINER_SLAVE_JACK TR_VTRAINER_MASTER_SBUS_MODULE TR_VTRAINER_MASTER_CPPM_MODULE TR_VTRAINER_MASTER_BATTERY TR_VTRAINER_BLUETOOTH TR_VTRAINER_MULTI #elif defined(PCBTARANIS) - #define TR_VTRAINERMODES TR_VTRAINER_MASTER_JACK TR_VTRAINER_SLAVE_JACK TR_VTRAINER_MASTER_SBUS_MODULE TR_VTRAINER_MASTER_CPPM_MODULE TR_VTRAINER_MASTER_BATTERY TR_VTRAINER_MULTI + #define TR_VTRAINERMODES TR_VTRAINER_MASTER_JACK TR_VTRAINER_SLAVE_JACK TR_VTRAINER_MASTER_SBUS_MODULE TR_VTRAINER_MASTER_CPPM_MODULE TR_VTRAINER_MASTER_BATTERY TR_VTRAINER_BLUETOOTH TR_VTRAINER_MULTI #else - #define TR_VTRAINERMODES TR_VTRAINER_MASTER_JACK TR_VTRAINER_SLAVE_JACK TR_VTRAINER_MASTER_CPPM_MODULE TR_VTRAINER_MASTER_BATTERY + #define TR_VTRAINERMODES TR_VTRAINER_MASTER_JACK TR_VTRAINER_SLAVE_JACK TR_VTRAINER_MASTER_CPPM_MODULE TR_VTRAINER_MASTER_BATTERY TR_VTRAINER_BLUETOOTH TR_VTRAINER_MULTI #endif #define TR_VSRCRAW "---\0" TR_STICKS_VSRCRAW TR_POTS_VSRCRAW TR_ROTARY_ENCODERS TR_GYR_VSRCRAW "MAX\0" TR_CYC_VSRCRAW TR_TRIMS_VSRCRAW TR_SW_VSRCRAW TR_EXTRA_VSRCRAW -- 2.11.4.GIT