From 149e1a2df00f680404691dadbb59de62abecc3bf Mon Sep 17 00:00:00 2001 From: Neil Horne <15316949+elecpower@users.noreply.github.com> Date: Thu, 26 Sep 2024 20:39:51 +1000 Subject: [PATCH] feat(cpn): add support for surface radios inc Radiomaster MT12 (#5381) --- companion/src/apppreferencesdialog.cpp | 44 +- companion/src/apppreferencesdialog.h | 4 + companion/src/apppreferencesdialog.ui | 4 +- .../src/datamodels/compounditemmodels.cpp | 4 +- companion/src/firmwares/boardjson.cpp | 87 +- companion/src/firmwares/boardjson.h | 27 +- companion/src/firmwares/boards.cpp | 99 +- companion/src/firmwares/boards.h | 79 + .../firmwares/edgetx/yaml_generalsettings.cpp | 2 +- .../src/firmwares/edgetx/yaml_modeldata.cpp | 44 +- .../src/firmwares/edgetx/yaml_rawsource.cpp | 2 +- companion/src/firmwares/eeprominterface.h | 18 +- companion/src/firmwares/flightmodedata.cpp | 2 +- companion/src/firmwares/generalsettings.cpp | 118 +- companion/src/firmwares/generalsettings.h | 22 + companion/src/firmwares/modeldata.cpp | 23 +- companion/src/firmwares/modeldata.h | 4 +- .../src/firmwares/opentx/opentxinterface.cpp | 64 +- companion/src/firmwares/rawsource.cpp | 30 +- companion/src/firmwares/rawswitch.cpp | 33 +- companion/src/generaledit/generaloptions.cpp | 2 +- companion/src/generaledit/generalsetup.cpp | 494 ++-- companion/src/generaledit/generalsetup.h | 6 +- companion/src/generaledit/generalsetup.ui | 2434 ++++++++--------- companion/src/generaledit/hardware.cpp | 10 + companion/src/generaledit/trainer.cpp | 2 +- companion/src/helpers.cpp | 18 +- companion/src/helpers.h | 5 +- .../src/modeledit/colorcustomscreens.cpp | 18 +- companion/src/modeledit/expodialog.ui | 2 +- companion/src/modeledit/flightmodes.cpp | 102 +- companion/src/modeledit/flightmodes.h | 17 +- companion/src/modeledit/mixerdialog.ui | 2 +- companion/src/modeledit/modeledit.cpp | 11 +- companion/src/modeledit/modeloptions.cpp | 2 +- companion/src/modeledit/setup.cpp | 30 +- companion/src/modeledit/setup.h | 1 + companion/src/shared/genericpanel.cpp | 1 + companion/src/shared/genericpanel.h | 2 + companion/src/simulation/CMakeLists.txt | 7 + companion/src/simulation/debugoutput.h | 6 +- companion/src/simulation/filteredtextbuffer.h | 6 +- companion/src/simulation/joystick.h | 5 +- companion/src/simulation/joystickdialog.h | 5 +- .../src/simulation/radiooutputswidget.cpp | 3 +- companion/src/simulation/radiooutputswidget.h | 5 +- companion/src/simulation/radiouiaction.h | 19 +- .../src/simulation/simulateduiwidget.cpp | 160 +- companion/src/simulation/simulateduiwidget.h | 56 +- .../src/simulation/simulateduiwidgetBoxer.cpp | 21 + .../simulation/simulateduiwidgetCommando8.cpp | 21 + .../simulateduiwidgetFatfishF16.cpp | 1 - .../src/simulation/simulateduiwidgetGeneric.h | 48 + .../simulation/simulateduiwidgetGeneric.ui | 210 ++ .../simulation/simulateduiwidgetJumperT12.cpp | 21 + .../simulation/simulateduiwidgetJumperT14.cpp | 21 + .../simulation/simulateduiwidgetJumperT20.cpp | 21 + .../simulateduiwidgetJumperTLITE.cpp | 21 + .../simulateduiwidgetJumperTPRO.cpp | 21 + .../simulation/simulateduiwidgetLR3PRO.cpp | 21 + .../src/simulation/simulateduiwidgetMT12.cpp | 33 + .../simulation/simulateduiwidgetPocket.cpp | 21 + .../src/simulation/simulateduiwidgetT8.cpp | 21 + .../src/simulation/simulateduiwidgetTX12.cpp | 21 + .../src/simulation/simulateduiwidgetX7.cpp | 21 + .../simulation/simulateduiwidgetX9LITE.cpp | 21 + .../src/simulation/simulateduiwidgetXLITE.cpp | 21 + .../src/simulation/simulateduiwidgetZorro.cpp | 21 + companion/src/simulation/simulator.h | 6 +- companion/src/simulation/simulator_strings.h | 26 +- companion/src/simulation/simulatorinterface.h | 5 +- .../src/simulation/simulatormainwindow.h | 5 +- .../src/simulation/simulatormainwindow.ui | 4 +- .../src/simulation/simulatorstartupdialog.h | 5 +- companion/src/simulation/simulatorwidget.cpp | 5 +- companion/src/simulation/simulatorwidget.h | 5 +- companion/src/simulation/telemetrysimu.h | 1 - companion/src/simulation/trainersimu.h | 7 +- .../src/simulation/widgets/buttonswidget.h | 46 +- .../src/simulation/widgets/radiofaderwidget.h | 8 +- .../src/simulation/widgets/radiokeywidget.h | 29 +- .../simulation/widgets/radioswitchwidget.h | 5 +- .../src/simulation/widgets/radiotrimwidget.h | 5 +- .../src/simulation/widgets/radiowidget.cpp | 6 +- .../src/simulation/widgets/radiowidget.h | 6 +- .../src/simulation/widgets/sliderwidget.h | 5 +- .../widgets/virtualjoystickwidget.cpp | 303 +- .../widgets/virtualjoystickwidget.h | 10 +- radio/src/hal/key_driver.h | 1 + tools/build-companion.sh | 2 +- 90 files changed, 3301 insertions(+), 1942 deletions(-) create mode 100644 companion/src/simulation/simulateduiwidgetGeneric.h create mode 100644 companion/src/simulation/simulateduiwidgetGeneric.ui create mode 100644 companion/src/simulation/simulateduiwidgetMT12.cpp diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index fbf7e5d82ca..13d86e90241 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -29,23 +29,27 @@ #include "joystickdialog.h" #endif #include "moduledata.h" -#include "compounditemmodels.h" +#include "filtereditemmodels.h" #include "updates/updatefactories.h" #include "updates/updateoptionsdialog.h" -#include +constexpr char FIM_TEMPLATESETUP[] {"Template Setup"}; AppPreferencesDialog::AppPreferencesDialog(QWidget * parent, UpdateFactories * factories) : QDialog(parent), ui(new Ui::AppPreferencesDialog), updateLock(false), mainWinHasDirtyChild(false), - factories(factories) + factories(factories), + panelItemModels(nullptr) { ui->setupUi(this); setWindowIcon(CompanionIcon("apppreferences.png")); ui->tabWidget->setCurrentIndex(0); + panelItemModels = new FilteredItemModelFactory(); + panelItemModels->registerItemModel(new FilteredItemModel(GeneralSettings::templateSetupItemModel()), FIM_TEMPLATESETUP); + initSettings(); connect(ui->boardCB, SIGNAL(currentIndexChanged(int)), this, SLOT(onBaseFirmwareChanged())); connect(ui->opt_appDebugLog, &QCheckBox::toggled, this, &AppPreferencesDialog::toggleAppLogSettings); @@ -65,6 +69,7 @@ AppPreferencesDialog::AppPreferencesDialog(QWidget * parent, UpdateFactories * f AppPreferencesDialog::~AppPreferencesDialog() { delete ui; + delete panelItemModels; } void AppPreferencesDialog::setMainWinHasDirtyChild(bool value) @@ -156,8 +161,8 @@ void AppPreferencesDialog::accept() profile.defaultInternalModule(ui->defaultInternalModuleCB->currentData().toInt()); profile.externalModuleSize(ui->externalModuleSizeCB->currentData().toInt()); - profile.channelOrder(ui->channelorderCB->currentIndex()); - profile.defaultMode(ui->stickmodeCB->currentIndex()); + profile.channelOrder(ui->channelorderCB->currentData().toInt()); + profile.defaultMode(ui->stickmodeCB->currentData().toInt()); profile.burnFirmware(ui->burnFirmware->isChecked()); profile.sdPath(ui->sdPath->text()); profile.pBackupDir(ui->profilebackupPath->text()); @@ -305,8 +310,12 @@ void AppPreferencesDialog::initSettings() ui->defaultInternalModuleCB->setCurrentIndex(ui->defaultInternalModuleCB->findData(profile.defaultInternalModule())); ui->externalModuleSizeCB->setModel(Boards::externalModuleSizeItemModel()); ui->externalModuleSizeCB->setCurrentIndex(ui->externalModuleSizeCB->findData(profile.externalModuleSize())); - ui->channelorderCB->setCurrentIndex(profile.channelOrder()); - ui->stickmodeCB->setCurrentIndex(profile.defaultMode()); + panelItemModels->getItemModel(FIM_TEMPLATESETUP)->setFilterFlags(Boards::isAir() ? GeneralSettings::RadioTypeContextAir : + GeneralSettings::RadioTypeContextSurface); + ui->channelorderCB->setModel(panelItemModels->getItemModel(FIM_TEMPLATESETUP)); + ui->channelorderCB->setCurrentIndex(ui->channelorderCB->findData(profile.channelOrder())); + ui->stickmodeCB->setModel(GeneralSettings::stickModeItemModel()); + ui->stickmodeCB->setCurrentIndex(ui->stickmodeCB->findData(profile.defaultMode())); ui->sdPath->setText(profile.sdPath()); if (!profile.pBackupDir().isEmpty()) { if (QDir(profile.pBackupDir()).exists()) { @@ -321,6 +330,11 @@ void AppPreferencesDialog::initSettings() ui->pbackupEnable->setDisabled(true); } + if (Boards::isSurface()) { + ui->stickmodeLabel->hide(); + ui->stickmodeCB->hide(); + } + ui->profileNameLE->setText(profile.name()); QString hwSettings; @@ -649,7 +663,8 @@ bool AppPreferencesDialog::displayImage(const QString & fileName) return false; ui->imageLabel->setPixmap(makePixMap(image)); - ui->imageLabel->setFixedSize(getCurrentFirmware()->getCapability(LcdWidth), getCurrentFirmware()->getCapability(LcdHeight)); + ui->imageLabel->setFixedSize(Boards::getCapability(getCurrentBoard(), Board::LcdWidth), + Boards::getCapability(getCurrentBoard(), Board::LcdHeight)); return true; } @@ -690,6 +705,19 @@ void AppPreferencesDialog::onBaseFirmwareChanged() profile.externalModuleSize(Boards::getDefaultExternalModuleSize(newfw->getBoard())); ui->externalModuleSizeCB->setModel(Boards::externalModuleSizeItemModel()); ui->externalModuleSizeCB->setCurrentIndex(ui->externalModuleSizeCB->findData(profile.externalModuleSize())); + + if (Boards::isSurface()) { + profile.defaultMode(1); + ui->stickmodeLabel->hide(); + ui->stickmodeCB->hide(); + profile.channelOrder(0); + } + + ui->stickmodeCB->setCurrentIndex(ui->stickmodeCB->findData(profile.defaultMode())); + panelItemModels->getItemModel(FIM_TEMPLATESETUP)->setFilterFlags(Boards::isAir() ? GeneralSettings::RadioTypeContextAir : + GeneralSettings::RadioTypeContextSurface); + ui->channelorderCB->setCurrentIndex(ui->channelorderCB->findData(profile.channelOrder())); + } Firmware *AppPreferencesDialog::getBaseFirmware() const diff --git a/companion/src/apppreferencesdialog.h b/companion/src/apppreferencesdialog.h index 4ceef568fdb..c96caa6935c 100644 --- a/companion/src/apppreferencesdialog.h +++ b/companion/src/apppreferencesdialog.h @@ -28,6 +28,8 @@ #include #include +class FilteredItemModelFactory; + namespace Ui { class AppPreferencesDialog; } @@ -95,6 +97,8 @@ class AppPreferencesDialog : public QDialog QComboBox *cboReleaseChannel[MAX_COMPONENTS]; QPushButton *btnComponentOptions[MAX_COMPONENTS]; + FilteredItemModelFactory *panelItemModels; + void loadUpdatesTab(); }; diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index cce9a37394a..c7ed3d7d514 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -624,7 +624,7 @@ Mode 4: - + 0 @@ -676,7 +676,7 @@ Mode 4: - + 0 diff --git a/companion/src/datamodels/compounditemmodels.cpp b/companion/src/datamodels/compounditemmodels.cpp index c79ab5e7d29..9eecded4943 100644 --- a/companion/src/datamodels/compounditemmodels.cpp +++ b/companion/src/datamodels/compounditemmodels.cpp @@ -395,7 +395,7 @@ ThrottleSourceItemModel::ThrottleSourceItemModel(const GeneralSettings * const g if (!modelData) return; - setUpdateMask(IMUE_Timers | IMUE_Inputs | IMUE_TeleSensors); + setUpdateMask(IMUE_Channels); for (int i = 0; i < modelData->thrTraceSrcCount(); i++) { QStandardItem * modelItem = new QStandardItem(); @@ -407,7 +407,7 @@ ThrottleSourceItemModel::ThrottleSourceItemModel(const GeneralSettings * const g void ThrottleSourceItemModel::setDynamicItemData(QStandardItem * item, const int value) const { - item->setText(modelData->thrTraceSrcToString(value)); + item->setText(modelData->thrTraceSrcToString(generalSettings, value)); item->setData(modelData->isThrTraceSrcAvailable(generalSettings, value), IMDR_Available); } diff --git a/companion/src/firmwares/boardjson.cpp b/companion/src/firmwares/boardjson.cpp index d29346e2661..8ae3c643f2a 100644 --- a/companion/src/firmwares/boardjson.cpp +++ b/companion/src/firmwares/boardjson.cpp @@ -68,6 +68,7 @@ BoardJson::BoardJson(Board::Type board, QString hwdefn) : m_inputs(new InputsTable), m_switches(new SwitchesTable), m_trims(new TrimsTable), + m_keys(new KeysTable), m_inputCnt({0, 0, 0, 0, 0, 0, 0, 0, 0}), m_switchCnt({0, 0, 0}) { @@ -79,10 +80,12 @@ BoardJson::~BoardJson() delete m_inputs; delete m_switches; delete m_trims; + delete m_keys; } // static -void BoardJson::afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches) +void BoardJson::afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches, + KeysTable * keys, TrimsTable * trims) { // TODO json files do not contain gyro defs // Radio cmake directive IMU is currently used @@ -114,8 +117,8 @@ void BoardJson::afterLoadFixups(Board::Type board, InputsTable * inputs, Switche } } - // Flex switches are not listed in json file - int count = IS_RADIOMASTER_TX16S(board) ? 2 : 0; + // Flex switches are not listed in json file for these radios + int count = IS_RADIOMASTER_TX16S(board) || IS_RADIOMASTER_MT12(board) ? 2 : 0; for (int i = 1; i <= count; i++) { QString tag = QString("FL%1").arg(i); @@ -164,6 +167,9 @@ const int BoardJson::getCapability(const Board::Capability capability) const case Board::InputSwitches: return m_inputCnt.switches; + case Board::Keys: + return m_keys->size(); + case Board::MultiposPots: // assumes every input has potential to be one // index used for mapping 6 pos switches back to input @@ -332,6 +338,14 @@ const int BoardJson::getInputSliderIndex(int index) return -1; } +const int BoardJson::getInputThrottleIndex() +{ + if (getCapability(Board::Sticks) > 0) + return getInputTagOffset(m_inputs, Boards::getCapability(m_board, Board::Air) ? "RV" : "TH"); + + return -1; +} + const int BoardJson::getInputTypeOffset(Board::AnalogInputType type) { return getInputTypeOffset(m_inputs, type); @@ -371,6 +385,42 @@ Board::InputInfo BoardJson::getInputInfo(const InputsTable * inputs, int index) return info; } +const int BoardJson::getKeyIndex(const QString key) const +{ + return getKeyIndex(m_keys, key); +} + +// static +int BoardJson::getKeyIndex(const KeysTable * keys, QString key) +{ + for (int i = 0; i < (int)keys->size(); i++) { + if (keys->at(i).key.c_str() == key) + return i; + } + + return -1; +} + +const Board::KeyInfo BoardJson::getKeyInfo(int index) const +{ + return getKeyInfo(m_keys, index); +} + +// static +Board::KeyInfo BoardJson::getKeyInfo(const KeysTable * keys, int index) +{ + Board::KeyInfo info; + + if (index >= 0 && index < (int)keys->size()) { + KeyDefn defn = keys->at(index); + info.name = defn.name; + info.key = defn.key; + info.label = defn.label; + } + + return info; +} + // static int BoardJson::getNumericSuffix(const std::string str) { @@ -771,10 +821,10 @@ bool BoardJson::loadDefinition() if (m_board == Board::BOARD_UNKNOWN) return true; - if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_trims)) + if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_keys, m_trims)) return false; - afterLoadFixups(m_board, m_inputs, m_switches); + afterLoadFixups(m_board, m_inputs, m_switches, m_keys, m_trims); setInputCounts(m_inputs, m_inputCnt); setSwitchCounts(m_switches, m_switchCnt); @@ -795,6 +845,7 @@ bool BoardJson::loadDefinition() "flex inputs:" << getCapability(Board::FlexInputs) << "input switches:" << getCapability(Board::InputSwitches) << "trims:" << getCapability(Board::NumTrims) << + "keys:" << getCapability(Board::Keys) << "std switches:" << getCapability(Board::StandardSwitches) << "flex switches:" << getCapability(Board::FlexSwitches) << "func switches:" << getCapability(Board::FunctionSwitches) << @@ -805,7 +856,8 @@ bool BoardJson::loadDefinition() } // static -bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches, TrimsTable * trims) +bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches, + KeysTable * keys, TrimsTable * trims) { if (board == Board::BOARD_UNKNOWN) { return false; @@ -952,6 +1004,29 @@ bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs } } + if (obj.value("keys").isArray()) { + const QJsonArray &kys = obj.value("keys").toArray(); + + for (const QJsonValue &key : kys) + { + if (key.isObject()) { + const QJsonObject &o = key.toObject(); + KeyDefn k; + + if (!o.value("name").isUndefined()) { + k.name = o.value("name").toString().toStdString(); + k.key = o.value("key").toString().toStdString(); + k.label = o.value("label").toString().toStdString(); + k.tag = k.name; + } + + keys->insert(keys->end(), k); + +// qDebug() << "name:" << k.name.c_str() << "key:" << k.key.c_str() << "label:" << k.label.c_str(); + } + } + } + if (obj.value("trims").isArray()) { const QJsonArray &trms = obj.value("trims").toArray(); diff --git a/companion/src/firmwares/boardjson.h b/companion/src/firmwares/boardjson.h index 656281df7d8..856be965e49 100644 --- a/companion/src/firmwares/boardjson.h +++ b/companion/src/firmwares/boardjson.h @@ -76,6 +76,19 @@ class BoardJson typedef std::vector SwitchesTable; + struct KeyDefn { + std::string tag = ""; + std::string name = ""; + std::string key = ""; + std::string label = ""; + Board::LookupValueType cfgYaml = Board::LVT_TAG; + Board::LookupValueType refYaml = Board::LVT_NAME; + + KeyDefn() = default; + }; + + typedef std::vector KeysTable; + struct TrimDefn { std::string tag = ""; std::string name = ""; @@ -106,6 +119,7 @@ class BoardJson const int getInputSliderIndex(int index); const QString getInputTag(int index) const; const int getInputTagOffset(QString tag); + const int getInputThrottleIndex(); const int getInputTypeOffset(Board::AnalogInputType type); const int getInputYamlIndex(const QString val, YamlLookupType ylt) const; const QString getInputYamlName(int index, YamlLookupType ylt) const; @@ -119,6 +133,9 @@ class BoardJson const bool isInputStick(int index) const; const bool isInputSwitch(int index) const; + const Board::KeyInfo getKeyInfo(int index) const; + const int getKeyIndex(const QString key) const; + const int getSwitchIndex(const QString val, Board::LookupValueType lvt) const; const Board::SwitchInfo getSwitchInfo(int index) const; const QString getSwitchName(int index) const; @@ -144,6 +161,7 @@ class BoardJson InputsTable *m_inputs; SwitchesTable *m_switches; TrimsTable *m_trims; + KeysTable *m_keys; struct InputCounts { unsigned int flexGyroAxes; @@ -167,8 +185,10 @@ class BoardJson SwitchCounts m_switchCnt; - static bool loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches, TrimsTable * trims); - static void afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches); + static bool loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches, + KeysTable * keys, TrimsTable * trims); + static void afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches, + KeysTable * keys, TrimsTable * trims); static int getInputsCalibrated(const InputsTable * inputs); @@ -179,6 +199,9 @@ class BoardJson static int getInputTagOffset(const InputsTable * inputs, QString tag); static int getInputTypeOffset(const InputsTable * inputs, Board::AnalogInputType type); + static int getKeyIndex(const KeysTable * keys, QString key); + static Board::KeyInfo getKeyInfo(const KeysTable * keys, int index); + static int getSwitchIndex(const SwitchesTable * switches, QString val, Board::LookupValueType lvt); static Board::SwitchInfo getSwitchInfo(const SwitchesTable * switches, int index); static QString getSwitchName(const SwitchesTable * switches, int index); diff --git a/companion/src/firmwares/boards.cpp b/companion/src/firmwares/boards.cpp index b7e218d4d4d..3a46dd32c21 100644 --- a/companion/src/firmwares/boards.cpp +++ b/companion/src/firmwares/boards.cpp @@ -199,6 +199,7 @@ int Boards::getEEpromSize(Board::Type board) case BOARD_RADIOMASTER_ZORRO: case BOARD_RADIOMASTER_BOXER: case BOARD_RADIOMASTER_POCKET: + case BOARD_RADIOMASTER_MT12: return EESIZE_TARANIS; case BOARD_UNKNOWN: return EESIZE_MAX; @@ -256,6 +257,7 @@ int Boards::getFlashSize(Type board) case BOARD_RADIOMASTER_BOXER: case BOARD_RADIOMASTER_T8: case BOARD_RADIOMASTER_POCKET: + case BOARD_RADIOMASTER_MT12: return FSIZE_TARANIS; case BOARD_HORUS_X12S: case BOARD_X10: @@ -283,6 +285,9 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) // TODO investigate usage of any that should be covered in BoardJson::getCapability or are no longer required // some could be used when importing pre v2.10 configurations switch (capability) { + case Air: + return !getCapability(board, Surface); + case FactoryInstalledPots: if (IS_TARANIS_X9(board)) return 2; @@ -340,6 +345,40 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_POCKET(board)) || (getCapability(board, HasExternalModuleSupport) && (IS_TARANIS(board) && !IS_FAMILY_T12(board)))); + case LcdDepth: + if (IS_FAMILY_HORUS_OR_T16(board)) + return 16; + else if (IS_TARANIS_SMALL(board)) + return 1; + else if (IS_TARANIS(board)) + return 4; + else + return 1; + + case LcdHeight: + if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) + return 480; + else if (IS_FLYSKY_PL18(board) || IS_JUMPER_T15(board)) + return 320; + else if (IS_FAMILY_HORUS_OR_T16(board)) + return 272; + else + return 64; + + 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)) + return 128; + else if (IS_TARANIS(board)) + return 212; + else + return 128; + case MaxAnalogs: return getCapability(board, Board::Sticks) + getCapability(board, Board::Pots) + getCapability(board, Board::Sliders) + getCapability(board, Board::JoystickAxes) + getCapability(board, Board::GyroAxes); @@ -351,6 +390,9 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) else return 250000; // less than 400K + case Surface: + return IS_RADIOMASTER_MT12(board); + default: return getBoardJson(board)->getCapability(capability); } @@ -557,20 +599,22 @@ QString Boards::getBoardName(Board::Type board) return "Jumper T20"; case BOARD_JUMPER_T20V2: return "Jumper T20 V2"; - case BOARD_RADIOMASTER_TX16S: - return "Radiomaster TX16S"; - case BOARD_RADIOMASTER_TX12: - return "Radiomaster TX12"; - case BOARD_RADIOMASTER_TX12_MK2: - return "Radiomaster TX12 Mark II"; - case BOARD_RADIOMASTER_ZORRO: - return "Radiomaster Zorro"; case BOARD_RADIOMASTER_BOXER: return "Radiomaster Boxer"; case BOARD_RADIOMASTER_POCKET: return "Radiomaster Pocket"; + case BOARD_RADIOMASTER_MT12: + return "Radiomaster MT12"; case BOARD_RADIOMASTER_T8: return "Radiomaster T8"; + case BOARD_RADIOMASTER_TX12: + return "Radiomaster TX12"; + case BOARD_RADIOMASTER_TX12_MK2: + return "Radiomaster TX12 Mark II"; + case BOARD_RADIOMASTER_TX16S: + return "Radiomaster TX16S"; + case BOARD_RADIOMASTER_ZORRO: + return "Radiomaster Zorro"; case BOARD_FLYSKY_NV14: return "FlySky NV14"; case BOARD_FLYSKY_EL18: @@ -637,6 +681,11 @@ QList Boards::getSupportedInternalModules(Board::Type board) (int)MODULE_TYPE_FLYSKY_AFHDS3, (int)MODULE_TYPE_CROSSFIRE, }); + } else if (IS_RADIOMASTER_MT12(board)) { + modules.append({ + (int)MODULE_TYPE_CROSSFIRE, + (int)MODULE_TYPE_MULTIMODULE, + }); } else if (IS_FAMILY_HORUS_OR_T16(board) || IS_FAMILY_T12(board) || (IS_TARANIS_SMALL(board) && IS_ACCESS_RADIO(board))) { modules.append({ @@ -688,6 +737,7 @@ int Boards::getDefaultInternalModules(Board::Type board) case BOARD_BETAFPV_LR3PRO: case BOARD_RADIOMASTER_ZORRO: case BOARD_RADIOMASTER_BOXER: + case BOARD_RADIOMASTER_MT12: case BOARD_RADIOMASTER_POCKET: case BOARD_RADIOMASTER_TX12_MK2: case BOARD_IFLIGHT_COMMANDO8: @@ -729,7 +779,7 @@ void Boards::getBattRange(Board::Type board, int& vmin, int& vmax, unsigned int& case BOARD_RADIOMASTER_BOXER: case BOARD_RADIOMASTER_POCKET: case BOARD_RADIOMASTER_ZORRO: - // case BOARD_RADIOMASTER_MT12: // TODO + case BOARD_RADIOMASTER_MT12: case BOARD_JUMPER_T12: case BOARD_JUMPER_T14: case BOARD_JUMPER_TPRO: @@ -786,6 +836,7 @@ int Boards::getDefaultExternalModuleSize(Board::Type board) if (IS_TARANIS_X9LITE(board) || IS_RADIOMASTER_ZORRO(board) || + IS_RADIOMASTER_MT12(board) || IS_RADIOMASTER_POCKET(board) || IS_JUMPER_TLITE(board) || IS_JUMPER_TPRO(board) || @@ -909,6 +960,11 @@ int Boards::getInputTagOffset(QString tag, Board::Type board) return getBoardJson(board)->getInputTagOffset(tag); } +int Boards::getInputThrottleIndex(Board::Type board) +{ + return getBoardJson(board)->getInputThrottleIndex(); +} + int Boards::getInputTypeOffset(Board::AnalogInputType type, Board::Type board) { return getBoardJson(board)->getInputTypeOffset(type); @@ -929,6 +985,16 @@ int Boards::getInputsCalibrated(Board::Type board) return getBoardJson(board)->getInputsCalibrated(); } +Board::KeyInfo Boards::getKeyInfo(int index, Board::Type board) +{ + return getBoardJson(board)->getKeyInfo(index); +} + +int Boards::getKeyIndex(QString key, Board::Type board) +{ + return getBoardJson(board)->getKeyIndex(key); +} + Board::SwitchInfo Boards::getSwitchInfo(int index, Board::Type board) { return getBoardJson(board)->getSwitchInfo(index); @@ -1023,3 +1089,18 @@ bool Boards::isSwitchFunc(int index, Board::Type board) { return getBoardJson(board)->isSwitchFunc(index); } + +QString Boards::getRadioTypeString(Board::Type board) +{ + return getCapability(board == Board::BOARD_UNKNOWN ? getCurrentBoard() : board, Board::Air) ? tr("Flight") : tr("Drive"); +} + +bool Boards::isAir(Board::Type board) +{ + return getCapability(board == Board::BOARD_UNKNOWN ? getCurrentBoard() : board, Board::Air); +} + +bool Boards::isSurface(Board::Type board) +{ + return getCapability(board == Board::BOARD_UNKNOWN ? getCurrentBoard() : board, Board::Surface); +} diff --git a/companion/src/firmwares/boards.h b/companion/src/firmwares/boards.h index 1bf00d74e0e..0718867bf65 100644 --- a/companion/src/firmwares/boards.h +++ b/companion/src/firmwares/boards.h @@ -88,6 +88,7 @@ namespace Board { BOARD_JUMPER_T20V2, BOARD_FATFISH_F16, BOARD_HELLORADIOSKY_V16, + BOARD_RADIOMASTER_MT12, BOARD_TYPE_COUNT, BOARD_TYPE_MAX = BOARD_TYPE_COUNT - 1 }; @@ -160,7 +161,47 @@ namespace Board { TRIM_SW_COUNT }; + enum StickAxesSurface { + STICK_AXIS_SURFACE_RH = 0, // Steering + STICK_AXIS_SURFACE_LV, // Throttle + STICK_AXIS_SURFACE_COUNT + }; + + enum TrimAxesSurface { + TRIM_AXIS_SURFACE_RH = 0, + TRIM_AXIS_SURFACE_LH, // Throttle axis vertical but its trim horizontal in lcd + TRIM_AXIS_SURFACE_T3, + TRIM_AXIS_SURFACE_T4, + TRIM_AXIS_SURFACE_T5, + TRIM_AXIS_SURFACE_T6, + TRIM_AXIS_SURFACE_T7, + TRIM_AXIS_SURFACE_T8, + TRIM_AXIS_SURFACE_COUNT + }; + + enum TrimSwitchesSurface + { + TRIM_SW_SURFACE_RH_DEC, + TRIM_SW_SURFACE_RH_INC, + TRIM_SW_SURFACE_LH_DEC, // Throttle axis vertical but its trim horizontal in lcd + TRIM_SW_SURFACE_LH_INC, // Throttle axis vertical but its trim horizontal in lcd + TRIM_SW_SURFACE_T3_DEC, + TRIM_SW_SURFACE_T3_INC, + TRIM_SW_SURFACE_T4_DEC, + TRIM_SW_SURFACE_T4_INC, + TRIM_SW_SURFACE_T5_DEC, + TRIM_SW_SURFACE_T5_INC, + TRIM_SW_SURFACE_T6_DEC, + TRIM_SW_SURFACE_T6_INC, + TRIM_SW_SURFACE_T7_DEC, + TRIM_SW_SURFACE_T7_INC, + TRIM_SW_SURFACE_T8_DEC, + TRIM_SW_SURFACE_T8_INC, + TRIM_SW_SURFACE_COUNT + }; + enum Capability { + Air, FactoryInstalledPots, FactoryInstalledSwitches, FlexInputs, @@ -180,11 +221,15 @@ namespace Board { HasTrainerModuleCPPM, HasTrainerModuleSBUS, HasVBat, + LcdDepth, + LcdHeight, + LcdWidth, MaxAnalogs, Inputs, InputSwitches, Joysticks, JoystickAxes, + Keys, MultiposPots, MultiposPotsPositions, NumFunctionSwitchesPositions, @@ -195,6 +240,7 @@ namespace Board { SportMaxBaudRate, StandardSwitches, Sticks, + Surface, Switches, SwitchesPositions, }; @@ -294,6 +340,26 @@ namespace Board { SwitchType dflt; bool inverted; }; + + struct KeyInfo { + KeyInfo() : + key(""), + name(""), + label("") + {} + + std::string key; + std::string name; + std::string label; + }; + + struct TrimInfo { + TrimInfo() : + name("") + {} + + std::string name; + }; } class Boards @@ -343,10 +409,14 @@ class Boards static int getInputSliderIndex(int index, Board::Type board = Board::BOARD_UNKNOWN); static QString getInputTag(int index, Board::Type board = Board::BOARD_UNKNOWN); static int getInputTagOffset(QString tag, Board::Type board = Board::BOARD_UNKNOWN); + static int getInputThrottleIndex(Board::Type board = Board::BOARD_UNKNOWN); static int getInputTypeOffset(Board::AnalogInputType type, Board::Type board = Board::BOARD_UNKNOWN); static int getInputYamlIndex(QString val, int ylt, Board::Type board = Board::BOARD_UNKNOWN); static QString getInputYamlName(int index, int ylt, Board::Type board = Board::BOARD_UNKNOWN); + static Board::KeyInfo getKeyInfo(int index, Board::Type board = Board::BOARD_UNKNOWN); + static int getKeyIndex(QString key, Board::Type board = Board::BOARD_UNKNOWN); + static Board::SwitchInfo getSwitchInfo(int index, Board::Type board = Board::BOARD_UNKNOWN); static int getSwitchIndex(QString val, Board::LookupValueType lvt, Board::Type board = Board::BOARD_UNKNOWN); static QString getSwitchName(int index, Board::Type board = Board::BOARD_UNKNOWN); @@ -379,6 +449,9 @@ class Boards static AbstractStaticItemModel * flexTypeItemModel(); static std::string getLegacyAnalogMappedInputTag(const char * legacytag, Board::Type board = Board::BOARD_UNKNOWN); + static QString getRadioTypeString(Board::Type board = Board::BOARD_UNKNOWN); + static bool isAir(Board::Type board = Board::BOARD_UNKNOWN); + static bool isSurface(Board::Type board = Board::BOARD_UNKNOWN); private: @@ -501,6 +574,11 @@ inline bool IS_RADIOMASTER_BOXER(Board::Type board) return board == Board::BOARD_RADIOMASTER_BOXER; } +inline bool IS_RADIOMASTER_MT12(Board::Type board) +{ + return board == Board::BOARD_RADIOMASTER_MT12; +} + inline bool IS_RADIOMASTER_POCKET(Board::Type board) { return board == Board::BOARD_RADIOMASTER_POCKET; @@ -542,6 +620,7 @@ inline bool IS_FAMILY_T12(Board::Type board) board == Board::BOARD_RADIOMASTER_TX12_MK2 || board == Board::BOARD_RADIOMASTER_ZORRO || board == Board::BOARD_RADIOMASTER_BOXER || + board == Board::BOARD_RADIOMASTER_MT12 || board == Board::BOARD_RADIOMASTER_POCKET || board == Board::BOARD_RADIOMASTER_T8 || board == Board::BOARD_BETAFPV_LR3PRO || diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp index 74490e7bebf..ea71c49287d 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp @@ -262,7 +262,7 @@ Node convert::encode(const GeneralSettings& rhs) node["labelSingleSelect"] = rhs.labelSingleSelect; node["labelMultiMode"] = rhs.labelMultiMode; node["favMultiMode"] = rhs.favMultiMode; - } else if (fw->getCapability(LcdWidth) == 128) { + } else if (Boards::getCapability(board, Board::LcdWidth) == 128) { node["invertLCD"] = (int)rhs.invertLCD; } diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index caffdb8fc5d..a217f33f3dd 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -167,38 +167,42 @@ struct YamlThrTrace { YamlThrTrace(unsigned int cpn_value) { + Board::Type board = getCurrentBoard(); + if (cpn_value == 0) { - src = RawSource(SOURCE_TYPE_INPUT, 2/* throttle */); + if (Boards::getInputThrottleIndex(board) >= 0) + src = RawSource(SOURCE_TYPE_INPUT, Boards::getInputThrottleIndex(board) + 1); + else + src = RawSource(SOURCE_TYPE_NONE); return; } - cpn_value--; - Boards board(getCurrentBoard()); - int pots = board.getCapability(Board::Pots); - int sliders = board.getCapability(Board::Sliders); - if (cpn_value < (unsigned int)(pots + sliders)) { - src = RawSource(SOURCE_TYPE_INPUT, 4/* sticks */ + cpn_value); - } - else { - cpn_value -= pots + sliders; - src = RawSource(SOURCE_TYPE_CH, cpn_value); - } + + int sticks = Boards::getCapability(board, Board::Sticks); + int pots = Boards::getCapability(board, Board::Pots); + int sliders = Boards::getCapability(board, Board::Sliders); + + if (cpn_value <= (unsigned int)(pots + sliders)) + src = RawSource(SOURCE_TYPE_INPUT, sticks + cpn_value); + else + src = RawSource(SOURCE_TYPE_CH, cpn_value - pots - sliders); } unsigned int toCpn() { + Board::Type board = getCurrentBoard(); + int sticks = Boards::getCapability(board, Board::Sticks); + switch (src.type) { case SOURCE_TYPE_INPUT: - if (src.index == 2 /* throttle */) { + if (src.index == Boards::getInputThrottleIndex(board) + 1) return 0; - } else { - return src.index - 4/* sticks */ + 1; - } + else + return src.index - sticks; break; case SOURCE_TYPE_CH: { - Boards board(getCurrentBoard()); - int pots = board.getCapability(Board::Pots); - int sliders = board.getCapability(Board::Sliders); - return 1 + pots + sliders + src.index; + int pots = Boards::getCapability(board, Board::Pots); + int sliders = Boards::getCapability(board, Board::Sliders); + return pots + sliders + src.index; } break; default: break; diff --git a/companion/src/firmwares/edgetx/yaml_rawsource.cpp b/companion/src/firmwares/edgetx/yaml_rawsource.cpp index b63a80ccad7..88c2f8bf870 100644 --- a/companion/src/firmwares/edgetx/yaml_rawsource.cpp +++ b/companion/src/firmwares/edgetx/yaml_rawsource.cpp @@ -162,7 +162,7 @@ RawSource YamlRawSourceDecode(const std::string& src_str) } else if ((val_len == 2 && val[0] == 'S' && - val[1] >= 'A' && val[1] <= 'Z') || + val[1] >= 'A' && val[1] <= 'S') || // ST used for surface steering (val_len == 3 && ( (val[0] == 'F' && val[1] == 'L') || (val[0] == 'S' && val[1] == 'W')) && diff --git a/companion/src/firmwares/eeprominterface.h b/companion/src/firmwares/eeprominterface.h index 4ee40788015..54cb711a226 100644 --- a/companion/src/firmwares/eeprominterface.h +++ b/companion/src/firmwares/eeprominterface.h @@ -37,11 +37,16 @@ #include #include -const uint8_t modn12x3[4][4]= { - {1, 2, 3, 4}, - {1, 3, 2, 4}, - {4, 2, 3, 1}, - {4, 3, 2, 1} }; +const uint8_t modn12x3[8][4]= { + {1, 2, 3, 4}, // air mode 1 + {1, 3, 2, 4}, // air mode 2 + {4, 2, 3, 1}, // air mode 3 + {4, 3, 2, 1}, // air mode 4 + {2, 3, 4, 1}, // surface mode 1 + {2, 3, 4, 1}, // surface mode 2 + {2, 3, 4, 1}, // surface mode 3 + {2, 3, 4, 1} // surface mode 4 +}; enum Capability { Models, @@ -129,9 +134,6 @@ enum Capability { PermTimers, HasSDLogs, CSFunc, - LcdWidth, - LcdHeight, - LcdDepth, GetThrSwitch, HasDisplayText, HasTopLcd, diff --git a/companion/src/firmwares/flightmodedata.cpp b/companion/src/firmwares/flightmodedata.cpp index 2a14d0581ae..b13a73fc75d 100644 --- a/companion/src/firmwares/flightmodedata.cpp +++ b/companion/src/firmwares/flightmodedata.cpp @@ -43,7 +43,7 @@ void FlightModeData::clear(const int phaseIdx) QString FlightModeData::nameToString(int phaseIdx) const { - return RadioData::getElementName(tr("FM"), phaseIdx, name); // names are zero-based, FM0, FM1, etc + return RadioData::getElementName(Boards::isAir() ? tr("FM") : tr("DM"), phaseIdx, name); // names are zero-based, FM0, FM1, etc } bool FlightModeData::isEmpty(int phaseIdx) const diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index 0e0ce20fc9c..c4c9cd8a80a 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -27,13 +27,41 @@ #include "compounditemmodels.h" #include "yaml_ops.h" -const uint8_t chout_ar[] = { // First number is 0..23 -> template setup, Second is relevant channel out +const QList channelsAir = { // First number is 0..23 -> template setup, Second is relevant channel out 1,2,3,4 , 1,2,4,3 , 1,3,2,4 , 1,3,4,2 , 1,4,2,3 , 1,4,3,2, 2,1,3,4 , 2,1,4,3 , 2,3,1,4 , 2,3,4,1 , 2,4,1,3 , 2,4,3,1, 3,1,2,4 , 3,1,4,2 , 3,2,1,4 , 3,2,4,1 , 3,4,1,2 , 3,4,2,1, 4,1,2,3 , 4,1,3,2 , 4,2,1,3 , 4,2,3,1 , 4,3,1,2 , 4,3,2,1 }; +const QList controlsAir = { 'R', 'E', 'T', 'A' }; // channelsAir[x] - 1] entry mapping + +const QList channelsSurface = { // First number is 0..1 -> template setup, Second is relevant channel out + 1,2 , 2,1 +}; + +const QList controlsSurface = { 'S', 'T' }; // channelsSurface[x] - 1] entry mapping + +const QList useChannels(bool isBoardAir) +{ + return isBoardAir ? channelsAir : channelsSurface; +} + +const QList useControls(bool isBoardAir) +{ + return isBoardAir ? controlsAir : controlsSurface; +} + +const int channelsCount(bool isBoardAir) +{ + return isBoardAir ? channelsAir.size() : channelsSurface.size(); +} + +const int controlsCount(bool isBoardAir) +{ + return isBoardAir ? controlsAir.size() : controlsSurface.size(); +} + bool GeneralSettings::switchPositionAllowed(int index) const { if (index == 0) @@ -351,13 +379,15 @@ int GeneralSettings::getDefaultStick(unsigned int channel) const { if (channel >= CPN_MAX_STICKS) return -1; - else - return chout_ar[4 * templateSetup + channel] - 1; + else { + return useChannels(Boards::isAir())[controlsCount(Boards::isAir()) * templateSetup + channel] - 1; + } } RawSource GeneralSettings::getDefaultSource(unsigned int channel) const { int stick = getDefaultStick(channel); + if (stick >= 0) return RawSource(SOURCE_TYPE_INPUT, stick + 1); else @@ -366,7 +396,7 @@ RawSource GeneralSettings::getDefaultSource(unsigned int channel) const int GeneralSettings::getDefaultChannel(unsigned int stick) const { - for (int i = 0; i < 4; i++){ + for (int i = 0; i < controlsCount(Boards::isAir()); i++) { if (getDefaultStick(i) == (int)stick) return i; } @@ -959,3 +989,83 @@ AbstractStaticItemModel * TrainerMix::srcItemModel() mdl->loadItemList(); return mdl; } + +QString GeneralSettings::stickModeToString() const +{ + return stickModeToString(stickMode); +} + +// static +QString GeneralSettings::stickModeToString(int value) +{ + switch(value) { + case STICK_MODE_1: + return tr("Mode 1 (RUD ELE THR AIL)"); + case STICK_MODE_2: + return tr("Mode 2 (RUD THR ELE AIL)"); + case STICK_MODE_3: + return tr("Mode 3 (AIL ELE THR RUD)"); + case STICK_MODE_4: + return tr("Mode 4 (AIL THR ELE RUD)"); + default: + return CPN_STR_UNKNOWN_ITEM; + } +} + +// static +AbstractStaticItemModel * GeneralSettings::stickModeItemModel() +{ + AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); + mdl->setName(AIM_GS_STICKMODE); + + for (int i = 0; i < STICK_MODE_COUNT; i++) { + mdl->appendToItemList(stickModeToString(i), i); + } + + mdl->loadItemList(); + return mdl; +} + +QString GeneralSettings::templateSetupToString() const +{ + return templateSetupToString(templateSetup, Boards::isAir()); +} + +// static +QString GeneralSettings::templateSetupToString(int value, bool isBoardAir) +{ + QString ret; + const QList channels = useChannels(isBoardAir); + const QList controls = useControls(isBoardAir); + + if (value < (channels.size() / controls.size())) { + for (int i = 0; i < controls.size(); i++) { + if (i > 0) + ret.append(" "); + + int idx = channels[controls.size() * value + i] - 1; + if (idx >= 0 && idx < controls.size()) + ret.append(controls[channels[controls.size() * value + i] - 1]); + } + } + + return ret; +} + +// static +AbstractStaticItemModel * GeneralSettings::templateSetupItemModel() +{ + AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); + mdl->setName(AIM_GS_TEMPLATESETUP); + + for (int i = 0; i < (channelsCount(true) / controlsCount(true)); i++) { + mdl->appendToItemList(templateSetupToString(i, true), i, true, 0, RadioTypeContextAir); + } + + for (int i = 0; i < (channelsCount(false) / controlsCount(false)); i++) { + mdl->appendToItemList(templateSetupToString(i, false), i, true, 0, RadioTypeContextSurface); + } + + mdl->loadItemList(); + return mdl; +} diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index fb0d19f27b2..747fc7c4261 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -44,6 +44,9 @@ constexpr char AIM_GS_INTMODULEBAUDRATE[] {"gs.intmodulebaudrate"}; constexpr char AIM_GS_STICKDEADZONE[] {"gs.stickdeadzone"}; constexpr char AIM_GS_UARTSAMPLEMODE[] {"gs.uartsamplemode"}; constexpr char AIM_GS_HATSMODE[] {"gs.hatsmode"}; +constexpr char AIM_GS_STICKMODE[] {"gs.stickmode"}; +constexpr char AIM_GS_TEMPLATESETUP[] {"gs.templatesetup"}; + constexpr char AIM_TRAINERMIX_MODE[] {"trainermix.mode"}; constexpr char AIM_TRAINERMIX_SRC[] {"trainermix.src"}; @@ -188,6 +191,19 @@ class GeneralSettings { PPM_US }; + enum StickMode { + STICK_MODE_1, + STICK_MODE_2, + STICK_MODE_3, + STICK_MODE_4, + STICK_MODE_COUNT, + }; + + enum RadioTypeContext { + RadioTypeContextAir = 1 << 1, + RadioTypeContextSurface = 1 << 2, + }; + GeneralSettings() { clear(); } void clear(); void init(); @@ -394,6 +410,8 @@ class GeneralSettings { QString internalModuleBaudrateToString() const; QString uartSampleModeToString() const; QString hatsModeToString() const; + QString stickModeToString() const; + QString templateSetupToString() const; static QString antennaModeToString(int value); static QString bluetoothModeToString(int value); @@ -403,6 +421,8 @@ class GeneralSettings { static FieldRange getTxCurrentCalibration(); static QString uartSampleModeToString(int value); static QString hatsModeToString(int value); + static QString stickModeToString(int value); + static QString templateSetupToString(int value, bool isBoardAir); static AbstractStaticItemModel * antennaModeItemModel(bool model_setup = false); static AbstractStaticItemModel * bluetoothModeItemModel(); @@ -411,6 +431,8 @@ class GeneralSettings { static AbstractStaticItemModel * stickDeadZoneItemModel(); static AbstractStaticItemModel * uartSampleModeItemModel(); static AbstractStaticItemModel * hatsModeItemModel(bool radio_setup = true); + static AbstractStaticItemModel * stickModeItemModel(); + static AbstractStaticItemModel * templateSetupItemModel(); void validateFlexSwitches(); }; diff --git a/companion/src/firmwares/modeldata.cpp b/companion/src/firmwares/modeldata.cpp index 053051c39b6..85dae1b7b03 100644 --- a/companion/src/firmwares/modeldata.cpp +++ b/companion/src/firmwares/modeldata.cpp @@ -193,7 +193,7 @@ bool ModelData::isEmpty() const void ModelData::setDefaultInputs(const GeneralSettings & settings) { - for (int i = 0; i < CPN_MAX_STICKS; i++) { + for (int i = 0; i < Boards::getCapability(getCurrentBoard(), Board::Sticks); i++) { ExpoData * expo = &expoData[i]; expo->chn = i; expo->mode = INPUT_MODE_BOTH; @@ -207,7 +207,7 @@ void ModelData::setDefaultMixes(const GeneralSettings & settings) { setDefaultInputs(settings); - for (int i = 0; i < CPN_MAX_STICKS; i++) { + for (int i = 0; i < Boards::getCapability(getCurrentBoard(), Board::Sticks); i++) { MixData * mix = &mixData[i]; mix->destCh = i + 1; mix->weight = 100; @@ -1492,20 +1492,21 @@ void ModelData::updateResetParam(CustomFunctionData * cfd) QString ModelData::thrTraceSrcToString() const { - return thrTraceSrcToString((int)thrTraceSrc); + return thrTraceSrcToString(nullptr, (int)thrTraceSrc); } -QString ModelData::thrTraceSrcToString(const int index) const +QString ModelData::thrTraceSrcToString(const GeneralSettings * generalSettings, const int index) const { const Board::Type board = getCurrentBoard(); const int pscnt = Boards::getCapability(board, Board::Pots) + Boards::getCapability(board, Board::Sliders); if (index == 0) - return tr("THR"); + return Boards::getCapability(board, Board::Air) ? tr("THR") : tr("TH"); else if (index <= pscnt) - return Boards::getInputName(index + Boards::getCapability(board, Board::Sticks) - 1, board); + //return Boards::getInputName(index + Boards::getCapability(board, Board::Sticks) - 1, board); + return RawSource(SOURCE_TYPE_INPUT, index + Boards::getCapability(board, Board::Sticks)).toString(this, generalSettings, board); else if (index <= pscnt + getCurrentFirmware()->getCapability(Outputs)) - return RawSource(SOURCE_TYPE_CH, index - pscnt - 1).toString(this); + return RawSource(SOURCE_TYPE_CH, index - pscnt).toString(this); return QString(CPN_STR_UNKNOWN_ITEM); } @@ -1522,10 +1523,12 @@ bool ModelData::isThrTraceSrcAvailable(const GeneralSettings * generalSettings, { const Board::Type board = getCurrentBoard(); - if (index > 0 && index <= Boards::getCapability(board, Board::Pots) + Boards::getCapability(board, Board::Sliders)) - return RawSource(SOURCE_TYPE_INPUT, index + Boards::getCapability(board, Board::Sticks) - 1).isAvailable(this, generalSettings, board); - else + if (index == 0) return true; + else if (index > 0 && index <= Boards::getCapability(board, Board::Pots) + Boards::getCapability(board, Board::Sliders)) + return RawSource(SOURCE_TYPE_INPUT, index + Boards::getCapability(board, Board::Sticks)).isAvailable(this, generalSettings, board); + else + return hasMixes(index - Boards::getCapability(board, Board::Pots) - Boards::getCapability(board, Board::Sliders) - 1); } void ModelData::limitsClear(const int index) diff --git a/companion/src/firmwares/modeldata.h b/companion/src/firmwares/modeldata.h index 8b35664fd01..4fe0b970684 100644 --- a/companion/src/firmwares/modeldata.h +++ b/companion/src/firmwares/modeldata.h @@ -314,7 +314,7 @@ class ModelData { bool hasExpoSiblings(const int index); void removeMix(const int idx); QString thrTraceSrcToString() const; - QString thrTraceSrcToString(const int index) const; + QString thrTraceSrcToString(const GeneralSettings * generalSettings, const int index) const; int thrTraceSrcCount() const; bool isThrTraceSrcAvailable(const GeneralSettings * generalSettings, const int index) const; @@ -336,7 +336,7 @@ class ModelData { static AbstractStaticItemModel * funcSwitchConfigItemModel(); static AbstractStaticItemModel * funcSwitchGroupStartSwitchModel(int switchcnt); static AbstractStaticItemModel * funcSwitchGroupsModel(); - + unsigned int getFuncSwitchGroup(unsigned int index) const; void setFuncSwitchGroup(unsigned int index, unsigned int value); diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 1627c24914c..c36d432be95 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -545,7 +545,9 @@ int OpenTxFirmware::getCapability(::Capability capability) case FlightModesHaveFades: return 1; case Heli: - if (IS_HORUS_OR_TARANIS(board)) + if (Boards::getCapability(board, Board::Surface)) + return false; + else if (IS_HORUS_OR_TARANIS(board)) return id.contains("noheli") ? 0 : 1; else return id.contains("heli") ? 1 : 0; @@ -674,9 +676,9 @@ int OpenTxFirmware::getCapability(::Capability capability) case OptrexDisplay: return (board == BOARD_SKY9X ? true : false); case HasVario: - return 1; + return Boards::isAir(board); case HasVarioSink: - return true; + return Boards::isAir(board); case HasFailsafe: return 32; case NumModules: @@ -705,37 +707,6 @@ int OpenTxFirmware::getCapability(::Capability capability) return 18; case HasSDLogs: return true; - 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)) - return 128; - else if (IS_TARANIS(board)) - return 212; - else - return 128; - case LcdHeight: - if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board)) - return 480; - else if (IS_FLYSKY_PL18(board) || IS_JUMPER_T15(board)) - return 320; - else if (IS_FAMILY_HORUS_OR_T16(board)) - return 272; - else - return 64; - case LcdDepth: - if (IS_FAMILY_HORUS_OR_T16(board)) - return 16; - else if (IS_TARANIS_SMALL(board)) - return 1; - else if (IS_TARANIS(board)) - return 4; - else - return 1; case GetThrSwitch: return (IS_HORUS_OR_TARANIS(board) ? SWITCH_SF1 : SWITCH_THR); case HasDisplayText: @@ -817,12 +788,14 @@ int OpenTxFirmware::getCapability(::Capability capability) case HasAuxSerialMode: return (IS_FAMILY_HORUS_OR_T16(board) && !(IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))) || (IS_TARANIS_X9(board) && !IS_TARANIS_X9DP_2019(board)) || - IS_RADIOMASTER_ZORRO(board) || IS_RADIOMASTER_TX12_MK2(board); + IS_RADIOMASTER_ZORRO(board) || IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_MT12(board); case HasAux2SerialMode: return IS_FAMILY_T16(board); case HasVCPSerialMode: return IS_FAMILY_HORUS_OR_T16(board) || IS_RADIOMASTER_ZORRO(board) || - IS_JUMPER_TPRO(board) || IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_POCKET(board); + IS_JUMPER_TPRO(board) || IS_RADIOMASTER_TX12_MK2(board) || + IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_POCKET(board) || + IS_RADIOMASTER_MT12(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) || IS_FLYSKY_PL18(board)) ? true : false; @@ -831,7 +804,7 @@ int OpenTxFirmware::getCapability(::Capability capability) case HasTelemetryBaudrate: return IS_HORUS_OR_TARANIS(board); case TopBarZones: - return getCapability(LcdWidth) > getCapability(LcdHeight) ? 4 : 2; + return Boards::getCapability(board, Board::LcdWidth) > Boards::getCapability(board, Board::LcdHeight) ? 4 : 2; case HasModelsList: return IS_FAMILY_HORUS_OR_T16(board); case HasFlySkyGimbals: @@ -843,7 +816,7 @@ int OpenTxFirmware::getCapability(::Capability capability) IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_ZORRO(board) || IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_TX16S(board) || IS_JUMPER_T18(board) || IS_JUMPER_T20(board) || - IS_RADIOMASTER_POCKET(board)); + IS_RADIOMASTER_POCKET(board) || IS_RADIOMASTER_MT12(board)); case HasSoftwareSerialPower: return IS_RADIOMASTER_TX16S(board); case HasIntModuleMulti: @@ -851,13 +824,15 @@ int OpenTxFirmware::getCapability(::Capability capability) IS_RADIOMASTER_TX12(board) || IS_JUMPER_TLITE(board) || IS_BETAFPV_LR3PRO(board) || (IS_RADIOMASTER_ZORRO(board) && !id.contains("internalelrs")) || (IS_RADIOMASTER_BOXER(board) && !id.contains("internalelrs")) || - (IS_RADIOMASTER_POCKET(board) && !id.contains("internalelrs")); + (IS_RADIOMASTER_POCKET(board) && !id.contains("internalelrs")) || + (IS_RADIOMASTER_MT12(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_RADIOMASTER_POCKET(board) || IS_JUMPER_T20(board); + IS_RADIOMASTER_POCKET(board) || IS_JUMPER_T20(board) || + IS_RADIOMASTER_MT12(board); case HasIntModuleFlySky: return id.contains("afhds2a") || id.contains("afhds3") || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board); @@ -1529,6 +1504,15 @@ void registerOpenTxFirmwares() registerOpenTxFirmware(firmware); addOpenTxRfOptions(firmware, FLEX + AFHDS2A + AFHDS3); + /* Radiomaster MT12 board */ + firmware = new OpenTxFirmware(FIRMWAREID("mt12"), QCoreApplication::translate("Firmware", "Radiomaster MT12"), Board::BOARD_RADIOMASTER_MT12); + addOpenTxCommonOptions(firmware); + firmware->addOption("nogvars", Firmware::tr("Disable Global variables")); + firmware->addOption("lua", Firmware::tr("Enable Lua custom scripts screen")); + addOpenTxFontOptions(firmware); + registerOpenTxFirmware(firmware); + addOpenTxRfOptions(firmware, NONE); + /* Radiomaster T8 board */ firmware = new OpenTxFirmware(FIRMWAREID("t8"), QCoreApplication::translate("Firmware", "Radiomaster T8"), BOARD_RADIOMASTER_T8); addOpenTxCommonOptions(firmware); diff --git a/companion/src/firmwares/rawsource.cpp b/companion/src/firmwares/rawsource.cpp index ce7940aabb9..14979d446c3 100644 --- a/companion/src/firmwares/rawsource.cpp +++ b/companion/src/firmwares/rawsource.cpp @@ -137,8 +137,12 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con if (board == Board::BOARD_UNKNOWN) board = getCurrentBoard(); - static const QString trims[] = { - "", tr("TrmR"), tr("TrmE"), tr("TrmT"), tr("TrmA"), tr("Trm5"), tr("Trm6"), tr("Trm7"), tr("Trm8") + static const QString trimsAir[] = { + "", tr("Trim Rud"), tr("Trim Ele"), tr("Trim Thr"), tr("Trim Ail"), tr("Trim 5"), tr("Trim 6"), tr("Trim 7"), tr("Trim 8") + }; + + static const QString trimsSurface[] = { + "", tr("Trim ST"), tr("Trim TH"), tr("Trim 3"), tr("Trim 4"), tr("Trim 5"), tr("Trim 6"), tr("Trim 7"), tr("Trim 8") }; static const QString trims2[] = { @@ -180,7 +184,9 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con return DataHelpers::getCompositeName(dfltName, custName, prefixCustomName); case SOURCE_TYPE_TRIM: - return (Boards::getCapability(board, Board::NumTrims) == 2 ? CHECK_IN_ARRAY(trims2, index) : CHECK_IN_ARRAY(trims, index)); + return (Boards::getCapability(board, Board::NumTrims) == 2 ? CHECK_IN_ARRAY(trims2, index) : + (Boards::isAir(board) ? CHECK_IN_ARRAY(trimsAir, index) : + CHECK_IN_ARRAY(trimsSurface, index))); case SOURCE_TYPE_ROTARY_ENCODER: return CHECK_IN_ARRAY(rotary, index); @@ -286,6 +292,7 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings board = getCurrentBoard(); Boards b(board); + Firmware *firmware = getCurrentFirmware(); if (type == SOURCE_TYPE_CH && abs(index) > CPN_MAX_CHNOUT) return false; @@ -296,9 +303,6 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings if (type == SOURCE_TYPE_CUSTOM_SWITCH && abs(index) > CPN_MAX_LOGICAL_SWITCHES) return false; - if (type == SOURCE_TYPE_FUNCTIONSWITCH_GROUP && b.getCapability(Board::FunctionSwitches) && model->getFuncGroupSwitchCount(abs(index), CPN_MAX_SWITCHES_FUNCTION) == 0) - return false; - if (type == SOURCE_TYPE_LUA_OUTPUT && div(abs(index - 1), 16).quot >= CPN_MAX_SCRIPTS) return false; @@ -317,6 +321,9 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings if (type == SOURCE_TYPE_TELEMETRY && div(abs(index), 3).quot > CPN_MAX_SENSORS) return false; + if (type == SOURCE_TYPE_CYC && !firmware->getCapability(Heli)) + return false; + if (model) { if (type == SOURCE_TYPE_TIMER && model->timers[abs(index) - 1].isModeOff()) return false; @@ -342,6 +349,17 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings if (type == SOURCE_TYPE_CH && !model->hasMixes(abs(index) - 1)) return false; + + if (type == SOURCE_TYPE_FUNCTIONSWITCH_GROUP) { + if (!b.getCapability(Board::FunctionSwitches)) + return false; + else if (model->getFuncGroupSwitchCount(abs(index), CPN_MAX_SWITCHES_FUNCTION) == 0) + return false; + } + } + else { + if (type == SOURCE_TYPE_FUNCTIONSWITCH_GROUP && b.getCapability(Board::FunctionSwitches)) + return false; } if (gs) { diff --git a/companion/src/firmwares/rawswitch.cpp b/companion/src/firmwares/rawswitch.cpp index 8fe7b2aacd2..70da6be2fd5 100644 --- a/companion/src/firmwares/rawswitch.cpp +++ b/companion/src/firmwares/rawswitch.cpp @@ -37,15 +37,26 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen QString("AIL"), QString("GEA"), QString("TRN") }; - static const QString trimsSwitches[] = { - tr("Rud-"), tr("Rud+"), - tr("Ele-"), tr("Ele+"), - tr("Thr-"), tr("Thr+"), - tr("Ail-"), tr("Ail+"), - tr("T5-"), tr("T5+"), - tr("T6-"), tr("T6+"), - tr("T7-"), tr("T7+"), - tr("T8-"), tr("T8+") + static const QString trimsSwitchesAir[] = { + tr("Trim Rud-"), tr("Trim Rud+"), + tr("Trim Ele-"), tr("Trim Ele+"), + tr("Trim Thr-"), tr("Trim Thr+"), + tr("Trim Ail-"), tr("Trim Ail+"), + tr("Trim T5-"), tr("Trim T5+"), + tr("Trim T6-"), tr("Trim T6+"), + tr("Trim T7-"), tr("Trim T7+"), + tr("Trim T8-"), tr("Trim T8+") + }; + + static const QString trimsSwitchesSurface[] = { + tr("Trim ST-"), tr("Trim ST+"), + tr("Trim TH-"), tr("Trim TH+"), + tr("Trim T3-"), tr("Trim T3+"), + tr("Trim T4-"), tr("Trim T4+"), + tr("Trim T5-"), tr("Trim T5+"), + tr("Trim T6-"), tr("Trim T6+"), + tr("Trim T7-"), tr("Trim T7+"), + tr("Trim T8-"), tr("Trim T8+") }; static const QString trimsSwitches2[] = { @@ -115,7 +126,9 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen case SWITCH_TYPE_TRIM: return (Boards::getCapability(board, Board::NumTrims) == 2 ? - CHECK_IN_ARRAY(trimsSwitches2, index - 1) : CHECK_IN_ARRAY(trimsSwitches, index - 1)); + CHECK_IN_ARRAY(trimsSwitches2, index - 1) : + (Boards::isAir(board) ? CHECK_IN_ARRAY(trimsSwitchesAir, index - 1) : + CHECK_IN_ARRAY(trimsSwitchesSurface, index - 1))); case SWITCH_TYPE_ROTARY_ENCODER: return CHECK_IN_ARRAY(rotaryEncoders, index - 1); diff --git a/companion/src/generaledit/generaloptions.cpp b/companion/src/generaledit/generaloptions.cpp index e71e6269491..57347a8a407 100644 --- a/companion/src/generaledit/generaloptions.cpp +++ b/companion/src/generaledit/generaloptions.cpp @@ -68,7 +68,7 @@ GeneralOptionsPanel::GeneralOptionsPanel(QWidget * parent, GeneralSettings & gen addParams(); } - addLabel(tr("Flight Modes")); + addLabel(tr("%1 Modes").arg(Boards::getRadioTypeString(board))); AutoCheckBox *fmDisable = new AutoCheckBox(this); fmDisable->setField(generalSettings.modelFMDisabled, this, true); params->append(fmDisable); diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index 34f87d21eda..7419ba7ffe4 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -26,6 +26,10 @@ #include "autocombobox.h" #include "namevalidator.h" +constexpr char FIM_HATSMODE[] {"Hats Mode"}; +constexpr char FIM_STICKMODE[] {"Stick Mode"}; +constexpr char FIM_TEMPLATESETUP[] {"Template Setup"}; + GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware): GeneralPanel(parent, generalSettings, firmware), ui(new Ui::GeneralSetup) @@ -34,6 +38,15 @@ ui(new Ui::GeneralSetup) Board::Type board = firmware->getBoard(); + panelFilteredModels = new FilteredItemModelFactory(); + + panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::hatsModeItemModel()), FIM_HATSMODE); + panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::stickModeItemModel()), FIM_STICKMODE); + panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::templateSetupItemModel(), + Boards::isAir(board) ? GeneralSettings::RadioTypeContextAir : + GeneralSettings::RadioTypeContextSurface), + FIM_TEMPLATESETUP); + QLabel *pmsl[] = {ui->ro_label, ui->ro1_label, ui->ro2_label, ui->ro3_label, ui->ro4_label, ui->ro5_label, ui->ro6_label, ui->ro7_label, ui->ro8_label, NULL}; QSlider *tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL}; @@ -178,7 +191,7 @@ ui(new Ui::GeneralSetup) } if (IS_FLYSKY_EL18(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_PL18(board)) { - ui->hatsModeCB->setModel(new FilteredItemModel(GeneralSettings::hatsModeItemModel())); + ui->hatsModeCB->setModel(panelFilteredModels->getItemModel(FIM_HATSMODE)); ui->hatsModeCB->setField(generalSettings.hatsMode, this); } else { @@ -204,12 +217,12 @@ ui(new Ui::GeneralSetup) } if (!firmware->getCapability(HasVolume)) { - ui->volume_SB->hide(); - ui->volume_SB->setDisabled(true); + ui->volume_SL->hide(); + ui->volume_SL->setDisabled(true); ui->label_volume->hide(); } else { - ui->volume_SB->setMaximum(firmware->getCapability(MaxVolume)); + ui->volume_SL->setMaximum(firmware->getCapability(MaxVolume)); } if (!firmware->getCapability(HasBrightness)) { @@ -264,8 +277,8 @@ ui(new Ui::GeneralSetup) ui->contrastSB->setMaximum(firmware->getCapability(MaxContrast)); ui->contrastSB->setValue(generalSettings.contrast); - ui->battwarningDSB->setValue((double)generalSettings.vBatWarn/10); - ui->backlightautoSB->setValue(generalSettings.backlightDelay*5); + ui->battwarningDSB->setValue((double)generalSettings.vBatWarn / 10); + ui->backlightautoSB->setValue(generalSettings.backlightDelay * 5); ui->inactimerSB->setValue(generalSettings.inactivityTimer); ui->memwarnChkB->setChecked(!generalSettings.disableMemoryWarning); // Default is zero=checked @@ -274,7 +287,7 @@ ui(new Ui::GeneralSetup) ui->rssiPowerOffWarnChkB->setChecked(!generalSettings.disableRssiPoweroffAlarm); // Default is zero=checked ui->trainerPowerOffWarnChkB->setChecked(!generalSettings.disableTrainerPoweroffAlarm); // Default is zero=checked - ui->splashScreenDuration->setCurrentIndex(3-generalSettings.splashMode); + ui->splashScreenDuration->setCurrentIndex(3 - generalSettings.splashMode); if (IS_FAMILY_HORUS_OR_T16(firmware->getBoard())) { ui->splashScreenDuration->setItemText(0, QCoreApplication::translate("GeneralSetup", "1s", nullptr)); } @@ -297,11 +310,14 @@ ui(new Ui::GeneralSetup) ui->registrationId->setValidator(new NameValidator(board, this)); ui->registrationId->setMaxLength(REGISTRATION_ID_LEN); + ui->stickmodeCB->setModel(panelFilteredModels->getItemModel(FIM_STICKMODE)); + ui->channelorderCB->setModel(panelFilteredModels->getItemModel(FIM_TEMPLATESETUP)); + setValues(); lock = false; - for (int i=0; tpmsld[i]; i++) { + for (int i = 0; tpmsld[i]; i++) { connect(tpmsld[i], SIGNAL(valueChanged(int)),this,SLOT(unlockSwitchEdited())); } @@ -333,7 +349,7 @@ ui(new Ui::GeneralSetup) ui->backlightColor2_label->hide(); } - ui->switchesDelay->setValue(10*(generalSettings.switchesDelay+15)); + ui->switchesDelay->setValue(10 * (generalSettings.switchesDelay + 15)); ui->blAlarm_ChkB->setChecked(generalSettings.alarmsFlash); if (!firmware->getCapability(HasBatMeterRange)) { @@ -344,12 +360,30 @@ ui(new Ui::GeneralSetup) ui->vBatMaxDSB->hide(); } + if (Boards::getCapability(board, Board::Surface)) { + ui->stickModeLabel->hide(); + ui->stickmodeCB->hide(); + } + + if (!firmware->getCapability(HasVario)) { + ui->varioVolume_label->hide(); + ui->varioVolume_SL->hide(); + ui->varioP0_label->hide(); + ui->varioP0_SB->hide(); + ui->varioPMax_label->hide(); + ui->varioPMax_SB->hide(); + ui->varioR0_label->hide(); + ui->varioR0_SB->hide(); + } + disableMouseScrolling(); } GeneralSetupPanel::~GeneralSetupPanel() { delete ui; + delete panelFilteredModels; + } void GeneralSetupPanel::on_timezoneLE_textEdited(const QString &text) @@ -365,14 +399,15 @@ void GeneralSetupPanel::on_timezoneLE_textEdited(const QString &text) void GeneralSetupPanel::populateBacklightCB() { QComboBox * b = ui->backlightswCB; - QString strings[] = { tr("OFF"), tr("Keys"), tr("Sticks"), tr("Keys + Sticks"), tr("ON"), NULL }; + const QStringList strings = { tr("OFF"), tr("Keys"), tr("Controls"), tr("Keys + Controls"), tr("ON") }; b->clear(); - int startValue = (firmware->getCapability(LcdDepth)>=8)?1:0; - for (int i=startValue; !strings[i].isNull(); i++) { + int startValue = (Boards::getCapability(firmware->getBoard(), Board::LcdDepth) >= 8) ? 1 : 0; + + for (int i = startValue; i < strings.size(); i++) { b->addItem(strings[i], 0); if (generalSettings.backlightMode == i) { - b->setCurrentIndex(b->count()-1); + b->setCurrentIndex(b->count() - 1); } } } @@ -403,10 +438,10 @@ void GeneralSetupPanel::populateVoiceLangCB() { NULL, NULL }}; b->clear(); - for (int i=0; strings[i][0]!=NULL; i++) { + for (int i = 0; strings[i][0] != NULL; i++) { b->addItem(strings[i][0],strings[i][1]); if (generalSettings.ttsLanguage == strings[i][1]) { - b->setCurrentIndex(b->count()-1); + b->setCurrentIndex(b->count() - 1); } } } @@ -455,7 +490,7 @@ void GeneralSetupPanel::on_voiceLang_CB_currentIndexChanged(int index) { if (!lock) { QString code = ui->voiceLang_CB->itemData(index).toString(); - for (int i=0; i<2; i++) { + for (int i = 0; i < 2; i++) { generalSettings.ttsLanguage[i] = code.at(i).toLatin1(); } generalSettings.ttsLanguage[2] = '\0'; @@ -465,8 +500,8 @@ void GeneralSetupPanel::on_voiceLang_CB_currentIndexChanged(int index) void GeneralSetupPanel::updateVarioPitchRange() { - ui->varioPMax_SB->setMaximum(700+(generalSettings.varioPitch*10)+1000+800); - ui->varioPMax_SB->setMinimum(700+(generalSettings.varioPitch*10)+1000-800); + ui->varioPMax_SB->setMaximum(700 + (generalSettings.varioPitch * 10) + 1000 + 800); + ui->varioPMax_SB->setMinimum(700 + (generalSettings.varioPitch * 10) + 1000 - 800); } void GeneralSetupPanel::populateRotEncCB(int reCount) @@ -475,7 +510,7 @@ void GeneralSetupPanel::populateRotEncCB(int reCount) QComboBox * b = ui->re_CB; b->clear(); - for (int i=0; i<=reCount; i++) { + for (int i = 0; i <= reCount; i++) { b->addItem(strings[i]); } b->setCurrentIndex(generalSettings.reNavigation); @@ -495,29 +530,30 @@ int pwrDelayToYaml(int delay) void GeneralSetupPanel::setValues() { + Board::Type board = firmware->getBoard(); ui->beeperCB->setCurrentIndex(generalSettings.beeperMode+2); - ui->channelorderCB->setCurrentIndex(generalSettings.templateSetup); - ui->stickmodeCB->setCurrentIndex(generalSettings.stickMode); + ui->channelorderCB->setCurrentIndex(ui->channelorderCB->findData(generalSettings.templateSetup)); + ui->stickmodeCB->setCurrentIndex(ui->stickmodeCB->findData(generalSettings.stickMode)); if (firmware->getCapability(Haptic)) { - ui->hapticLengthCB->setCurrentIndex(generalSettings.hapticLength+2); + ui->hapticLengthCB->setCurrentIndex(generalSettings.hapticLength + 2); } else { ui->label_HL->hide(); ui->hapticLengthCB->hide(); } ui->OFFBright_SB->setMinimum(firmware->getCapability(BacklightLevelMin)); - if (generalSettings.backlightOffBright > 100-generalSettings.backlightBright) - generalSettings.backlightOffBright = 100-generalSettings.backlightBright; - ui->BLBright_SB->setValue(100-generalSettings.backlightBright); + if (generalSettings.backlightOffBright > 100 - generalSettings.backlightBright) + generalSettings.backlightOffBright = 100 - generalSettings.backlightBright; + ui->BLBright_SB->setValue(100 - generalSettings.backlightBright); ui->OFFBright_SB->setValue(generalSettings.backlightOffBright); ui->BLBright_SB->setMinimum(ui->OFFBright_SB->value()); ui->OFFBright_SB->setMaximum(ui->BLBright_SB->value()); ui->soundModeCB->setCurrentIndex(generalSettings.speakerMode); - ui->volume_SB->setValue(generalSettings.speakerVolume + 12); - ui->beeperlenCB->setCurrentIndex(generalSettings.beeperLength+2); + ui->volume_SL->setValue(generalSettings.speakerVolume + 12); + ui->beeperlenCB->setCurrentIndex(generalSettings.beeperLength + 2); ui->speakerPitchSB->setValue(generalSettings.speakerPitch); ui->hapticStrength->setValue(generalSettings.hapticStrength); - ui->hapticmodeCB->setCurrentIndex(generalSettings.hapticMode+2); + ui->hapticmodeCB->setCurrentIndex(generalSettings.hapticMode + 2); if (firmware->getCapability(HasBatMeterRange)) { ui->vBatMinDSB->setValue((double)(generalSettings.vBatMin + 90) / 10); @@ -532,7 +568,7 @@ void GeneralSetupPanel::setValues() ui->startSoundCB->setChecked(!generalSettings.dontPlayHello); - if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) { + if (Boards::getCapability(board, Board::HasColorLcd)) { ui->modelQuickSelect_CB->setChecked(generalSettings.modelQuickSelect); ui->modelSelectLayout_CB->setCurrentIndex(generalSettings.modelSelectLayout); ui->labelSingleSelect_CB->setCurrentIndex(generalSettings.labelSingleSelect); @@ -551,13 +587,6 @@ void GeneralSetupPanel::setValues() ui->label_favMultiMode->hide(); ui->favMultiMode_CB->hide(); } - - if (firmware->getCapability(LcdWidth) == 128) { - ui->invertLCD_CB->setChecked(generalSettings.invertLCD); - } else { - ui->invertLCD_label->hide(); - ui->invertLCD_CB->hide(); - } } void GeneralSetupPanel::showLabelSelectOptions() @@ -582,21 +611,23 @@ void GeneralSetupPanel::showLabelSelectOptions() void GeneralSetupPanel::on_faimode_CB_stateChanged(int) { - if (ui->faimode_CB->isChecked()) { - int ret = QMessageBox::question(this, CPN_STR_APP_NAME, - tr("If you enable FAI, only RSSI and RxBt sensors will keep working.\nThis function cannot be disabled by the radio.\nAre you sure ?") , - QMessageBox::Yes | QMessageBox::No); - if (ret==QMessageBox::Yes) { - generalSettings.fai = true; + if (!lock) { + if (ui->faimode_CB->isChecked()) { + int ret = QMessageBox::question(this, CPN_STR_APP_NAME, + tr("If you enable FAI, only RSSI and RxBt sensors will keep working.\nThis function cannot be disabled by the radio.\nAre you sure ?") , + QMessageBox::Yes | QMessageBox::No); + if (ret == QMessageBox::Yes) { + generalSettings.fai = true; + } + else { + ui->faimode_CB->setChecked(false); + } } else { - ui->faimode_CB->setChecked(false); + generalSettings.fai = false; } + emit modified(); } - else { - generalSettings.fai = false; - } - emit modified(); } void GeneralSetupPanel::populateRotEncModeCB() @@ -610,7 +641,7 @@ void GeneralSetupPanel::populateRotEncModeCB() } b->clear(); - for (uint8_t i=0; i < itemCount; i++) { + for (int i = 0; i < itemCount; i++) { b->addItem(strings[i], 0); } b->setCurrentIndex(generalSettings.rotEncMode); @@ -626,212 +657,276 @@ void GeneralSetupPanel::on_rotEncMode_CB_currentIndexChanged(int index) void GeneralSetupPanel::on_speakerPitchSB_editingFinished() { - generalSettings.speakerPitch = ui->speakerPitchSB->value(); - emit modified(); + if (!lock) { + generalSettings.speakerPitch = ui->speakerPitchSB->value(); + emit modified(); + } } void GeneralSetupPanel::on_hapticStrength_valueChanged() { - generalSettings.hapticStrength = ui->hapticStrength->value(); - emit modified(); + if (!lock) { + generalSettings.hapticStrength = ui->hapticStrength->value(); + emit modified(); + } } void GeneralSetupPanel::on_soundModeCB_currentIndexChanged(int index) { - generalSettings.speakerMode = index; - emit modified(); + if (!lock) { + generalSettings.speakerMode = index; + emit modified(); + } } void GeneralSetupPanel::on_splashScreenDuration_currentIndexChanged(int index) { - generalSettings.splashMode = 3-index; - emit modified(); + if (!lock) { + generalSettings.splashMode = 3 - index; + emit modified(); + } } void GeneralSetupPanel::on_pwrOnDelay_currentIndexChanged(int index) { - generalSettings.pwrOnSpeed = pwrDelayToYaml(index); - emit modified(); + if (!lock) { + generalSettings.pwrOnSpeed = pwrDelayToYaml(index); + emit modified(); + } } void GeneralSetupPanel::on_pwrOffDelay_currentIndexChanged(int index) { - generalSettings.pwrOffSpeed = pwrDelayToYaml(index); - emit modified(); + if (!lock) { + generalSettings.pwrOffSpeed = pwrDelayToYaml(index); + emit modified(); + } } void GeneralSetupPanel::on_pwrOnOffHaptic_CB_stateChanged(int) { - generalSettings.disablePwrOnOffHaptic = ui->pwrOnOffHaptic_CB->isChecked() ? 0 : 1; - emit modified(); + if (!lock) { + generalSettings.disablePwrOnOffHaptic = ui->pwrOnOffHaptic_CB->isChecked() ? 0 : 1; + emit modified(); + } } void GeneralSetupPanel::on_beepVolume_SL_valueChanged() { - generalSettings.beepVolume=ui->beepVolume_SL->value(); - emit modified(); + if (!lock) { + generalSettings.beepVolume = ui->beepVolume_SL->value(); + emit modified(); + } } void GeneralSetupPanel::on_wavVolume_SL_valueChanged() { - generalSettings.wavVolume=ui->wavVolume_SL->value(); - emit modified(); + if (!lock) { + generalSettings.wavVolume = ui->wavVolume_SL->value(); + emit modified(); + } } void GeneralSetupPanel::on_varioVolume_SL_valueChanged() { - generalSettings.varioVolume=ui->varioVolume_SL->value(); - emit modified(); + if (!lock) { + generalSettings.varioVolume = ui->varioVolume_SL->value(); + emit modified(); + } } void GeneralSetupPanel::on_bgVolume_SL_valueChanged() { - generalSettings.backgroundVolume=ui->bgVolume_SL->value(); - emit modified(); + if (!lock) { + generalSettings.backgroundVolume = ui->bgVolume_SL->value(); + emit modified(); + } } void GeneralSetupPanel::on_varioP0_SB_editingFinished() { - generalSettings.varioPitch = (ui->varioP0_SB->value()-700)/10; - updateVarioPitchRange(); - emit modified(); + if (!lock) { + generalSettings.varioPitch = (ui->varioP0_SB->value() - 700) / 10; + updateVarioPitchRange(); + emit modified(); + } } void GeneralSetupPanel::on_varioPMax_SB_editingFinished() { - generalSettings.varioRange = (ui->varioPMax_SB->value()-(700+(generalSettings.varioPitch*10))-1000)/10; - emit modified(); + if (!lock) { + generalSettings.varioRange = (ui->varioPMax_SB->value() - (700 + (generalSettings.varioPitch * 10)) - 1000) / 10; + emit modified(); + } } void GeneralSetupPanel::on_varioR0_SB_editingFinished() { - generalSettings.varioRepeat = (ui->varioR0_SB->value()-500)/10; - emit modified(); + if (!lock) { + generalSettings.varioRepeat = (ui->varioR0_SB->value() - 500) / 10; + emit modified(); + } } void GeneralSetupPanel::on_BLBright_SB_editingFinished() { - if (ui->BLBright_SB->value() < ui->OFFBright_SB->value()) { - ui->BLBright_SB->setValue(ui->OFFBright_SB->value()); - } else { - ui->OFFBright_SB->setMaximum(ui->BLBright_SB->value()); - generalSettings.backlightBright = 100 - ui->BLBright_SB->value(); - emit modified(); + if (!lock) { + if (ui->BLBright_SB->value() < ui->OFFBright_SB->value()) { + ui->BLBright_SB->setValue(ui->OFFBright_SB->value()); + } else { + ui->OFFBright_SB->setMaximum(ui->BLBright_SB->value()); + generalSettings.backlightBright = 100 - ui->BLBright_SB->value(); + emit modified(); + } } } void GeneralSetupPanel::on_OFFBright_SB_editingFinished() { - if (ui->OFFBright_SB->value() > ui->BLBright_SB->value()) { - ui->OFFBright_SB->setValue(ui->BLBright_SB->value()); - } else { - ui->BLBright_SB->setMinimum(ui->OFFBright_SB->value()); - generalSettings.backlightOffBright = ui->OFFBright_SB->value(); - emit modified(); + if (!lock) { + if (ui->OFFBright_SB->value() > ui->BLBright_SB->value()) { + ui->OFFBright_SB->setValue(ui->BLBright_SB->value()); + } else { + ui->BLBright_SB->setMinimum(ui->OFFBright_SB->value()); + generalSettings.backlightOffBright = ui->OFFBright_SB->value(); + emit modified(); + } } } -void GeneralSetupPanel::on_volume_SB_editingFinished() +void GeneralSetupPanel::on_volume_SL_valueChanged() { - generalSettings.speakerVolume = ui->volume_SB->value() - 12; - emit modified(); + if (!lock) { + generalSettings.speakerVolume = ui->volume_SL->value() - 12; + emit modified(); + } } void GeneralSetupPanel::on_contrastSB_editingFinished() { - generalSettings.contrast = ui->contrastSB->value(); - emit modified(); + if (!lock) { + generalSettings.contrast = ui->contrastSB->value(); + emit modified(); + } } void GeneralSetupPanel::on_battwarningDSB_editingFinished() { - generalSettings.vBatWarn = (int)(ui->battwarningDSB->value()*10); - emit modified(); + if (!lock) { + generalSettings.vBatWarn = (int)(ui->battwarningDSB->value() * 10); + emit modified(); + } } void GeneralSetupPanel::on_vBatMinDSB_editingFinished() { - generalSettings.vBatMin = ui->vBatMinDSB->value() * 10 - 90; - emit modified(); + if (!lock) { + generalSettings.vBatMin = ui->vBatMinDSB->value() * 10 - 90; + emit modified(); + } } void GeneralSetupPanel::on_vBatMaxDSB_editingFinished() { - generalSettings.vBatMax = ui->vBatMaxDSB->value() * 10 - 120; - emit modified(); + if (!lock) { + generalSettings.vBatMax = ui->vBatMaxDSB->value() * 10 - 120; + emit modified(); + } } void GeneralSetupPanel::on_re_CB_currentIndexChanged(int index) { - generalSettings.reNavigation = ui->re_CB->currentIndex(); - emit modified(); + if (!lock) { + generalSettings.reNavigation = ui->re_CB->currentIndex(); + emit modified(); + } } void GeneralSetupPanel::on_countrycode_CB_currentIndexChanged(int index) { - generalSettings.countryCode = ui->countrycode_CB->currentIndex(); - emit modified(); + if (!lock) { + generalSettings.countryCode = ui->countrycode_CB->currentIndex(); + emit modified(); + } } void GeneralSetupPanel::on_units_CB_currentIndexChanged(int index) { - generalSettings.imperial = ui->units_CB->currentIndex(); - emit modified(); + if (!lock) { + generalSettings.imperial = ui->units_CB->currentIndex(); + emit modified(); + } } void GeneralSetupPanel::on_ppm_units_CB_currentIndexChanged(int index) { - generalSettings.ppmunit = ui->ppm_units_CB->currentIndex(); - emit modified(); + if (!lock) { + generalSettings.ppmunit = ui->ppm_units_CB->currentIndex(); + emit modified(); + } } void GeneralSetupPanel::on_beeperlenCB_currentIndexChanged(int index) { - generalSettings.beeperLength = index-2; - emit modified(); + if (!lock) { + generalSettings.beeperLength = index - 2; + emit modified(); + } } void GeneralSetupPanel::on_hapticLengthCB_currentIndexChanged(int index) { - generalSettings.hapticLength = index-2; - emit modified(); + if (!lock) { + generalSettings.hapticLength = index - 2; + emit modified(); + } } void GeneralSetupPanel::on_gpsFormatCB_currentIndexChanged(int index) { - generalSettings.gpsFormat = index; - emit modified(); + if (!lock) { + generalSettings.gpsFormat = index; + emit modified(); + } } void GeneralSetupPanel::on_backlightautoSB_editingFinished() { - int i = ui->backlightautoSB->value()/5; - if((i*5)!=ui->backlightautoSB->value()) - ui->backlightautoSB->setValue(i*5); - else - { - generalSettings.backlightDelay = i; - emit modified(); + if (!lock) { + int i = ui->backlightautoSB->value() / 5; + if((i * 5) != ui->backlightautoSB->value()) + ui->backlightautoSB->setValue(i * 5); + else + { + generalSettings.backlightDelay = i; + emit modified(); + } } } void GeneralSetupPanel::on_switchesDelay_valueChanged(int) { - generalSettings.switchesDelay = (ui->switchesDelay->value() / 10) - 15; - emit modified(); + if (!lock) { + generalSettings.switchesDelay = (ui->switchesDelay->value() / 10) - 15; + emit modified(); + } } void GeneralSetupPanel::on_adjustRTC_stateChanged(int) { - generalSettings.adjustRTC = ui->adjustRTC->isChecked(); - emit modified(); + if (!lock) { + generalSettings.adjustRTC = ui->adjustRTC->isChecked(); + emit modified(); + } } void GeneralSetupPanel::on_inactimerSB_editingFinished() { - generalSettings.inactivityTimer = ui->inactimerSB->value(); - emit modified(); + if (!lock) { + generalSettings.inactivityTimer = ui->inactimerSB->value(); + emit modified(); + } } void GeneralSetupPanel::on_pwrOffIfInactiveSB_editingFinished() @@ -842,132 +937,167 @@ void GeneralSetupPanel::on_pwrOffIfInactiveSB_editingFinished() void GeneralSetupPanel::on_memwarnChkB_stateChanged(int) { - generalSettings.disableMemoryWarning = ui->memwarnChkB->isChecked() ? 0 : 1; - emit modified(); + if (!lock) { + generalSettings.disableMemoryWarning = !ui->memwarnChkB->isChecked(); + emit modified(); + } } void GeneralSetupPanel::on_alarmwarnChkB_stateChanged(int) { - generalSettings.disableAlarmWarning = ui->alarmwarnChkB->isChecked() ? 0 : 1; - emit modified(); + if (!lock) { + generalSettings.disableAlarmWarning = !ui->alarmwarnChkB->isChecked(); + emit modified(); + } } void GeneralSetupPanel::on_rssiPowerOffWarnChkB_stateChanged(int) { - generalSettings.disableRssiPoweroffAlarm = ui->rssiPowerOffWarnChkB->isChecked() ? 0 : 1; - emit modified(); + if (!lock) { + generalSettings.disableRssiPoweroffAlarm = !ui->rssiPowerOffWarnChkB->isChecked(); + emit modified(); + } } void GeneralSetupPanel::on_trainerPowerOffWarnChkB_stateChanged(int) { - generalSettings.disableTrainerPoweroffAlarm = ui->trainerPowerOffWarnChkB->isChecked() ? 0 : 1; - emit modified(); + if (!lock) { + generalSettings.disableTrainerPoweroffAlarm = !ui->trainerPowerOffWarnChkB->isChecked(); + emit modified(); + } } void GeneralSetupPanel::on_beeperCB_currentIndexChanged(int index) { - generalSettings.beeperMode = (GeneralSettings::BeeperMode)(index-2); - emit modified(); + if (!lock) { + generalSettings.beeperMode = (GeneralSettings::BeeperMode)(index - 2); + emit modified(); + } } void GeneralSetupPanel::on_displayTypeCB_currentIndexChanged(int index) { - generalSettings.optrexDisplay = index; - emit modified(); + if (!lock) { + generalSettings.optrexDisplay = index; + emit modified(); + } } void GeneralSetupPanel::on_hapticmodeCB_currentIndexChanged(int index) { - generalSettings.hapticMode = (GeneralSettings::BeeperMode)(index-2); - emit modified(); + if (!lock) { + generalSettings.hapticMode = (GeneralSettings::BeeperMode)(index - 2); + emit modified(); + } } void GeneralSetupPanel::on_channelorderCB_currentIndexChanged(int index) { - generalSettings.templateSetup = index; - emit modified(); + if (!lock) { + generalSettings.templateSetup = ui->channelorderCB->currentData().toInt(); + emit modified(); + } } void GeneralSetupPanel::on_stickmodeCB_currentIndexChanged(int index) { - generalSettings.stickMode = index; - emit modified(); + if (!lock) { + generalSettings.stickMode = ui->stickmodeCB->currentData().toInt(); + emit modified(); + } } void GeneralSetupPanel::unlockSwitchEdited() { - int i=0; - i|=(((uint16_t)ui->chkSA->value())); - i|=(((uint16_t)ui->chkSB->value())<<2); - i|=(((uint16_t)ui->chkSC->value())<<4); - i|=(((uint16_t)ui->chkSD->value())<<6); - i|=(((uint16_t)ui->chkSE->value())<<8); - i|=(((uint16_t)ui->chkSF->value())<<10); - i|=(((uint16_t)ui->chkSG->value())<<12); - i|=(((uint16_t)ui->chkSH->value())<<14); - generalSettings.switchUnlockStates=i; - emit modified(); + if (!lock) { + int i = 0; + i |= (((uint16_t)ui->chkSA->value())); + i |= (((uint16_t)ui->chkSB->value()) << 2); + i |= (((uint16_t)ui->chkSC->value()) << 4); + i |= (((uint16_t)ui->chkSD->value()) << 6); + i |= (((uint16_t)ui->chkSE->value()) << 8); + i |= (((uint16_t)ui->chkSF->value()) << 10); + i |= (((uint16_t)ui->chkSG->value()) << 12); + i |= (((uint16_t)ui->chkSH->value()) << 14); + generalSettings.switchUnlockStates=i; + emit modified(); + } } void GeneralSetupPanel::on_blAlarm_ChkB_stateChanged() { - generalSettings.alarmsFlash = ui->blAlarm_ChkB->isChecked(); - emit modified(); + if (!lock) { + generalSettings.alarmsFlash = ui->blAlarm_ChkB->isChecked(); + emit modified(); + } } void GeneralSetupPanel::on_registrationId_editingFinished() { - strncpy(generalSettings.registrationId, ui->registrationId->text().toLatin1(), REGISTRATION_ID_LEN); - emit modified(); + if (!lock) { + strncpy(generalSettings.registrationId, ui->registrationId->text().toLatin1(), REGISTRATION_ID_LEN); + emit modified(); + } } void GeneralSetupPanel::stickReverseEdited() { - generalSettings.stickReverse = ((int)ui->stickReverse1->isChecked()) | ((int)ui->stickReverse2->isChecked()<<1) | ((int)ui->stickReverse3->isChecked()<<2) | ((int)ui->stickReverse4->isChecked()<<3); - emit modified(); + if (!lock) { + generalSettings.stickReverse = ((int)ui->stickReverse1->isChecked()) | + ((int)ui->stickReverse2->isChecked() << 1) | + ((int)ui->stickReverse3->isChecked() << 2) | + ((int)ui->stickReverse4->isChecked() << 3); + emit modified(); + } } void GeneralSetupPanel::on_modelQuickSelect_CB_stateChanged(int) { - generalSettings.modelQuickSelect = ui->modelQuickSelect_CB->isChecked(); - emit modified(); + if (!lock) { + generalSettings.modelQuickSelect = ui->modelQuickSelect_CB->isChecked(); + emit modified(); + } } void GeneralSetupPanel::on_modelSelectLayout_CB_currentIndexChanged(int index) { - generalSettings.modelSelectLayout = index; - emit modified(); + if (!lock) { + generalSettings.modelSelectLayout = index; + emit modified(); + } } void GeneralSetupPanel::on_labelSingleSelect_CB_currentIndexChanged(int index) { - generalSettings.labelSingleSelect = index; - showLabelSelectOptions(); - emit modified(); + if (!lock) { + generalSettings.labelSingleSelect = index; + showLabelSelectOptions(); + emit modified(); + } } void GeneralSetupPanel::on_labelMultiMode_CB_currentIndexChanged(int index) { - generalSettings.labelMultiMode = index; - showLabelSelectOptions(); - emit modified(); + if (!lock) { + generalSettings.labelMultiMode = index; + showLabelSelectOptions(); + emit modified(); + } } void GeneralSetupPanel::on_favMultiMode_CB_currentIndexChanged(int index) { - generalSettings.favMultiMode = index; - emit modified(); + if (!lock) { + generalSettings.favMultiMode = index; + emit modified(); + } } void GeneralSetupPanel::on_startSoundCB_stateChanged(int) { - generalSettings.dontPlayHello = !ui->startSoundCB->isChecked(); - emit modified(); -} - -void GeneralSetupPanel::on_invertLCD_CB_stateChanged(int) -{ - generalSettings.invertLCD = ui->invertLCD_CB->isChecked(); - emit modified(); + if (!lock) { + generalSettings.dontPlayHello = !ui->startSoundCB->isChecked(); + emit modified(); + } } diff --git a/companion/src/generaledit/generalsetup.h b/companion/src/generaledit/generalsetup.h index d114db7d772..2f09e4778f7 100644 --- a/companion/src/generaledit/generalsetup.h +++ b/companion/src/generaledit/generalsetup.h @@ -25,6 +25,8 @@ #include "generaledit.h" #include "eeprominterface.h" +class FilteredItemModelFactory; + namespace Ui { class GeneralSetup; } @@ -58,7 +60,7 @@ class GeneralSetupPanel : public GeneralPanel void on_hapticStrength_valueChanged(); void on_soundModeCB_currentIndexChanged(int index); void on_beeperlenCB_currentIndexChanged(int index); - void on_volume_SB_editingFinished(); + void on_volume_SL_valueChanged(); void on_hapticmodeCB_currentIndexChanged(int index); void on_hapticLengthCB_currentIndexChanged(int index); void on_backlightswCB_currentIndexChanged(int index); @@ -102,12 +104,12 @@ class GeneralSetupPanel : public GeneralPanel void on_labelSingleSelect_CB_currentIndexChanged(int); void on_labelMultiMode_CB_currentIndexChanged(int); void on_favMultiMode_CB_currentIndexChanged(int); - void on_invertLCD_CB_stateChanged(int); void on_pwrOffIfInactiveSB_editingFinished(); private: Ui::GeneralSetup *ui; + FilteredItemModelFactory *panelFilteredModels; void showLabelSelectOptions(); diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index d4a6368f631..68a30ddd2de 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -6,8 +6,8 @@ 0 0 - 858 - 1018 + 878 + 1231 @@ -19,15 +19,12 @@ Readonly Unlock - - Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop - - QLayout::SizeConstraint::SetMinimumSize + QLayout::SetDefaultConstraint 0 @@ -46,9 +43,6 @@ SC - - Qt::AlignmentFlag::AlignCenter - @@ -83,14 +77,11 @@ 0 - - Qt::Orientation::Vertical - true - QSlider::TickPosition::TicksBothSides + QSlider::NoTicks 1 @@ -108,9 +99,6 @@ SE - - Qt::AlignmentFlag::AlignCenter - @@ -148,14 +136,11 @@ 0 - - Qt::Orientation::Vertical - true - QSlider::TickPosition::TicksBothSides + QSlider::NoTicks 1 @@ -194,14 +179,11 @@ 0 - - Qt::Orientation::Vertical - true - QSlider::TickPosition::TicksBothSides + QSlider::NoTicks 1 @@ -240,14 +222,11 @@ 0 - - Qt::Orientation::Vertical - true - QSlider::TickPosition::TicksBothSides + QSlider::NoTicks 1 @@ -286,14 +265,11 @@ 0 - - Qt::Orientation::Vertical - true - QSlider::TickPosition::TicksBothSides + QSlider::NoTicks 1 @@ -332,14 +308,11 @@ 0 - - Qt::Orientation::Vertical - true - QSlider::TickPosition::TicksBothSides + QSlider::NoTicks 1 @@ -378,14 +351,11 @@ 0 - - Qt::Orientation::Vertical - true - QSlider::TickPosition::TicksBothSides + QSlider::NoTicks 1 @@ -403,9 +373,6 @@ SA - - Qt::AlignmentFlag::AlignCenter - @@ -419,9 +386,6 @@ SF - - Qt::AlignmentFlag::AlignCenter - @@ -435,9 +399,6 @@ SH - - Qt::AlignmentFlag::AlignCenter - @@ -451,9 +412,6 @@ SD - - Qt::AlignmentFlag::AlignCenter - @@ -467,9 +425,6 @@ SB - - Qt::AlignmentFlag::AlignCenter - @@ -507,14 +462,11 @@ 0 - - Qt::Orientation::Vertical - true - QSlider::TickPosition::TicksBothSides + QSlider::NoTicks 1 @@ -532,15 +484,12 @@ SG - - Qt::AlignmentFlag::AlignCenter - - Qt::Orientation::Horizontal + Qt::Vertical @@ -554,338 +503,277 @@ - + + + + Vario volume + + + + - - + + - Voice Language + Backlight Brightness - - - - - - Beep volume - - - - - - - -2 - - - 2 - - - 1 - - - Qt::Orientation::Horizontal - - + + + + Label matching + + + + + + + + America + - - - - Wav volume - - + + + Japan + - - - - -2 - - - 2 - - - 1 - - - Qt::Orientation::Horizontal - - + + + Europe + - - + + + + + + Speaker Pitch (spkr only) + + + + + + + Backlight flash on alarm + + + + + + + -2 + + + 2 + + + 1 + + + Qt::Horizontal + + + + + + + Backlight Switch + + + + + + + -2 + + + 2 + + + 1 + + + Qt::Horizontal + + + + + + + - Vario volume + Color 1 - - - - -2 - + + - 2 + 20 - 1 - - - Qt::Orientation::Horizontal + 5 - - + + - Background volume - - - - - - - -2 - - - 2 - - - 1 - - - Qt::Orientation::Horizontal + Color 2 - - + + - Label selection mode + Favorites matching - - + + - Label matching + Country Code - - + + + + + + + + + Automatically adjust the radio's clock if a GPS is connected to telemetry. + + + Qt::LeftToRight + + + Adjust RTC + + + + + + + - Backlight OFF Brightness + Sound Mode - - - - - 0 - 0 - + + + + -2 - 23 + 2 + + + 1 + + + Qt::Horizontal - - + + - - Large image (2 columns) - + + + 1 + + - - Small image (3 columns) - + + + 2 + + - - Name only (2 columns) - + + + 3 + + - - Name only (1 column) - + + + 4 + + - + - - + + - Beeper + Must match - Speaker - - - - - BeeperVoice - - - - - SpeakerVoice + Optional match - - - - - 0 - 0 - - - - Stick reverse - - - - + 8 - - - - Timeshift from UTC - - - - - - - - - - - - - - Backlight flash on alarm - - - - - - - Backlight Brightness - - - - - - - Vario pitch at max - - - - - + + - Vario repeat at zero + Backlight Auto OFF after - + Manage Models layout - - - - - - - Speaker Volume - - - - - - - Owner Registration ID - - - - - - - Rotary Encoder Mode - - - - - - - - - - Model quick select - - - - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> + + + + ms - 1 + 200 - 20 - - - 1 + 1000 - - - - - - Enable this to quickly change model on the model select page (a long press can then be used to open the model edit menu). + + 10 - - + + 500 - + - Qt::Orientation::Vertical + Qt::Vertical @@ -895,110 +783,83 @@ p, li { white-space: pre-wrap; } - - + + - America + Multi select - Japan + Single select + + + + + + + + + Match all - Europe + Match any - - - - ms + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> - 200 + 1 - 1000 - - - 10 + 20 - 500 + 1 - - - - Hz - - - 300 - - - 1100 - - - 10 - - - 700 + + + + Backlight OFF Brightness - + Vario pitch at zero - - + + - RotEnc Navigation + Wav volume - - - - - - 1 - - - - - - - 2 - - - - - - - 3 - - - - - - - 4 - - - - - - + @@ -1016,319 +877,219 @@ p, li { white-space: pre-wrap; } - - + + - Country Code + Owner Registration ID - - + + - Backlight Switch - - - - - - - - 0 - 0 - - - - - - - - - - If this value is not 0, any keypress will turn on the backlight and turn it off after the specified number of seconds. - - - sec - - - 600 - - - 5 + Timeshift from UTC - - - - - - - - - Automatically adjust the radio's clock if a GPS is connected to telemetry. - - - Qt::LayoutDirection::RightToLeft - - - Adjust RTC - - - - - - - - - 100 + + + + Model quick select - - + + - Backlight Auto OFF after + - + FAI Mode - - - - Hz - + + + + + - 1300 + -2 - 2900 + 2 - - 10 + + 1 - - 1700 + + Qt::Horizontal - - + + - If you enable FAI, only RSSI and RxBt sensors will keep working. This function cannot be disabled by the radio. + Enable this to quickly change model on the model select page (a long press can then be used to open the model edit menu). - - + + - Backlight color + Background volume - - - - - - Color 1 - - - - - - - 20 - - - 5 - - - Qt::Orientation::Horizontal - - - - - - - Color 2 - - - - - - - - - Speaker Pitch (spkr only) + + + + 5 - - - - - - + + 100 - - + + - Sound Mode + Rotary Encoder Mode - - + + - Keys Backlight + Voice Language - - - - 5 - + + 100 - - + + + + + 0 + 0 + + - Favorites matching + Stick reverse - - - - - Multi select - - - - - Single select - - - - - - + + - Match all + Beeper - Match any + Speaker - - - - - Must match + BeeperVoice - Optional match + SpeakerVoice - - + + + + If you enable FAI, only RSSI and RxBt sensors will keep working. This function cannot be disabled by the radio. + - Invert LCD + - - + + - + Keys Backlight - - - - - - QLayout::SizeConstraint::SetDefaultConstraint - - - - - - 0 - 0 - + + + + Hz - - - 0 - 0 - + + 300 + + + 1100 + + + 10 + + + 700 + + + + - Haptic Mode + Speaker Volume - - - - - 0 - 0 - + + + + 23 - - - 0 - 0 - + + 5 - - + + 0 + + + Qt::Horizontal + + + + - Contrast + - - + + - + 0 0 - - - 0 - 22 - - @@ -1336,134 +1097,209 @@ p, li { white-space: pre-wrap; } - If not zero will sound beeps if the transmitter has been left without inputs for the specified number of minutes. + If this value is not 0, any keypress will turn on the backlight and turn it off after the specified number of seconds. - min + sec - 120 + 600 + + + 5 - - - - - - - - - - Mode selection: - -Mode 1: - Left stick: Elevator, Rudder - Right stick: Throttle, Aileron - -Mode 2: - Left stick: Throttle, Rudder - Right stick: Elevator, Aileron - -Mode 3: - Left stick: Elevator, Aileron - Right stick: Throttle, Rudder - -Mode 4: - Left stick: Throttle, Aileron - Right stick: Elevator, Rudder - - - - - 1 - + + - Mode 1 (RUD ELE THR AIL) + Large image (2 columns) - Mode 2 (RUD THR ELE AIL) + Small image (3 columns) - Mode 3 (AIL ELE THR RUD) + Name only (2 columns) - Mode 4 (AIL THR ELE RUD) + Name only (1 column) - - - - - 0 - 0 - + + + + Vario repeat at zero - - - 0 - 0 - + + + + + + Label selection mode + + + + + + + Vario pitch at max + + + + - Battery Meter Range + Backlight color + + + + + + + Beep volume + + + + + + + Hz + + + 1300 + + + 2900 + + + 10 + + + 1700 + + + + + + + RotEnc Navigation - + + + + + + + + QLayout::SetDefaultConstraint + + + - Ask on Connect + 0s - Joystick (HID) + 0.5s - USB Mass Storage + 1s - USB Serial (CDC) + 2s + + + + + 3s - - + + + + + + + + + + <html><head/><body><p>Channel order</p><p><br/></p><p>Defines the order of the default mixes created on a new model.</p></body></html> + + + -1 + + + + + - + 0 0 - + + Play Delay (switch mid position) + + + + + + + + 0 + 0 + + + - 0 - 0 + 16777215 + 16777215 + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + - Low EEPROM Warning + + + + true - - + + 0 @@ -1477,12 +1313,12 @@ Mode 4: - RSSI Poweroff Warning + Haptic Strength - - + + 0 @@ -1491,55 +1327,22 @@ Mode 4: - 0 - 22 + 20 + 0 - - - Quiet - - - - - Only Alarms - - - - - No Keys - - - - - All - - - - - - - - - 0 - 0 - - - - - 0 - 0 - + + - Haptic Strength + Battery Warning - - + + - + 0 0 @@ -1547,221 +1350,87 @@ Mode 4: 0 - 22 - - - - - 16777215 - 16777215 + 0 - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - true + Haptic Mode - - - - - 4800 Baud - - - - - 9600 Baud - - - - - 14400 Baud - - - - - 19200 Baud - - - - - 38400 Baud - - - - - 57600 Baud - - - - - 76800 Baud - - + + - - 115200 Baud - + + + + 0 + 0 + + + + + --- + + + + + 2s + + + + + 3s + + + + + 4s + + + + + 6s + + + + + 8s + + + + + 10s + + + + + 15s + + + - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - -2 - - - 2 - - - 1 - - - Qt::Orientation::Horizontal - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - - - - - - - PPM Units - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - - + - - + + - USB Mode + Trainer Poweroff Warning - - + + - + Measurement Units - - - - - DMS - - - - - NMEA - - - + + - - + + 0 @@ -1771,48 +1440,13 @@ p, li { white-space: pre-wrap; } 0 - 22 + 0 - - - X-Short - - - - - Short - - - - - Normal - - - - - Long - - - - - X-Long - - - - - - - - Qt::Orientation::Vertical - - - - 20 - 40 - + + Beeper Length - + @@ -1848,17 +1482,17 @@ p, li { white-space: pre-wrap; } - - + + - Power On Delay + GPS Coordinates - - + + - + 0 0 @@ -1866,179 +1500,128 @@ p, li { white-space: pre-wrap; } 0 - 0 + 22 + + + + + 16777215 + 16777215 + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + - Beeper Length + - - - - - - 0.-- + + true - - - 0.-- - - - - - 0.0 - - - - - us - - - - + + - + Hats Mode - - - - - - - - - - <html><head/><body><p>Channel order</p><p><br/></p><p>Defines the order of the default mixes created on a new model.</p></body></html> - - - 0 - - - - R E T A - - - - - R E A T - - - - - R T E A - - - - - R T A E - - - - - R A E T - - - - - R A T E - - - - - E R T A - - - - - E R A T - - - - - E T R A - - - - - E T A R - - - - - E A R T - - - - - E A T R - - - - - T R E A - - - - - T R A E - - - - - T E R A - - + + - T E A R + Ask on Connect - T A R E + Joystick (HID) - T A E R + USB Mass Storage - A R E T + USB Serial (CDC) + + + + + + PPM Units + + + + + + + + 0 + 0 + + + + + 0 + 22 + + - A R T E + X-Short - A E R T + Short - A E T R + Normal - A T R E + Long - A T E R + X-Long + + + + + 0 + 0 + + + + MAVLink Baud Rate + + + @@ -2068,56 +1651,107 @@ p, li { white-space: pre-wrap; } - - - - - Ask on Connect - - + + + + + 0 + 0 + + + + + 0 + 22 + + - Audio + Standard - Trainer + Optrex - - - - Stick Mode - - - - - + + - + 0 0 - - Play Delay (switch mid position) + + + 0 + 22 + + + + + + + + + + Battery warning voltage. +This is the threshold where the battery warning sounds. + +Acceptable values are 3v..12v + + + + + + V + + + 1 + + + 3.000000000000000 + + + 12.000000000000000 + + + 0.100000000000000 + + + 9.600000000000000 - - + + - Trainer Poweroff Warning + USB Mode - - + + + + + 0 + 0 + + + + + 0 + 0 + + + + + - GPS Coordinates + Contrast @@ -2140,8 +1774,21 @@ p, li { white-space: pre-wrap; } - - + + + + + 0 + 0 + + + + Default Channel Order + + + + + 0 @@ -2154,21 +1801,6 @@ p, li { white-space: pre-wrap; } 22 - - - - - - - - Beeper volume - -0 - Quiet. No beeps at all. -1 - No Keys. Normal beeps but menu keys do not beep. -2 - Normal. -3 - Loud. -4 - Extra loud. - Quiet @@ -2176,7 +1808,7 @@ p, li { white-space: pre-wrap; } - Alarms Only + Only Alarms @@ -2191,15 +1823,34 @@ p, li { white-space: pre-wrap; } - - - - Hats Mode - + + + + + DMS + + + + + NMEA + + - - + + + + + 0 + 0 + + + + + 0 + 22 + + @@ -2207,27 +1858,61 @@ p, li { white-space: pre-wrap; } - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> + If not zero will sound beeps if the transmitter has been left without inputs for the specified number of minutes. - ms - - - 0 + min - 1000 + 120 + + + + + + + + + + + + + + + + + + + + Mode selection: + +Mode 1: + Left stick: Elevator, Rudder + Right stick: Throttle, Aileron + +Mode 2: + Left stick: Throttle, Rudder + Right stick: Elevator, Aileron + +Mode 3: + Left stick: Elevator, Aileron + Right stick: Throttle, Rudder + +Mode 4: + Left stick: Throttle, Aileron + Right stick: Elevator, Rudder + + - - 10 + + -1 - - 0 + + + + + + Power ON/OFF Haptic @@ -2250,15 +1935,27 @@ p, li { white-space: pre-wrap; } - - + + + + + 0 + 0 + + + + + 0 + 0 + + - Power ON/OFF Haptic + Inactivity Timer - - + + 0 @@ -2305,50 +2002,89 @@ p, li { white-space: pre-wrap; } - - + + - + 0 0 + + + 0 + 0 + + - Default Channel Order + Low EEPROM Warning - - + + - 0s + Metric - 0.5s + Imperial + + + + + + 0.-- + - 1s + 0.-- - 2s + 0.0 - 3s + us - - + + + + + Ask on Connect + + + + + Audio + + + + + Trainer + + + + + + + + Stick Mode + + + + + 0 @@ -2358,33 +2094,44 @@ p, li { white-space: pre-wrap; } 0 - 0 + 22 - - Inactivity Timer + + + + + + + + Beeper volume + +0 - Quiet. No beeps at all. +1 - No Keys. Normal beeps but menu keys do not beep. +2 - Normal. +3 - Loud. +4 - Extra loud. - - - - - Metric + Quiet - Imperial + Alarms Only + + + + + No Keys + + + + + All - - - - - - Measurement Units - @@ -2394,45 +2141,62 @@ p, li { white-space: pre-wrap; } - - + + - + 0 0 - + - 16777215 - 16777215 + 0 + 0 + + RSSI Poweroff Warning + + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> - - + + ms - - true + + 0 + + + 1000 + + + 10 + + + 0 - - + + - + 0 0 @@ -2443,43 +2207,35 @@ p, li { white-space: pre-wrap; } 22 - - - - - + + + 16777215 + 16777215 + - Battery warning voltage. -This is the threshold where the battery warning sounds. - -Acceptable values are 3v..12v - - - - - - V - - - 1 - - - 3.000000000000000 - - - 12.000000000000000 + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - 0.100000000000000 + + - - 9.600000000000000 + + true - - + + 0 @@ -2493,12 +2249,19 @@ Acceptable values are 3v..12v - Beeper Mode + Haptic Length - - + + + + Power On Delay + + + + + 0 @@ -2512,90 +2275,78 @@ Acceptable values are 3v..12v - "No Sound" Warning + Beeper Mode - - + + - - - - 0 - 0 - - - - - --- - - - - - 2s - - - - - 3s - - - - - 4s - - - - - 6s - - - - - 8s - - - - - 10s - - - - - 15s - - - + + 4800 Baud + - + + + 9600 Baud + + + + + 14400 Baud + + + + + 19200 Baud + + + + + 38400 Baud + + + + + 57600 Baud + + + + + 76800 Baud + + + + + 115200 Baud + + + - - - - - 0 - 0 - + + + + Qt::Vertical - + 20 - 0 + 40 - - - + + + + - Battery Warning + Jack Mode - - + + - + 0 0 @@ -2606,41 +2357,17 @@ Acceptable values are 3v..12v 22 - - - Standard - - - - - Optrex - - - - - - - - - 0 - 0 - + + -2 - - - 0 - 0 - + + 2 - - Haptic Length + + 1 - - - - - - Jack Mode + + Qt::Horizontal @@ -2706,11 +2433,33 @@ Acceptable values are 3v..12v - - + + + + + 0 + 0 + + + + + 0 + 0 + + + + Battery Meter Range + + - - + + + + + 0 + 0 + + 0 @@ -2718,7 +2467,49 @@ Acceptable values are 3v..12v - MAVLink Baud Rate + "No Sound" Warning + + + + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + + + + + + true @@ -2731,9 +2522,6 @@ Acceptable values are 3v..12v - - If not zero transmitter will shut down if it has been left without inputs for the specified number of minutes. - min @@ -2747,7 +2535,7 @@ Acceptable values are 3v..12v - Qt::Orientation::Horizontal + Qt::Vertical @@ -2760,7 +2548,7 @@ Acceptable values are 3v..12v - Qt::Orientation::Vertical + Qt::Vertical diff --git a/companion/src/generaledit/hardware.cpp b/companion/src/generaledit/hardware.cpp index 685f52fe8ee..f4f49953add 100644 --- a/companion/src/generaledit/hardware.cpp +++ b/companion/src/generaledit/hardware.cpp @@ -357,6 +357,16 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings addParams(); } + if (Boards::getCapability(board, Board::LcdWidth) == 128) { + addSection(tr("Screen")); + + addLabel(tr("Invert")); + AutoCheckBox *screenInvert = new AutoCheckBox(this); + screenInvert->setField(generalSettings.invertLCD, this); + params->append(screenInvert); + addParams(); + } + addVSpring(grid, 0, grid->rowCount()); addHSpring(grid, grid->columnCount(), 0); disableMouseScrolling(); diff --git a/companion/src/generaledit/trainer.cpp b/companion/src/generaledit/trainer.cpp index fd801b68c13..47bc0101182 100644 --- a/companion/src/generaledit/trainer.cpp +++ b/companion/src/generaledit/trainer.cpp @@ -50,7 +50,7 @@ TrainerPanel::TrainerPanel(QWidget * parent, GeneralSettings & generalSettings, addLabel(tr("Weight"), row, 2); addLabel(tr("Source"), row++, 3); - for (int i = 0; i < CPN_MAX_STICKS; i++, row++) { + for (int i = 0; i < stickcnt; i++, row++) { col = 0; addLabel(Boards::getInputName(i), row, col++); diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 86cd731767e..c84ef4b6e37 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -225,17 +225,6 @@ void GVarGroup::setWeight(int val) * Helpers namespace functions */ -// TODO: Move lookup to GVarData class (w/out combobox) -void Helpers::populateGvarUseCB(QComboBox * b, unsigned int phase) -{ - b->addItem(QCoreApplication::translate("GVarData", "Own value")); - for (int i=0; igetCapability(FlightModes); i++) { - if (i != (int)phase) { - b->addItem(QCoreApplication::translate("GVarData", "Flight mode %1 value").arg(i)); - } - } -} - static bool caseInsensitiveLessThan(const QString &s1, const QString &s2) { return s1.toLower() < s2.toLower(); @@ -413,9 +402,10 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx) QPixmap makePixMap(const QImage & image) { - Firmware * firmware = getCurrentFirmware(); - QImage result = image.scaled(firmware->getCapability(LcdWidth), firmware->getCapability(LcdHeight)); - if (firmware->getCapability(LcdDepth) == 4) { + Board::Type board = getCurrentBoard(); + QImage result = image.scaled(Boards::getCapability(board, Board::LcdWidth), Boards::getCapability(board, Board::LcdHeight)); + + if (Boards::getCapability(board, Board::LcdDepth) == 4) { result = result.convertToFormat(QImage::Format_RGB32); for (int i = 0; i < result.width(); ++i) { for (int j = 0; j < result.height(); ++j) { diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 1e5b935a1d3..47350498926 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -39,7 +39,8 @@ extern const QColor colors[CPN_MAX_CURVES]; //convert from mode 1 to mode generalSettings.stickMode //NOTICE! => 1..4 -> 1..4 -#define CONVERT_MODE(x) (((x)<=4) ? modn12x3[generalSettings.stickMode][((x)-1)] : (x)) +#define CONVERT_AIRMODE(x) (((x)<=4) ? modn12x3[generalSettings.stickMode][((x)-1)] : (x)) +#define CONVERT_SURFACEMODE(x) (((x)<=4) ? modn12x3[4 + generalSettings.stickMode][((x)-1)] : (x)) #define CURVE_BASE 7 #define CH(x) (SRC_CH1+(x)-1-(SRC_SWC-SRC_3POS)) @@ -106,8 +107,6 @@ class GVarGroup: public QObject { namespace Helpers { - void populateGvarUseCB(QComboBox *b, unsigned int phase); - void populateFileComboBox(QComboBox * b, const QSet & set, const QString & current); void getFileComboBoxValue(QComboBox * b, char * dest, int length); diff --git a/companion/src/modeledit/colorcustomscreens.cpp b/companion/src/modeledit/colorcustomscreens.cpp index 8b4325c2256..5d748d9f81a 100644 --- a/companion/src/modeledit/colorcustomscreens.cpp +++ b/companion/src/modeledit/colorcustomscreens.cpp @@ -40,6 +40,8 @@ UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): ModelPanel(parent, model, generalSettings, firmware) { + Board::Type board = firmware->getBoard(); + QString sdPath = QString(g.profile[g.id()].sdPath()).trimmed(); grid = new QGridLayout(this); @@ -126,8 +128,10 @@ UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, Gene QImage image(path); if (!image.isNull()) { img->setText(""); - img->setFixedSize(QSize(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2)); - img->setPixmap(QPixmap::fromImage(image.scaled(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2))); + img->setFixedSize(QSize(Boards::getCapability(board, Board::LcdWidth) / 2, + Boards::getCapability(board, Board::LcdHeight) / 2)); + img->setPixmap(QPixmap::fromImage(image.scaled(Boards::getCapability(board, Board::LcdWidth) / 2, + Boards::getCapability(board, Board::LcdHeight) / 2))); } grid->addWidget(img, row++, col++); @@ -223,6 +227,7 @@ UserInterfacePanel::~UserInterfacePanel() CustomScreenPanel::CustomScreenPanel(QWidget * parent, ModelData & model, int index, GeneralSettings & generalSettings, Firmware * firmware): ModelPanel(parent, model, generalSettings, firmware) { + Board::Type board = firmware->getBoard(); RadioLayout::CustomScreens & scrns = model.customScreens; grid = new QGridLayout(this); @@ -245,11 +250,14 @@ CustomScreenPanel::CustomScreenPanel(QWidget * parent, ModelData & model, int in QString path(QString(":/layouts/mask_%1.png").arg(QString(scrns.customScreenData[index].layoutId).toLower())); QFile f(path); + if (f.exists()) { QImage image(path); if (!image.isNull()) { - img->setFixedSize(QSize(firmware->getCapability(LcdWidth) / 5, firmware->getCapability(LcdHeight) / 5)); - img->setPixmap(QPixmap::fromImage(image.scaled(firmware->getCapability(LcdWidth) / 5, firmware->getCapability(LcdHeight) / 5))); + img->setFixedSize(QSize(Boards::getCapability(board, Board::LcdWidth) / 5, + Boards::getCapability(board, Board::LcdHeight) / 5)); + img->setPixmap(QPixmap::fromImage(image.scaled(Boards::getCapability(board, Board::LcdWidth) / 5, + Boards::getCapability(board, Board::LcdHeight) / 5))); } } @@ -325,7 +333,7 @@ CustomScreenPanel::CustomScreenPanel(QWidget * parent, ModelData & model, int in str = tr("Top bar"); break; case LAYOUT_OPTION_FM: - str = tr("Flight mode"); + str = tr("%1 mode").arg(Boards::getRadioTypeString(firmware->getBoard())); break; case LAYOUT_OPTION_SLIDERS: str = tr("Sliders"); diff --git a/companion/src/modeledit/expodialog.ui b/companion/src/modeledit/expodialog.ui index 1b2be11c729..a8bd55e307c 100644 --- a/companion/src/modeledit/expodialog.ui +++ b/companion/src/modeledit/expodialog.ui @@ -83,7 +83,7 @@ - Flight modes + Modes diff --git a/companion/src/modeledit/flightmodes.cpp b/companion/src/modeledit/flightmodes.cpp index 6152e76118b..23f92f92eff 100644 --- a/companion/src/modeledit/flightmodes.cpp +++ b/companion/src/modeledit/flightmodes.cpp @@ -27,11 +27,12 @@ #include "namevalidator.h" FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware, - FilteredItemModel * rawSwitchFilteredModel): + FilteredItemModel * rawSwitchFilteredModel, QString radioType): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::FlightMode), phaseIdx(phaseIdx), - phase(model.flightModeData[phaseIdx]) + phase(model.flightModeData[phaseIdx]), + radioType(radioType) { ui->setupUi(this); connectItemModelEvents(rawSwitchFilteredModel); @@ -40,7 +41,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI ui->labelName->setToolTip(tr("Popup menu available")); connect(ui->labelName, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onCustomContextMenuRequested(const QPoint &))); - board = getCurrentBoard(); + board = firmware->getBoard(); fmCount = firmware->getCapability(FlightModes); gvCount = firmware->getCapability(Gvars); reCount = firmware->getCapability(RotaryEncoders); @@ -85,13 +86,14 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI // The trims QString labels[CPN_MAX_TRIMS]; - for(int i = 0; i < CPN_MAX_STICKS; i++) { + + for (int i = 0; i < Boards::getCapability(board, Board::Sticks); i++) { labels[i] = Boards::getInputName(i); } - labels[4] = "T5"; // TODO firmware function - labels[5] = "T6"; // TODO firmware function - labels[6] = "T7"; // TODO firmware function - labels[7] = "T8"; // TODO firmware function + + for (int i = Boards::getCapability(board, Board::Sticks); i < CPN_MAX_TRIMS; i++) { + labels[i] = QString("T%1").arg(i + 1); + } trimsLabel << ui->trim1Label << ui->trim2Label << ui->trim3Label << ui->trim4Label << ui->trim5Label << ui->trim6Label << ui->trim7Label << ui->trim8Label; trimsUse << ui->trim1Use << ui->trim2Use << ui->trim3Use << ui->trim4Use << ui->trim5Use << ui->trim6Use << ui->trim7Use << ui->trim8Use; @@ -106,7 +108,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI } for (int i = 0; i < trimCount; i++) { - trimsLabel[i]->setText(labels[CONVERT_MODE(i + 1) - 1]); + trimsLabel[i]->setText(labels[Boards::isAir(board) ? CONVERT_AIRMODE(i + 1) - 1 : CONVERT_SURFACEMODE(i + 1) - 1]); QComboBox * cb = trimsUse[i]; cb->setProperty("index", i); if (IS_HORUS_OR_TARANIS(board)) { @@ -118,9 +120,9 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI cb->addItem(tr("Own Trim"), m * 2); } else if (phaseIdx > 0) { - cb->addItem(tr("Use Trim from Flight mode %1").arg(m), m * 2); + cb->addItem(tr("Use Trim from %1 Mode %2").arg(radioType).arg(m), m * 2); if (IS_HORUS_OR_TARANIS(board)) { - cb->addItem(tr("Use Trim from Flight mode %1 + Own Trim as an offset").arg(m), m * 2 + 1); + cb->addItem(tr("Use Trim from %1 Mode %2 + Own Trim as an offset").arg(radioType).arg(m), m * 2 + 1); } } } @@ -137,8 +139,9 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI trimsSlider[i]->setProperty("index", i); trimsSlider[i]->setRange(-trimsMax, +trimsMax); - int chn = CONVERT_MODE(i + 1) - 1; - if (chn == 2/*TODO constant*/ && model.throttleReversed) + int chn = Boards::isAir(board) ? CONVERT_AIRMODE(i + 1) - 1 : CONVERT_SURFACEMODE(i + 1) - 1; + if (model.throttleReversed && ((Boards::isAir(board) && chn == 2/*TODO constant*/) || + (Boards::isSurface(board) && chn == 1/*TODO constant*/))) trimsSlider[i]->setInvertedAppearance(true); connect(trimsSlider[i], SIGNAL(valueChanged(int)), this, SLOT(phaseTrimSlider_valueChanged())); } @@ -155,7 +158,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI // RE link to another RE reUse[i] = new QComboBox(ui->reGB); reUse[i]->setProperty("index", i); - Helpers::populateGvarUseCB(reUse[i], phaseIdx); + populateGvarUseCB(reUse[i], phaseIdx); connect(reUse[i], SIGNAL(currentIndexChanged(int)), this, SLOT(phaseREUse_currentIndexChanged(int))); reLayout->addWidget(reUse[i], i, 1, 1, 1); } @@ -221,7 +224,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI int col = 0; // GVar label QLabel *label = new QLabel(ui->gvGB); - label->setText(tr("GVAR%1").arg(i + 1)); + label->setText(tr("GV%1").arg(i + 1)); label->setProperty("index", i); label->setContextMenuPolicy(Qt::CustomContextMenu); label->setToolTip(tr("Popup menu available")); @@ -241,7 +244,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI // GVar link to another GVar gvUse[i] = new QComboBox(ui->gvGB); gvUse[i]->setProperty("index", i); - Helpers::populateGvarUseCB(gvUse[i], phaseIdx); + populateGvarUseCB(gvUse[i], phaseIdx); connect(gvUse[i], SIGNAL(currentIndexChanged(int)), this, SLOT(phaseGVUse_currentIndexChanged(int))); gvLayout->addWidget(gvUse[i], i + 1, col++, 1, 1); } @@ -348,6 +351,16 @@ void FlightModePanel::updateGVar(int index) lock = false; } +void FlightModePanel::populateGvarUseCB(QComboBox * b, unsigned int phase) +{ + b->addItem(tr("Own value")); + for (int i = 0; i < getCurrentFirmware()->getCapability(FlightModes); i++) { + if (i != (int)phase) { + b->addItem(tr("%1 Mode %2 value").arg(radioType).arg(i)); + } + } +} + void FlightModePanel::setGVSB(QDoubleSpinBox * sb, int min, int max, int val) { int idx = sb->property("index").toInt(); @@ -430,7 +443,7 @@ void FlightModePanel::phaseFadeOut_editingFinished() void FlightModePanel::trimUpdate(unsigned int trim) { lock = true; - int chn = CONVERT_MODE(trim + 1) - 1; + int chn = Boards::isAir(board) ? CONVERT_AIRMODE(trim + 1) - 1 : CONVERT_SURFACEMODE(trim + 1) - 1; int value = model->getTrimValue(phaseIdx, chn); trimsSlider[trim]->setValue(value); trimsValue[trim]->setValue(value); @@ -496,7 +509,7 @@ void FlightModePanel::phaseGVUse_currentIndexChanged(int index) phase.gvars[gvar] = GVAR_MAX_VALUE + index; } if (model->isGVarLinkedCircular(phaseIdx, gvar)) - QMessageBox::warning(this, "Companion", tr("Warning: Global variable links back to itself. Flight Mode 0 value used.")); + QMessageBox::warning(this, "Companion", tr("Warning: Global variable links back to itself. %1 Mode 0 value used.").arg(radioType)); updateGVar(gvar); emit modified(); lock = false; @@ -605,7 +618,7 @@ void FlightModePanel::phaseREUse_currentIndexChanged(int index) } update(); if (model->isREncLinkedCircular(phaseIdx, re)) - QMessageBox::warning(this, "Companion", tr("Warning: Rotary encoder links back to itself. Flight Mode 0 value used.")); + QMessageBox::warning(this, "Companion", tr("Warning: Rotary encoder links back to itself. %1 Mode 0 value used.").arg(radioType)); emit modified(); lock = false; } @@ -616,7 +629,7 @@ void FlightModePanel::phaseTrimUse_currentIndexChanged(int index) if (!lock) { QComboBox *comboBox = qobject_cast(sender()); int trim = comboBox->property("index").toInt(); - int chn = CONVERT_MODE(trim + 1) - 1; + int chn = Boards::isAir(board) ? CONVERT_AIRMODE(trim + 1) - 1 : CONVERT_SURFACEMODE(trim + 1) - 1; int data = comboBox->itemData(index).toInt(); if (data < 0) { phase.trimMode[chn] = -1; @@ -648,7 +661,7 @@ void FlightModePanel::phaseTrim_valueChanged() if (!lock) { QSpinBox *spinBox = qobject_cast(sender()); int trim = spinBox->property("index").toInt(); - int chn = CONVERT_MODE(trim + 1) - 1; + int chn = Boards::isAir(board) ? CONVERT_AIRMODE(trim + 1) - 1 : CONVERT_SURFACEMODE(trim + 1) - 1; int value = spinBox->value(); model->setTrimValue(phaseIdx, chn, value); lock = true; @@ -663,7 +676,7 @@ void FlightModePanel::phaseTrimSlider_valueChanged() if (!lock) { QSlider *slider = qobject_cast(sender()); int trim = slider->property("index").toInt(); - int chn = CONVERT_MODE(trim + 1) - 1; + int chn = Boards::isAir(board) ? CONVERT_AIRMODE(trim + 1) - 1 : CONVERT_SURFACEMODE(trim + 1) - 1; int value = slider->value(); model->setTrimValue(phaseIdx, chn, value); lock = true; @@ -724,7 +737,7 @@ bool FlightModePanel::moveUpAllowed() const void FlightModePanel::cmClear(bool prompt) { if (prompt) { - if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Flight Mode. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear %1 Mode. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; } @@ -761,7 +774,7 @@ void FlightModePanel::cmClear(bool prompt) void FlightModePanel::cmClearAll() { - if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; for (int j = 0; j < fmCount; j++) { @@ -796,7 +809,7 @@ void FlightModePanel::cmCopy() void FlightModePanel::cmCut() { - if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut Flight Mode. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut %1 Mode. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; cmCopy(); cmClear(false); @@ -804,7 +817,7 @@ void FlightModePanel::cmCut() void FlightModePanel::cmDelete() { - if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete Flight Mode. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete %1 Mode. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; const int maxidx = fmCount - 1; @@ -1160,7 +1173,7 @@ void FlightModePanel::gvCmClear(bool prompt) { if (phaseIdx == 0) { if (prompt) { - if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Global Variable across all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Global Variable across all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; } model->gvarData[gvIdx].clear(); @@ -1184,7 +1197,7 @@ void FlightModePanel::gvCmClear(bool prompt) void FlightModePanel::gvCmClearAll() { if (phaseIdx == 0) { - if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Global Variables for all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Global Variables for all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; for (int i = 0; i < gvCount; i++) { model->gvarData[i].clear(); @@ -1195,7 +1208,7 @@ void FlightModePanel::gvCmClearAll() } } else { - if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Global Variables for this Flight Mode. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Global Variables for this %1 Mode. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; for (int i = 0; i < gvCount; i++) { phase.gvars[i] = phase.linkedGVarFlightModeZero(phaseIdx); @@ -1247,7 +1260,7 @@ void FlightModePanel::gvCmCopy() void FlightModePanel::gvCmCut() { if (phaseIdx == 0) { - if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut Global Variable across all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut Global Variable across all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; } else { @@ -1325,7 +1338,7 @@ void FlightModePanel::gvCmPaste() { QByteArray data; if (phaseIdx == 0) { - if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Paste to selected Global Variable across all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Paste to selected Global Variable across all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; if (gvHasDefnClipboardData(&data)) { memcpy(&model->gvarData[gvIdx], data.constData(), sizeof(GVarData)); @@ -1391,6 +1404,18 @@ void FlightModePanel::onItemModelUpdateComplete() lock = false; } +void FlightModePanel::onThrottleReverseChanged() +{ + for (int i = 0; i < CPN_MAX_TRIMS; i++) { + int chn = Boards::isAir(board) ? CONVERT_AIRMODE(i + 1) - 1 : CONVERT_SURFACEMODE(i + 1) - 1; + if (model->throttleReversed && ((Boards::isAir(board) && chn == 2/*TODO constant*/) || + (Boards::isSurface(board) && chn == 1/*TODO constant*/))) + trimsSlider[i]->setInvertedAppearance(true); + else + trimsSlider[i]->setInvertedAppearance(false); + } +} + /**********************************************************/ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, @@ -1402,11 +1427,13 @@ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralS connectItemModelEvents(rawSwitchFilteredModel); modesCount = firmware->getCapability(FlightModes); + radioType = Boards::getRadioTypeString(firmware->getBoard()); QGridLayout * gridLayout = new QGridLayout(this); tabWidget = new QTabWidget(this); + for (int i = 0; i < modesCount; i++) { - FlightModePanel * tab = new FlightModePanel(tabWidget, model, i, generalSettings, firmware, rawSwitchFilteredModel); + FlightModePanel * tab = new FlightModePanel(tabWidget, model, i, generalSettings, firmware, rawSwitchFilteredModel, radioType); tab->setProperty("index", i); connect(tab, &FlightModePanel::modified, this, &FlightModesPanel::modified); connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::onPhaseNameChanged); @@ -1414,10 +1441,12 @@ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralS connect(tab, &FlightModePanel::phaseSwitchChanged, this, &FlightModesPanel::updateItemModels); connect(tab, &FlightModePanel::gvNameChanged, this, &FlightModesPanel::updateItemModels); - connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update); + connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update); + connect(this, &FlightModesPanel::refreshThrottleTrim, tab, &FlightModePanel::onThrottleReverseChanged); tabWidget->addTab(tab, getTabName(i)); panels << tab; } + connect(tabWidget, &QTabWidget::currentChanged, this, &FlightModesPanel::onTabIndexChanged); gridLayout->addWidget(tabWidget, 0, 0, 1, 1); onTabIndexChanged(0); @@ -1430,7 +1459,7 @@ FlightModesPanel::~FlightModesPanel() QString FlightModesPanel::getTabName(int index) { - QString result = tr("Flight Mode %1").arg(index); + QString result = tr("%1 Mode %2").arg(radioType).arg(index); const char *name = model->flightModeData[index].name; if (firmware->getCapability(FlightModesName) && strlen(name) > 0) { result += tr(" (%1)").arg(name); @@ -1479,3 +1508,8 @@ void FlightModesPanel::onTabIndexChanged(int index) if (index < panels.size()) panels.at(index)->update(); } + +void FlightModesPanel::onThrottleReverseChanged() +{ + emit refreshThrottleTrim(); +} diff --git a/companion/src/modeledit/flightmodes.h b/companion/src/modeledit/flightmodes.h index ea723f0b3d9..11e7d5afe38 100644 --- a/companion/src/modeledit/flightmodes.h +++ b/companion/src/modeledit/flightmodes.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _FLIGHTMODES_H_ -#define _FLIGHTMODES_H_ +#pragma once #include "modeledit.h" #include "eeprominterface.h" @@ -43,7 +42,7 @@ class FlightModePanel : public ModelPanel public: FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware, - FilteredItemModel * rawSwitchFilteredModel); + FilteredItemModel * rawSwitchFilteredModel, QString radioType); virtual ~FlightModePanel(); virtual void update(); @@ -54,6 +53,9 @@ class FlightModePanel : public ModelPanel void phaseNameChanged(); void phaseSwitchChanged(); + public slots: + void onThrottleReverseChanged(); + private slots: void phaseName_editingFinished(); void phaseSwitch_currentIndexChanged(int index); @@ -119,6 +121,7 @@ class FlightModePanel : public ModelPanel QVector trimsValue; QVector trimsSlider; Board::Type board; + QString radioType; void trimUpdate(unsigned int trim); void updateGVar(int index); @@ -141,6 +144,7 @@ class FlightModePanel : public ModelPanel bool gvMoveUpAllowed() const; void gvSwapData(int idx1, int idx2); void connectItemModelEvents(const FilteredItemModel * itemModel); + void populateGvarUseCB(QComboBox *b, unsigned int phase); }; class FlightModesPanel : public ModelPanel @@ -153,9 +157,11 @@ class FlightModesPanel : public ModelPanel public slots: virtual void update() override; + void onThrottleReverseChanged(); signals: void updated(); + void refreshThrottleTrim(); private slots: void onPhaseNameChanged(); @@ -171,9 +177,8 @@ class FlightModesPanel : public ModelPanel CompoundItemModelFactory *sharedItemModels; FilteredItemModel *rawSwitchFilteredModel; QVector panels; + QString radioType; + void updateItemModels(); void connectItemModelEvents(const FilteredItemModel * itemModel); }; - -#endif // _FLIGHTMODES_H_ - diff --git a/companion/src/modeledit/mixerdialog.ui b/companion/src/modeledit/mixerdialog.ui index c8a886dfdd8..478b6b90f87 100644 --- a/companion/src/modeledit/mixerdialog.ui +++ b/companion/src/modeledit/mixerdialog.ui @@ -275,7 +275,7 @@ - Flight modes + Modes diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index ff8be1381fe..deb753d45dc 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -72,7 +72,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw s1.report("Init"); - SetupPanel * setupPanel = new SetupPanel(this, model, generalSettings, firmware, sharedItemModels); + SetupPanel *setupPanel = new SetupPanel(this, model, generalSettings, firmware, sharedItemModels); addTab(setupPanel, tr("Setup")); s1.report("Setup"); @@ -81,8 +81,10 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw s1.report("Heli"); } - addTab(new FlightModesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Flight Modes")); - s1.report("Flight Modes"); + QString radioType = QString("%1 Modes").arg(Boards::getRadioTypeString(firmware->getBoard())); + FlightModesPanel *flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, sharedItemModels); + addTab(flightModesPanel, radioType); + s1.report(radioType); addTab(new InputsPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Inputs")); s1.report("Inputs"); @@ -90,7 +92,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw addTab(new MixesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Mixes")); s1.report("Mixes"); - ChannelsPanel * channelsPanel = new ChannelsPanel(this, model, generalSettings, firmware, sharedItemModels); + ChannelsPanel *channelsPanel = new ChannelsPanel(this, model, generalSettings, firmware, sharedItemModels); addTab(channelsPanel, tr("Outputs")); s1.report("Outputs"); @@ -121,6 +123,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw s1.report("Enabled Features"); connect(setupPanel, &SetupPanel::extendedLimitsToggled, channelsPanel, &ChannelsPanel::refreshExtendedLimits); + connect(setupPanel, &SetupPanel::throttleReverseChanged, flightModesPanel, &FlightModesPanel::onThrottleReverseChanged); connect(ui->tabWidget, &QTabWidget::currentChanged, this, &ModelEdit::onTabIndexChanged); connect(ui->pushButton, &QPushButton::clicked, this, &ModelEdit::launchSimulation); diff --git a/companion/src/modeledit/modeloptions.cpp b/companion/src/modeledit/modeloptions.cpp index 1602d236fc8..5029cdcc472 100644 --- a/companion/src/modeledit/modeloptions.cpp +++ b/companion/src/modeledit/modeloptions.cpp @@ -82,7 +82,7 @@ ModelOptionsPanel::ModelOptionsPanel(QWidget * parent, ModelData & model, Genera addParams(); } - addLabel(tr("Flight Modes")); + addLabel(tr("%1 Modes").arg(Boards::getRadioTypeString(firmware->getBoard()))); AutoComboBox *fmDisable = new AutoComboBox(this); fmDisable->setModel(mdl); fmDisable->setField(model.modelFMDisabled, this); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index ef5f59d5ee3..5ed52cd23b4 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -1872,6 +1872,7 @@ void SetupPanel::on_customThrottleWarningPosition_valueChanged(int value) void SetupPanel::on_throttleReverse_toggled(bool checked) { model->throttleReversed = checked; + emit throttleReverseChanged(); emit modified(); } @@ -1935,18 +1936,29 @@ void SetupPanel::on_image_currentIndexChanged(int index) void SetupPanel::populateThrottleTrimSwitchCB() { Board::Type board = firmware->getBoard(); + bool isBoardSurface = Boards::isSurface(board); lock = true; ui->throttleTrimSwitch->clear(); - int idx=0; + int idx = 0; QString trim; - for (int i=0; ithrottleTrimSwitch->addItem(trim, idx); } diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index 14d5cb70b3a..0916ac191f4 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -292,6 +292,7 @@ class SetupPanel : public ModelPanel signals: void extendedLimitsToggled(); void updated(); + void throttleReverseChanged(); private slots: void on_name_editingFinished(); diff --git a/companion/src/shared/genericpanel.cpp b/companion/src/shared/genericpanel.cpp index 4b2c030eee3..de86f6d6a82 100644 --- a/companion/src/shared/genericpanel.cpp +++ b/companion/src/shared/genericpanel.cpp @@ -34,6 +34,7 @@ GenericPanel::GenericPanel(QWidget * parent, ModelData * model, GeneralSettings model(model), generalSettings(generalSettings), firmware(firmware), + //board(firmware->getBoard()), TODO: as part of capabilities refactor lock(false) { } diff --git a/companion/src/shared/genericpanel.h b/companion/src/shared/genericpanel.h index 66412835426..d0d62ba96c7 100644 --- a/companion/src/shared/genericpanel.h +++ b/companion/src/shared/genericpanel.h @@ -50,7 +50,9 @@ class GenericPanel : public QWidget ModelData * model; GeneralSettings & generalSettings; Firmware * firmware; + //Board::Type board; TODO: as part of refactor to move physical capabilities from Firmware to Boards bool lock; + void addLabel(QGridLayout * gridLayout, const QString &text, int col, bool mimimize=false); void addEmptyLabel(QGridLayout * gridLayout, int col); void addHSpring(QGridLayout *, int col, int row); diff --git a/companion/src/simulation/CMakeLists.txt b/companion/src/simulation/CMakeLists.txt index a05e28668e4..661f4228ef7 100644 --- a/companion/src/simulation/CMakeLists.txt +++ b/companion/src/simulation/CMakeLists.txt @@ -49,6 +49,7 @@ set(${PROJECT_NAME}_SRCS simulateduiwidgetJumperTPRO.cpp simulateduiwidgetJumperTPROS.cpp simulateduiwidgetLR3PRO.cpp + simulateduiwidgetMT12.cpp simulateduiwidgetNV14.cpp simulateduiwidgetPL18.cpp simulateduiwidgetPocket.cpp @@ -70,6 +71,7 @@ set(${PROJECT_NAME}_SRCS set(${PROJECT_NAME}_HDRS ${${PROJECT_NAME}_HDRS} radiouiaction.h + simulateduiwidgetGeneric.h widgets/buttonswidget.h widgets/radiofaderwidget.h widgets/radiokeywidget.h @@ -84,6 +86,11 @@ qt5_wrap_cpp(${PROJECT_NAME}_SRCS ${${PROJECT_NAME}_HDRS} ) +# AUTOUIC does not detect as ui in .h so manually process +qt5_wrap_ui(${PROJECT_NAME}_SRCS + simulateduiwidgetGeneric.ui +) + add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SRCS} ) diff --git a/companion/src/simulation/debugoutput.h b/companion/src/simulation/debugoutput.h index d5246ac2430..d6b9560bea7 100644 --- a/companion/src/simulation/debugoutput.h +++ b/companion/src/simulation/debugoutput.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _DEBUGOUTPUT_H_ -#define _DEBUGOUTPUT_H_ +#pragma once #include "simulator.h" #include "simulatorinterface.h" @@ -107,6 +106,3 @@ class DeleteComboBoxItemEventFilter : public QObject protected: bool eventFilter(QObject *obj, QEvent *event); }; - -#endif // _DEBUGOUTPUT_H_ - diff --git a/companion/src/simulation/filteredtextbuffer.h b/companion/src/simulation/filteredtextbuffer.h index 09281a6f6b9..5411f2e88b3 100644 --- a/companion/src/simulation/filteredtextbuffer.h +++ b/companion/src/simulation/filteredtextbuffer.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef FILTEREDTEXTBUFFER_H -#define FILTEREDTEXTBUFFER_H +#pragma once #include #include @@ -117,6 +116,3 @@ class FilteredTextBuffer : public FIFOBufferDevice bool m_lineFilterEnable; bool m_lineFilterExclusive; }; - - -#endif // FILTEREDTEXTBUFFER_H diff --git a/companion/src/simulation/joystick.h b/companion/src/simulation/joystick.h index 47e5e60aa78..d9a46a42656 100644 --- a/companion/src/simulation/joystick.h +++ b/companion/src/simulation/joystick.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _JOYSTICK_H_ -#define _JOYSTICK_H_ +#pragma once #include #include @@ -82,5 +81,3 @@ class Joystick : public QObject public slots: void processEvents(); }; - -#endif // _JOYSTICK_H_ diff --git a/companion/src/simulation/joystickdialog.h b/companion/src/simulation/joystickdialog.h index 141c4bb7df7..eac62806718 100644 --- a/companion/src/simulation/joystickdialog.h +++ b/companion/src/simulation/joystickdialog.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _JOYSTICKDIALOG_H_ -#define _JOYSTICKDIALOG_H_ +#pragma once #include #include "appdata.h" @@ -79,5 +78,3 @@ class joystickDialog : public QDialog void on_okButton_clicked(); }; - -#endif // _JOYSTICKDIALOG_H_ diff --git a/companion/src/simulation/radiooutputswidget.cpp b/companion/src/simulation/radiooutputswidget.cpp index 74f109f1526..1a4b2977168 100644 --- a/companion/src/simulation/radiooutputswidget.cpp +++ b/companion/src/simulation/radiooutputswidget.cpp @@ -222,9 +222,10 @@ void RadioOutputsWidget::setupGVarsDisplay() ui->globalVarsScroll->setWidget(gvarsWidget); QPalette::ColorRole bgrole = QPalette::AlternateBase; + const bool isAir = Boards::isAir(); for (int fm=0; fm < fmodes; fm++) { QLabel * label = new QLabel(gvarsWidget); - label->setText(QString(tr("FM%1")).arg(fm)); + label->setText(QString("%1%2").arg(isAir ? tr("FM") : tr("DM")).arg(fm)); label->setAlignment(Qt::AlignCenter); label->setBackgroundRole(bgrole); gvarsLayout->addWidget(label, 0, fm+1); diff --git a/companion/src/simulation/radiooutputswidget.h b/companion/src/simulation/radiooutputswidget.h index 8bdd9c584b9..b9dabefaaf5 100644 --- a/companion/src/simulation/radiooutputswidget.h +++ b/companion/src/simulation/radiooutputswidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef RADIOOUTPUTSWIDGET_H -#define RADIOOUTPUTSWIDGET_H +#pragma once #include "simulator.h" #include "simulatorinterface.h" @@ -86,5 +85,3 @@ class RadioOutputsWidget : public QWidget private: Ui::RadioOutputsWidget * ui; }; - -#endif // RADIOOUTPUTSWIDGET_H diff --git a/companion/src/simulation/radiouiaction.h b/companion/src/simulation/radiouiaction.h index caa8981e14a..fa6909dbb6c 100644 --- a/companion/src/simulation/radiouiaction.h +++ b/companion/src/simulation/radiouiaction.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef RADIOUIACTION_H -#define RADIOUIACTION_H +#pragma once #include #include @@ -43,7 +42,7 @@ class RadioUiAction : public QObject * @param text Optional title for this action. The text and description are currently used in generated help text. * @param descript Optional longer description text for this action. */ - RadioUiAction(int index = -1, int key = 0, const QString &text = "", const QString &descript = "", QWidget * parent = NULL): + RadioUiAction(int index = -1, int key = 0, const QString &text = "", const QString &descript = "", QWidget * parent = nullptr): m_hwIndex(index), m_active(false), m_keys(QList()), @@ -57,7 +56,7 @@ class RadioUiAction : public QObject * @param keys QList of Qt:Key codes to use as shortcuts. * [See above for other params.] */ - RadioUiAction(int index, QList keys, const QString &text = "", const QString &descript = "", QWidget * parent = NULL): + RadioUiAction(int index, QList keys, const QString &text = "", const QString &descript = "", QWidget * parent = nullptr): RadioUiAction(index, 0, text, descript, parent) { addKeys(keys); @@ -165,15 +164,3 @@ class RadioUiAction : public QObject void pushed(int index); // only emitted on user interaction && when 'active' is true void pushed(); }; - -#endif // RADIOUIACTION_H - - - - - - - - - - diff --git a/companion/src/simulation/simulateduiwidget.cpp b/companion/src/simulation/simulateduiwidget.cpp index f8aab65a8df..b05f0daec59 100644 --- a/companion/src/simulation/simulateduiwidget.cpp +++ b/companion/src/simulation/simulateduiwidget.cpp @@ -25,6 +25,10 @@ #include "radiouiaction.h" #include "radiokeywidget.h" #include "simulatorinterface.h" +#include "buttonswidget.h" + +#include +#include //#define FLASH_DURATION 10 //#define CBEEP_ON "QLabel { background-color: #FF364E }" @@ -34,11 +38,11 @@ SimulatedUIWidget::SimulatedUIWidget(SimulatorInterface * simulator, QWidget * p QWidget(parent), m_simulator(simulator), m_parent(parent), - m_lcd(NULL), - m_scrollUpAction(NULL), - m_scrollDnAction(NULL), - m_mouseMidClickAction(NULL), - m_screenshotAction(NULL), + m_lcd(nullptr), + m_scrollUpAction(nullptr), + m_scrollDnAction(nullptr), + m_mouseMidClickAction(nullptr), + m_screenshotAction(nullptr), m_board(getCurrentBoard()), m_backLight(0), m_beepShow(0), @@ -191,11 +195,11 @@ void SimulatedUIWidget::mouseReleaseEvent(QMouseEvent * event) void SimulatedUIWidget::setLcd(LcdWidget * lcd) { m_lcd = lcd; - Firmware * firmware = getCurrentFirmware(); + Board::Type board = getCurrentBoard(); - auto width = firmware->getCapability(LcdWidth); - auto height = firmware->getCapability(LcdHeight); - auto depth = firmware->getCapability(LcdDepth); + auto width = Boards::getCapability(board, Board::LcdWidth); + auto height = Boards::getCapability(board, Board::LcdHeight); + auto depth = Boards::getCapability(board, Board::LcdDepth); m_lcd->setData(width, height, depth); if (!m_backlightColors.size()) @@ -227,3 +231,141 @@ void SimulatedUIWidget::connectScrollActions() }); } } + +// static +int SimulatedUIWidget::strKeyToInt(std::string key) +{ + QStringList keys = { + "KEY_MENU", + "KEY_EXIT", + "KEY_ENTER", + "KEY_PAGEUP", + "KEY_PAGEDN", + "KEY_UP", + "KEY_DOWN", + "KEY_LEFT", + "KEY_RIGHT", + "KEY_PLUS", + "KEY_MINUS", + "KEY_MODEL", + "KEY_TELE", + "KEY_SYS", + "KEY_SHIFT", + "KEY_BIND" + }; + + return keys.indexOf(key.c_str()); +} + +void SimulatedUIWidget::addScrollActions() +{ + // Note: the keys cannot duplicate those used for radio buttons + m_scrollUpAction = new RadioUiAction(-1, QList() << Qt::Key_Minus, + SIMU_STR_HLP_KEY_MIN % "|" % SIMU_STR_HLP_MOUSE_UP, SIMU_STR_HLP_ACT_ROT_LFT); + m_scrollDnAction = new RadioUiAction(-1, QList() << Qt::Key_Plus << Qt::Key_Equal, + SIMU_STR_HLP_KEY_PLS % "|" % SIMU_STR_HLP_MOUSE_DN, SIMU_STR_HLP_ACT_ROT_RGT); + connectScrollActions(); +} + +void SimulatedUIWidget::addMouseActions() +{ + m_mouseMidClickAction = new RadioUiAction(KEY_ENTER, QList() << Qt::Key_Enter << Qt::Key_Return, + SIMU_STR_HLP_KEYS_ACTIVATE, SIMU_STR_HLP_ACT_ROT_DN); +} + +// Notes: unused rows will be hidden and squashed +// keys cannot duplicate those used for scrolling tefer m_mouseMidClickAction +static const QList genericKeyDefinitions = { + { KEY_SYS, 'R', 0, 0, QList() << Qt::Key_Left, SIMU_STR_HLP_KEY_LFT, SIMU_STR_HLP_ACT_SYS }, + + { KEY_MODEL, 'R', 0, 1, QList() << Qt::Key_Up, SIMU_STR_HLP_KEY_UP, SIMU_STR_HLP_ACT_MDL }, + + { KEY_PAGEUP, 'R', 1, 0, QList() << Qt::Key_PageUp, SIMU_STR_HLP_KEY_PGUP, SIMU_STR_HLP_ACT_PGUP }, + + { KEY_PAGEDN, 'R', 1, 1, QList() << Qt::Key_PageDown, SIMU_STR_HLP_KEY_PGDN, SIMU_STR_HLP_ACT_PGDN }, + + { KEY_UP, 'R', 2, 0, QList() << Qt::Key_Up + << Qt::Key_PageUp, SIMU_STR_HLP_KEYS_GO_UP, SIMU_STR_HLP_ACT_UP }, + + { KEY_DOWN, 'R', 2, 1, QList() << Qt::Key_Down + << Qt::Key_PageDown, SIMU_STR_HLP_KEYS_GO_DN, SIMU_STR_HLP_ACT_DN }, + + { KEY_LEFT, 'R', 3, 0, QList() << Qt::Key_Left + << Qt::Key_Minus, SIMU_STR_HLP_KEY_LFT % "|" % SIMU_STR_HLP_KEY_MIN, SIMU_STR_HLP_ACT_MIN }, + + { KEY_RIGHT, 'R', 3, 1, QList() << Qt::Key_Right + << Qt::Key_Plus, SIMU_STR_HLP_KEY_RGT % "|" % SIMU_STR_HLP_KEY_PLS, SIMU_STR_HLP_ACT_PLS }, + + { KEY_MINUS, 'R', 4, 0, QList() << Qt::Key_Minus + << Qt::Key_Right, SIMU_STR_HLP_KEY_RGT % "|" % SIMU_STR_HLP_KEY_MIN % "|" % SIMU_STR_HLP_MOUSE_DN, SIMU_STR_HLP_ACT_MIN }, + + { KEY_PLUS, 'R', 4, 1, QList() << Qt::Key_Plus + << Qt::Key_Equal + << Qt::Key_Left, SIMU_STR_HLP_KEY_LFT % "|" % SIMU_STR_HLP_KEY_PLS % "|" % SIMU_STR_HLP_MOUSE_UP, SIMU_STR_HLP_ACT_PLS }, + + { KEY_TELE, 'R', 5, 1, QList() << Qt::Key_Right, SIMU_STR_HLP_KEY_RGT, SIMU_STR_HLP_ACT_TELE }, + + { KEY_MENU, 'R', 6, 0, QList() << Qt::Key_Up + << Qt::Key_PageUp, SIMU_STR_HLP_KEYS_GO_UP, SIMU_STR_HLP_ACT_MENU }, + + { KEY_SHIFT, 'R', 6, 1, QList() << Qt::Key_S, SIMU_STR_HLP_KEY_SHIFT, SIMU_STR_HLP_ACT_SHIFT }, + + { KEY_EXIT, 'R', 7, 0, QList() << Qt::Key_Down + << Qt::Key_Delete + << Qt::Key_Escape + << Qt::Key_Backspace, SIMU_STR_HLP_KEYS_EXIT, SIMU_STR_HLP_ACT_EXIT }, + + { KEY_ENTER, 'R', 7, 1, QList() << Qt::Key_Enter + << Qt::Key_Return, SIMU_STR_HLP_KEYS_ACTIVATE, SIMU_STR_HLP_ACT_ROT_DN }, +}; + +void SimulatedUIWidget::addGenericPushButtons(ButtonsWidget * leftButtons, ButtonsWidget * rightButtons) +{ + QGridLayout * leftButtonsGrid = new QGridLayout(); + QGridLayout * rightButtonsGrid = new QGridLayout(); + + for (int i = 0; i < Boards::getCapability(m_board, Board::Keys); i++) { + Board::KeyInfo info = Boards::getKeyInfo(i, m_board); + int idx = strKeyToInt(info.key); + //qDebug() << "key:" << info.key.c_str() << info.name.c_str() << info.label.c_str() << idx; + if (idx >= 0) + addGenericPushButton(idx, info.label.c_str(), leftButtons, leftButtonsGrid, rightButtons, rightButtonsGrid); + else + qDebug() << "Unknown key:" << info.key.c_str() << info.name.c_str() << info.label.c_str(); + } + + QGridLayout * gridLeft = new QGridLayout((QWidget *)leftButtons); + gridLeft->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0); + gridLeft->addLayout(leftButtonsGrid, 0, 1); + //gridLeft->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2); + + QGridLayout * gridRight = new QGridLayout((QWidget *)rightButtons); + //gridRight->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0); + gridRight->addLayout(rightButtonsGrid, 0, 1); + gridRight->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2); +} + +void SimulatedUIWidget::addGenericPushButton(int index, QString label, ButtonsWidget * leftButtons, QGridLayout * leftButtonsGrid, + ButtonsWidget * rightButtons, QGridLayout * rightButtonsGrid) +{ + if (index >= genericKeyDefinitions.size()) + return; + + for (int i = 0; i < genericKeyDefinitions.size(); i++) { + const GenericKeyDefinition defn = genericKeyDefinitions.at(i); + + if (defn.index == index) { + QPushButton * b = new QPushButton(label); + b->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + b->setMinimumSize(60, 30); + b->setMaximumSize(60, 30); + RadioUiAction * act = new RadioUiAction(); + ButtonsWidget * btns = defn.side == 'L' ? leftButtons : rightButtons; + QGridLayout * grid = defn.side == 'L' ? leftButtonsGrid : rightButtonsGrid; + grid->addWidget(b, defn.gridRow, defn.gridCol); + act = new RadioUiAction(defn.index, defn.keys, defn.helpKeys, defn.helpActions); + addRadioWidget(btns->addPushButton(b, act)); + break; + } + } +} diff --git a/companion/src/simulation/simulateduiwidget.h b/companion/src/simulation/simulateduiwidget.h index 39f96f4f530..29df48e068e 100644 --- a/companion/src/simulation/simulateduiwidget.h +++ b/companion/src/simulation/simulateduiwidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef SIMULATEDUIWIDGET_H -#define SIMULATEDUIWIDGET_H +#pragma once #include "boards.h" #include "constants.h" @@ -35,6 +34,8 @@ class SimulatorInterface; class LcdWidget; class RadioKeyWidget; class RadioUiAction; +class ButtonsWidget; +class QPushButton; // Match with /radio/src/hal/key_driver.h enum EnumKeys { @@ -64,6 +65,23 @@ enum EnumKeys { MAX_KEYS }; +struct GenericKeyDefinition { + int index = 0; + QChar side = 'L'; + int gridRow = 0; + int gridCol = 0; + QList keys = QList(); + QString helpKeys = ""; + QString helpActions = ""; + + GenericKeyDefinition(int index, QChar side, int gridRow, int gridCol, + QList keys, QString helpKeys, QString helpActions) : + index(index), side(side), gridRow(gridRow), gridCol(gridCol), + keys(keys), helpKeys(helpKeys), helpActions(helpActions) {} + + GenericKeyDefinition() = default; +}; + /* * This is a base class for the main hardware-specific radio user interface, including LCD screen and navigation buttons/widgets. * It is responsible for hanlding all interactions with this part of the simulation (vs. common radio widgets like sticks/switches/knobs). @@ -126,11 +144,20 @@ class SimulatedUIWidget : public QWidget unsigned int m_backLight; int m_beepShow; int m_beepVal; + + static int strKeyToInt(std::string key); + + void addGenericPushButton(int index, QString label, ButtonsWidget * leftButtons, QGridLayout * leftButtonsGrid, + ButtonsWidget * rightButtons, QGridLayout * rightButtonsGrid); + void addGenericPushButtons(ButtonsWidget * leftButtons, ButtonsWidget * rightButtons); + void addScrollActions(); + void addMouseActions(); }; // Each subclass is responsible for its own Ui namespace Ui { + class SimulatedUIWidgetGeneric; class SimulatedUIWidget9X; class SimulatedUIWidgetX9LITE; class SimulatedUIWidgetX7; @@ -156,6 +183,7 @@ namespace Ui { class SimulatedUIWidgetTX12; class SimulatedUIWidgetZorro; class SimulatedUIWidgetBoxer; + class SimulatedUIWidgetMT12; class SimulatedUIWidgetPocket; class SimulatedUIWidgetT8; class SimulatedUIWidgetFatfishF16; @@ -165,6 +193,19 @@ namespace Ui { class SimulatedUIWidgetV16; } +class SimulatedUIWidgetGeneric: public SimulatedUIWidget +{ + Q_OBJECT + + public: + explicit SimulatedUIWidgetGeneric(SimulatorInterface * simulator, QWidget * parent = nullptr); + virtual ~SimulatedUIWidgetGeneric(); + + private: + Ui::SimulatedUIWidgetGeneric * ui; + +}; + class SimulatedUIWidget9X: public SimulatedUIWidget { Q_OBJECT @@ -469,6 +510,15 @@ class SimulatedUIWidgetBoxer: public SimulatedUIWidget Ui::SimulatedUIWidgetBoxer * ui; }; +class SimulatedUIWidgetMT12: public SimulatedUIWidgetGeneric +{ + Q_OBJECT + + public: + explicit SimulatedUIWidgetMT12(SimulatorInterface * simulator, QWidget * parent = nullptr); + virtual ~SimulatedUIWidgetMT12(); +}; + class SimulatedUIWidgetPocket: public SimulatedUIWidget { Q_OBJECT @@ -552,5 +602,3 @@ class SimulatedUIWidgetV16: public SimulatedUIWidget private: Ui::SimulatedUIWidgetV16 * ui; }; - -#endif // SIMULATEDUIWIDGET_H diff --git a/companion/src/simulation/simulateduiwidgetBoxer.cpp b/companion/src/simulation/simulateduiwidgetBoxer.cpp index 877d22e8a4e..47e2c81909f 100644 --- a/companion/src/simulation/simulateduiwidgetBoxer.cpp +++ b/companion/src/simulation/simulateduiwidgetBoxer.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetBoxer.h" diff --git a/companion/src/simulation/simulateduiwidgetCommando8.cpp b/companion/src/simulation/simulateduiwidgetCommando8.cpp index f04fed2ed61..3856a38d2f8 100644 --- a/companion/src/simulation/simulateduiwidgetCommando8.cpp +++ b/companion/src/simulation/simulateduiwidgetCommando8.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetCommando8.h" diff --git a/companion/src/simulation/simulateduiwidgetFatfishF16.cpp b/companion/src/simulation/simulateduiwidgetFatfishF16.cpp index a4eb59c07dd..bdda7580cfb 100644 --- a/companion/src/simulation/simulateduiwidgetFatfishF16.cpp +++ b/companion/src/simulation/simulateduiwidgetFatfishF16.cpp @@ -19,7 +19,6 @@ * GNU General Public License for more details. */ - #include "simulateduiwidget.h" #include "ui_simulateduiwidgetFatfishF16.h" diff --git a/companion/src/simulation/simulateduiwidgetGeneric.h b/companion/src/simulation/simulateduiwidgetGeneric.h new file mode 100644 index 00000000000..8c31d510ac5 --- /dev/null +++ b/companion/src/simulation/simulateduiwidgetGeneric.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#pragma once + +#include "simulateduiwidget.h" +#include "ui_simulateduiwidgetGeneric.h" + +/* + Note: This class is not expected to be instantiated directly but as the base for each firmware that uses it + due to the methods and functions surrounding the building and loading of radio simulators +*/ + +SimulatedUIWidgetGeneric::SimulatedUIWidgetGeneric(SimulatorInterface *simulator, QWidget * parent): + SimulatedUIWidget(simulator, parent), + ui(new Ui::SimulatedUIWidgetGeneric) +{ + ui->setupUi(this); + + addGenericPushButtons(ui->leftbuttons, ui->rightbuttons); + + addScrollActions(); + + setLcd(ui->lcd); +} + +SimulatedUIWidgetGeneric::~SimulatedUIWidgetGeneric() +{ + delete ui; +} diff --git a/companion/src/simulation/simulateduiwidgetGeneric.ui b/companion/src/simulation/simulateduiwidgetGeneric.ui new file mode 100644 index 00000000000..c52ad39e79d --- /dev/null +++ b/companion/src/simulation/simulateduiwidgetGeneric.ui @@ -0,0 +1,210 @@ + + + SimulatedUIWidgetGeneric + + + + 0 + 0 + 737 + 246 + + + + + 0 + 0 + + + + + 737 + 246 + + + + + 737 + 246 + + + + Generic Simulator + + + + + + + true + + + + 0 + 0 + 241 + 246 + + + + + 0 + 0 + + + + + 241 + 246 + + + + + 241 + 246 + + + + + + + + + + 496 + 0 + 241 + 246 + + + + + 0 + 0 + + + + + 241 + 246 + + + + + 241 + 246 + + + + + + + 241 + 188 + 255 + 58 + + + + + 0 + 0 + + + + + 255 + 58 + + + + + 255 + 58 + + + + + + + 240 + 59 + 256 + 128 + + + + + 0 + 0 + + + + + 200 + 100 + + + + + 424 + 180 + + + + background-color: rgb(215, 243, 255); + + + + + + 241 + 0 + 255 + 59 + + + + + 0 + 0 + + + + + 255 + 59 + + + + + 255 + 59 + + + + bottom + top + rightbuttons + leftbuttons + lcd + + + + LcdWidget + QWidget +
lcdwidget.h
+ 1 +
+ + ButtonsWidget + QWidget +
buttonswidget.h
+ 1 +
+
+ + + + +
diff --git a/companion/src/simulation/simulateduiwidgetJumperT12.cpp b/companion/src/simulation/simulateduiwidgetJumperT12.cpp index 129d8be48d2..22bc9d1c74b 100644 --- a/companion/src/simulation/simulateduiwidgetJumperT12.cpp +++ b/companion/src/simulation/simulateduiwidgetJumperT12.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetJumperT12.h" diff --git a/companion/src/simulation/simulateduiwidgetJumperT14.cpp b/companion/src/simulation/simulateduiwidgetJumperT14.cpp index fad5f407919..07d86029d74 100644 --- a/companion/src/simulation/simulateduiwidgetJumperT14.cpp +++ b/companion/src/simulation/simulateduiwidgetJumperT14.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetJumperT14.h" diff --git a/companion/src/simulation/simulateduiwidgetJumperT20.cpp b/companion/src/simulation/simulateduiwidgetJumperT20.cpp index 648d4928ca3..4d327dcc0ec 100644 --- a/companion/src/simulation/simulateduiwidgetJumperT20.cpp +++ b/companion/src/simulation/simulateduiwidgetJumperT20.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetJumperT20.h" diff --git a/companion/src/simulation/simulateduiwidgetJumperTLITE.cpp b/companion/src/simulation/simulateduiwidgetJumperTLITE.cpp index 84d4b2240df..f6a5863a53c 100644 --- a/companion/src/simulation/simulateduiwidgetJumperTLITE.cpp +++ b/companion/src/simulation/simulateduiwidgetJumperTLITE.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetJumperTLITE.h" diff --git a/companion/src/simulation/simulateduiwidgetJumperTPRO.cpp b/companion/src/simulation/simulateduiwidgetJumperTPRO.cpp index 2ccbb920026..61858575bab 100644 --- a/companion/src/simulation/simulateduiwidgetJumperTPRO.cpp +++ b/companion/src/simulation/simulateduiwidgetJumperTPRO.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetJumperTPRO.h" #include "eeprominterface.h" diff --git a/companion/src/simulation/simulateduiwidgetLR3PRO.cpp b/companion/src/simulation/simulateduiwidgetLR3PRO.cpp index dfee765c76f..092d1ba9032 100644 --- a/companion/src/simulation/simulateduiwidgetLR3PRO.cpp +++ b/companion/src/simulation/simulateduiwidgetLR3PRO.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetLR3PRO.h" diff --git a/companion/src/simulation/simulateduiwidgetMT12.cpp b/companion/src/simulation/simulateduiwidgetMT12.cpp new file mode 100644 index 00000000000..7e715cc896b --- /dev/null +++ b/companion/src/simulation/simulateduiwidgetMT12.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "simulateduiwidgetGeneric.h" + +SimulatedUIWidgetMT12::SimulatedUIWidgetMT12(SimulatorInterface *simulator, QWidget * parent): + SimulatedUIWidgetGeneric(simulator, parent) +{ + // Perform any customisation such as loading lcd area background color lists +} + +SimulatedUIWidgetMT12::~SimulatedUIWidgetMT12() +{ + +} diff --git a/companion/src/simulation/simulateduiwidgetPocket.cpp b/companion/src/simulation/simulateduiwidgetPocket.cpp index 01735dc9995..f42a943fcec 100644 --- a/companion/src/simulation/simulateduiwidgetPocket.cpp +++ b/companion/src/simulation/simulateduiwidgetPocket.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetPocket.h" diff --git a/companion/src/simulation/simulateduiwidgetT8.cpp b/companion/src/simulation/simulateduiwidgetT8.cpp index ae97a2da835..193ba8004d7 100644 --- a/companion/src/simulation/simulateduiwidgetT8.cpp +++ b/companion/src/simulation/simulateduiwidgetT8.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetT8.h" diff --git a/companion/src/simulation/simulateduiwidgetTX12.cpp b/companion/src/simulation/simulateduiwidgetTX12.cpp index 17d7e7512ad..f89a8723b48 100644 --- a/companion/src/simulation/simulateduiwidgetTX12.cpp +++ b/companion/src/simulation/simulateduiwidgetTX12.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetTX12.h" diff --git a/companion/src/simulation/simulateduiwidgetX7.cpp b/companion/src/simulation/simulateduiwidgetX7.cpp index 635275239ef..99e06d831d4 100644 --- a/companion/src/simulation/simulateduiwidgetX7.cpp +++ b/companion/src/simulation/simulateduiwidgetX7.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetX7.h" diff --git a/companion/src/simulation/simulateduiwidgetX9LITE.cpp b/companion/src/simulation/simulateduiwidgetX9LITE.cpp index ecf4b009389..7d889a6eb9d 100644 --- a/companion/src/simulation/simulateduiwidgetX9LITE.cpp +++ b/companion/src/simulation/simulateduiwidgetX9LITE.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetX9LITE.h" diff --git a/companion/src/simulation/simulateduiwidgetXLITE.cpp b/companion/src/simulation/simulateduiwidgetXLITE.cpp index 3ab6030950b..9c83bb5e768 100644 --- a/companion/src/simulation/simulateduiwidgetXLITE.cpp +++ b/companion/src/simulation/simulateduiwidgetXLITE.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetXLITE.h" diff --git a/companion/src/simulation/simulateduiwidgetZorro.cpp b/companion/src/simulation/simulateduiwidgetZorro.cpp index af9b1942d8b..c2d2fa140a3 100644 --- a/companion/src/simulation/simulateduiwidgetZorro.cpp +++ b/companion/src/simulation/simulateduiwidgetZorro.cpp @@ -1,3 +1,24 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "simulateduiwidget.h" #include "ui_simulateduiwidgetZorro.h" diff --git a/companion/src/simulation/simulator.h b/companion/src/simulation/simulator.h index 6bc549ea943..689bcdf9b16 100644 --- a/companion/src/simulation/simulator.h +++ b/companion/src/simulation/simulator.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef SIMULATOR_H -#define SIMULATOR_H +#pragma once #include #include @@ -195,6 +194,3 @@ struct SimulatorOptions }; Q_DECLARE_METATYPE(SimulatorOptions) - - -#endif // SIMULATOR_H diff --git a/companion/src/simulation/simulator_strings.h b/companion/src/simulation/simulator_strings.h index 645c7f5f824..be9e69dabc2 100644 --- a/companion/src/simulation/simulator_strings.h +++ b/companion/src/simulation/simulator_strings.h @@ -1,5 +1,25 @@ -#ifndef SIMULATOR_STRINGS_H -#define SIMULATOR_STRINGS_H +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#pragma once #include @@ -64,5 +84,3 @@ #define SIMU_STR_HLP_ACT_ROT_LFT SIMU_STR_HLP_ROTENC % " " % SIMU_STR_HLP_ROTENC_LFT #define SIMU_STR_HLP_ACT_ROT_RGT SIMU_STR_HLP_ROTENC % " " % SIMU_STR_HLP_ROTENC_RGT #define SIMU_STR_HLP_ACT_ROT_DN SIMU_STR_HLP_ROTENC % " " % SIMU_STR_HLP_ROTENC_DN - -#endif // SIMULATOR_STRINGS_H diff --git a/companion/src/simulation/simulatorinterface.h b/companion/src/simulation/simulatorinterface.h index 9f820840c79..57a3fa4efeb 100644 --- a/companion/src/simulation/simulatorinterface.h +++ b/companion/src/simulation/simulatorinterface.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _SIMULATORINTERFACE_H_ -#define _SIMULATORINTERFACE_H_ +#pragma once #include "firmwares/boards.h" #include "constants.h" @@ -204,5 +203,3 @@ class SimulatorLoader static int registerSimulators(const QDir & dir); static QMap registeredSimulators; }; - -#endif // _SIMULATORINTERFACE_H_ diff --git a/companion/src/simulation/simulatormainwindow.h b/companion/src/simulation/simulatormainwindow.h index 8d254fbddbc..6607161be4d 100644 --- a/companion/src/simulation/simulatormainwindow.h +++ b/companion/src/simulation/simulatormainwindow.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef SIMULATORMAINWINDOW_H -#define SIMULATORMAINWINDOW_H +#pragma once #include "simulator.h" @@ -114,5 +113,3 @@ class SimulatorMainWindow : public QMainWindow const static quint16 m_savedUiStateVersion; }; - -#endif // SIMULATORMAINWINDOW_H diff --git a/companion/src/simulation/simulatormainwindow.ui b/companion/src/simulation/simulatormainwindow.ui index 1e7d5eab384..fa80926100b 100644 --- a/companion/src/simulation/simulatormainwindow.ui +++ b/companion/src/simulation/simulatormainwindow.ui @@ -11,7 +11,7 @@
- OpenTx Simulator + EdgeTX Simulator @@ -37,7 +37,7 @@ 0 0 644 - 21 + 22 diff --git a/companion/src/simulation/simulatorstartupdialog.h b/companion/src/simulation/simulatorstartupdialog.h index 2a112aed759..f038c2a0c28 100644 --- a/companion/src/simulation/simulatorstartupdialog.h +++ b/companion/src/simulation/simulatorstartupdialog.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef SIMULATORSTARTUPDIALOG_H -#define SIMULATORSTARTUPDIALOG_H +#pragma once #include "simulator.h" #include @@ -75,5 +74,3 @@ class SimulatorStartupDialog : public QDialog void setGlobalFirmware(const QString & id); }; - -#endif // SIMULATORSTARTUPDIALOG_H diff --git a/companion/src/simulation/simulatorwidget.cpp b/companion/src/simulation/simulatorwidget.cpp index b6293ebcc0d..bcae14c8eef 100644 --- a/companion/src/simulation/simulatorwidget.cpp +++ b/companion/src/simulation/simulatorwidget.cpp @@ -138,6 +138,9 @@ SimulatorWidget::SimulatorWidget(QWidget * parent, SimulatorInterface * simulato case Board::BOARD_RADIOMASTER_BOXER: radioUiWidget = new SimulatedUIWidgetBoxer(simulator, this); break; + case Board::BOARD_RADIOMASTER_MT12: + radioUiWidget = new SimulatedUIWidgetMT12(simulator, this); + break; case Board::BOARD_RADIOMASTER_T8: radioUiWidget = new SimulatedUIWidgetT8(simulator, this); break; @@ -836,7 +839,7 @@ void SimulatorWidget::onSimulatorError(const QString & error) void SimulatorWidget::onPhaseChanged(qint32 phase, const QString & name) { - setWindowTitle(windowName + tr(" - Flight Mode %1 (#%2)").arg(name).arg(phase)); + setWindowTitle(windowName + QString(" - %1 %2 (#%3)").arg(Boards::getCapability(m_board, Board::Air) ? tr("Flight Mode") : tr("Drive Mode")).arg(name).arg(phase)); } void SimulatorWidget::onRadioWidgetValueChange(const RadioWidget::RadioWidgetType type, int index, int value) diff --git a/companion/src/simulation/simulatorwidget.h b/companion/src/simulation/simulatorwidget.h index 97a97e3c481..ea0ccac1f93 100644 --- a/companion/src/simulation/simulatorwidget.h +++ b/companion/src/simulation/simulatorwidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _SIMULATORWIDGET_H_ -#define _SIMULATORWIDGET_H_ +#pragma once #include "appdata.h" #include "constants.h" @@ -152,5 +151,3 @@ class SimulatorWidget : public QWidget int switchDirection[MAX_JS_BUTTONS]; #endif }; - -#endif // _SIMULATORWIDGET_H_ diff --git a/companion/src/simulation/telemetrysimu.h b/companion/src/simulation/telemetrysimu.h index 3df7719b483..e5fa3ece6f8 100644 --- a/companion/src/simulation/telemetrysimu.h +++ b/companion/src/simulation/telemetrysimu.h @@ -121,4 +121,3 @@ class TelemetrySimulator : public QWidget LogPlaybackController *logPlayback; }; // TelemetrySimulator - diff --git a/companion/src/simulation/trainersimu.h b/companion/src/simulation/trainersimu.h index e90277b0773..0a8ba879960 100644 --- a/companion/src/simulation/trainersimu.h +++ b/companion/src/simulation/trainersimu.h @@ -19,9 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _TRAINERSIMU_H_ -#define _TRAINERSIMU_H_ - +#pragma once #include #include @@ -67,6 +65,3 @@ class TrainerSimulator : public QWidget bool m_simuStarted; }; - -#endif // _TRAINERSIMU_H_ - diff --git a/companion/src/simulation/widgets/buttonswidget.h b/companion/src/simulation/widgets/buttonswidget.h index e4c1112cf2c..66ba4bbbb88 100644 --- a/companion/src/simulation/widgets/buttonswidget.h +++ b/companion/src/simulation/widgets/buttonswidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _BUTTONSWIDGET_H_ -#define _BUTTONSWIDGET_H_ +#pragma once #include "radiouiaction.h" #include "radiokeywidget.h" @@ -46,17 +45,46 @@ class ButtonsWidget : public QWidget QWidget::setStyleSheet(sheet); } - RadioKeyWidget * addArea(const QRect & rect, const char * image, RadioUiAction * action = NULL) + RadioKeyWidget * addArea(const QRect & rect, const char * image, RadioUiAction * action = nullptr) { return addArea(QPolygon(rect), image, action); } - RadioKeyWidget * addArea(const QPolygon & polygon, const char * image, RadioUiAction * action = NULL) + RadioKeyWidget * addArea(const QPolygon & polygon, const char * image, RadioUiAction * action = nullptr) { - RadioKeyWidget * btn = new RadioKeyWidget(polygon, image, action, this); - m_buttons.append(btn); - connect(btn, &RadioKeyWidget::imageChanged, this, &ButtonsWidget::setBitmap); - return btn; + RadioKeyWidget * rkw = new RadioKeyWidget(polygon, image, action, this); + m_buttons.append(rkw); + connect(rkw, &RadioKeyWidget::imageChanged, this, &ButtonsWidget::setBitmap); + return rkw; + } + + RadioKeyWidget * addPushButton(QPushButton * pushbtn, RadioUiAction * action = nullptr) + { + RadioKeyWidget * rkw = new RadioKeyWidget(pushbtn, action, this); + m_buttons.append(rkw); + connect(pushbtn, &QPushButton::pressed, rkw, &RadioKeyWidget::press); + connect(pushbtn, &QPushButton::released, rkw, &RadioKeyWidget::release); + + if (action) { + // blink push button on click or matching key(s) press + connect(action, static_cast(&RadioUiAction::pushed), [this, pushbtn] (void) { + // TODO: use a palette colors + // set to default -> blink -> default + QString csssave = pushbtn->styleSheet(); + QString blnkcol = "background-color: rgb(239, 41, 41)"; + // pressing the same key in rapid seccession can affect the order of the events see TODO + if (csssave != blnkcol) { + pushbtn->setFocus(); + pushbtn->setStyleSheet(blnkcol); + QTimer * tim = new QTimer(this); + tim->setSingleShot(true); + connect(tim, &QTimer::timeout, [pushbtn, csssave]() { pushbtn->setStyleSheet(csssave); }); + tim->start(300); + } + }); + } + pushbtn->setFocusPolicy(Qt::ClickFocus); + return rkw; } protected: @@ -111,5 +139,3 @@ class ButtonsWidget : public QWidget QList m_buttons; QString defaultStyleSheet; }; - -#endif // _BUTTONSWIDGET_H_ diff --git a/companion/src/simulation/widgets/radiofaderwidget.h b/companion/src/simulation/widgets/radiofaderwidget.h index bd7dce8d092..62f8e58b12b 100644 --- a/companion/src/simulation/widgets/radiofaderwidget.h +++ b/companion/src/simulation/widgets/radiofaderwidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _RADIOFADERWIDGET_H_ -#define _RADIOFADERWIDGET_H_ +#pragma once #include "radiowidget.h" #include "sliderwidget.h" @@ -63,8 +62,3 @@ class RadioFaderWidget : public RadioWidget setWidget(sl); } }; - - - - -#endif // _RADIOFADERWIDGET_H_ diff --git a/companion/src/simulation/widgets/radiokeywidget.h b/companion/src/simulation/widgets/radiokeywidget.h index dc29f61fead..a303097a15c 100644 --- a/companion/src/simulation/widgets/radiokeywidget.h +++ b/companion/src/simulation/widgets/radiokeywidget.h @@ -19,22 +19,25 @@ * GNU General Public License for more details. */ -#ifndef RADIOKEYWIDGET_H -#define RADIOKEYWIDGET_H +#pragma once #include "radiouiaction.h" #include "radiowidget.h" +#include + class RadioKeyWidget : public RadioWidget { Q_OBJECT public: - explicit RadioKeyWidget(const QPolygon & polygon, const QString &image, RadioUiAction * action = NULL, QWidget * parent = NULL, Qt::WindowFlags f = Qt::WindowFlags()): + explicit RadioKeyWidget(const QPolygon & polygon, const QString &image, RadioUiAction * action = nullptr, + QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags(), QPushButton * pushbtn = nullptr): RadioWidget(action, parent, f), polygon(polygon), - imgFile(image) + imgFile(image), + pushbtn(pushbtn) { m_type = RADIO_WIDGET_KEY; setValue(0); @@ -42,6 +45,11 @@ class RadioKeyWidget : public RadioWidget setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); } + explicit RadioKeyWidget(QPushButton * pushbtn = nullptr, RadioUiAction * action = nullptr, + QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) : + RadioKeyWidget(QPolygon(), QString(), action, parent, f, pushbtn) {} + + virtual void setAction(RadioUiAction * action) { if (m_action) @@ -82,6 +90,7 @@ class RadioKeyWidget : public RadioWidget signals: void imageChanged(const QString image); + void actionTriggered(); protected: @@ -91,11 +100,13 @@ class RadioKeyWidget : public RadioWidget emit imageChanged(active ? imgFile : ""); } + virtual void onActionTriggered(int index, bool active) + { + if (pushbtn) + emit actionTriggered(); + } + QPolygon polygon; QString imgFile; - + QPushButton *pushbtn; }; - -#endif // RADIOKEYWIDGET_H - - diff --git a/companion/src/simulation/widgets/radioswitchwidget.h b/companion/src/simulation/widgets/radioswitchwidget.h index 1645b6320be..eccda4972e8 100644 --- a/companion/src/simulation/widgets/radioswitchwidget.h +++ b/companion/src/simulation/widgets/radioswitchwidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _RADIOSWITCHWIDGET_H_ -#define _RADIOSWITCHWIDGET_H_ +#pragma once #include "radiowidget.h" #include "boards.h" @@ -146,5 +145,3 @@ class RadioSwitchWidget : public RadioWidget quint16 m_stepSize; }; - -#endif // _RADIOSWITCHWIDGET_H_ diff --git a/companion/src/simulation/widgets/radiotrimwidget.h b/companion/src/simulation/widgets/radiotrimwidget.h index 95bdbc14814..2c6e44039e5 100644 --- a/companion/src/simulation/widgets/radiotrimwidget.h +++ b/companion/src/simulation/widgets/radiotrimwidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _RADIOTRIMWIDGET_H_ -#define _RADIOTRIMWIDGET_H_ +#pragma once #include "radiowidget.h" #include "boards.h" @@ -138,5 +137,3 @@ class RadioTrimWidget : public RadioWidget int m_btnDecIndex; int m_btnIncIndex; }; - -#endif // _RADIOTRIMWIDGET_H_ diff --git a/companion/src/simulation/widgets/radiowidget.cpp b/companion/src/simulation/widgets/radiowidget.cpp index cb5213d8801..ed7d826e1e9 100644 --- a/companion/src/simulation/widgets/radiowidget.cpp +++ b/companion/src/simulation/widgets/radiowidget.cpp @@ -137,10 +137,10 @@ void RadioWidget::setAction(RadioUiAction * action) if (m_action->getIndex() > -1) setIndex(m_action->getIndex()); connect(m_action, &RadioUiAction::toggled, this, &RadioWidget::onActionToggled); + connect(m_action, &RadioUiAction::triggered, this, &RadioWidget::onActionTriggered); } } - int RadioWidget::getValue() const { return m_value; @@ -179,6 +179,10 @@ void RadioWidget::onActionToggled(int index, bool active) emit valueChange(m_type, index, getValue()); } +void RadioWidget::onActionTriggered(int index, bool active) +{ + // do nothing +} void RadioWidget::addLayout() { diff --git a/companion/src/simulation/widgets/radiowidget.h b/companion/src/simulation/widgets/radiowidget.h index 79821df9b87..90561aabbbf 100644 --- a/companion/src/simulation/widgets/radiowidget.h +++ b/companion/src/simulation/widgets/radiowidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _RADIOWIDGET_H_ -#define _RADIOWIDGET_H_ +#pragma once #include #include @@ -109,6 +108,7 @@ class RadioWidget : public QWidget void addLabel(); void setWidget(QWidget * widget = NULL, Qt::Alignment align = Qt::AlignHCenter); virtual void onActionToggled(int index, bool active); + virtual void onActionTriggered(int index, bool active); QGridLayout * m_gridLayout; QWidget * m_controlWidget; @@ -126,5 +126,3 @@ class RadioWidget : public QWidget }; Q_DECLARE_METATYPE(RadioWidget::RadioWidgetState) - -#endif // _RADIOWIDGET_H_ diff --git a/companion/src/simulation/widgets/sliderwidget.h b/companion/src/simulation/widgets/sliderwidget.h index 93dbb9a47f4..ceecbf6a3b9 100644 --- a/companion/src/simulation/widgets/sliderwidget.h +++ b/companion/src/simulation/widgets/sliderwidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef _SLIDERWIDGET_H_ -#define _SLIDERWIDGET_H_ +#pragma once #include #include @@ -64,5 +63,3 @@ class SliderWidget : public QSlider QString m_toolTip; }; - -#endif // _SLIDERWIDGET_H_ diff --git a/companion/src/simulation/widgets/virtualjoystickwidget.cpp b/companion/src/simulation/widgets/virtualjoystickwidget.cpp index 2ce264c4923..bd53b1de555 100644 --- a/companion/src/simulation/widgets/virtualjoystickwidget.cpp +++ b/companion/src/simulation/widgets/virtualjoystickwidget.cpp @@ -36,17 +36,18 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s QWidget(parent), stickSide(side), prefSize(size), - hTrimWidget(NULL), - vTrimWidget(NULL), - btnHoldX(NULL), - btnHoldY(NULL), - btnFixX(NULL), - btnFixY(NULL), - nodeLabelX(NULL), - nodeLabelY(NULL), + hTrimWidget(nullptr), + vTrimWidget(nullptr), + btnHoldX(nullptr), + btnHoldY(nullptr), + btnFixX(nullptr), + btnFixY(nullptr), + nodeLabelX(nullptr), + nodeLabelY(nullptr), m_stickScale(1024), m_stickPressed(false) { + isBoardSurface = Boards::isSurface(getCurrentBoard()); ar = (float)size.width() / size.height(); extraSize = QSize(0, 0); @@ -92,6 +93,13 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s hTrimWidget = createTrimWidget('H'); vTrimWidget = createTrimWidget('V'); + if (isBoardSurface) { + if (stickSide == 'L') + vTrimWidget->hide(); + else + vTrimWidget->hide(); + } + layout->addWidget(vTrimWidget, 1, colvt, 1, 1); layout->addWidget(hTrimWidget, 2, 2, 1, 1); @@ -109,6 +117,18 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s btnbox->addWidget(btnFixY = createButtonWidget(FIX_Y)); btnbox->addWidget(btnFixX = createButtonWidget(FIX_X)); btnbox->addWidget(btnHoldX = createButtonWidget(HOLD_X)); + if (isBoardSurface) { + if (stickSide == 'L') { + btnHoldX->hide(); + btnFixY->hide(); + btnFixX->hide(); + } + else { + btnHoldY->hide(); + btnFixY->hide(); + btnFixX->hide(); + } + } layout->addLayout(btnbox, 1, colbb, 1, 1); @@ -171,23 +191,37 @@ void VirtualJoystickWidget::setStickAxisValue(int index, int value) using namespace Board; qreal rvalue = value / 1024.0f; - switch (index) { - case STICK_AXIS_LH : - if (stickSide == 'L') - setStickX(rvalue); - break; - case STICK_AXIS_RH : - if (stickSide == 'R') - setStickX(rvalue); - break; - case STICK_AXIS_LV : - if (stickSide == 'L') - setStickY(rvalue); - break; - case STICK_AXIS_RV : - if (stickSide == 'R') - setStickY(rvalue); - break; + if (isBoardSurface) { + switch (index) { + case STICK_AXIS_SURFACE_LV : + if (stickSide == 'L') + setStickY(rvalue); + break; + case STICK_AXIS_SURFACE_RH : + if (stickSide == 'R') + setStickX(rvalue); + break; + } + } + else { + switch (index) { + case STICK_AXIS_LH : + if (stickSide == 'L') + setStickX(rvalue); + break; + case STICK_AXIS_RH : + if (stickSide == 'R') + setStickX(rvalue); + break; + case STICK_AXIS_LV : + if (stickSide == 'L') + setStickY(rvalue); + break; + case STICK_AXIS_RV : + if (stickSide == 'R') + setStickY(rvalue); + break; + } } } @@ -299,10 +333,24 @@ void VirtualJoystickWidget::setStickColor(const QColor & color) void VirtualJoystickWidget::loadDefaultsForMode(const unsigned mode) { - if (((mode & 1) && stickSide == 'L') || (!(mode & 1) && stickSide == 'R')) { - setStickConstraint(HOLD_Y, true); - setStickY(-1.0); - onNodeYChanged(); + if (isBoardSurface) { + if (stickSide == 'L') { + setStickX(0.0); + setStickConstraint(FIX_X, true); + onNodeXChanged(); + } + else { + setStickY(0.0); + setStickConstraint(FIX_Y, true); + onNodeYChanged(); + } + } + else { + if (((mode & 1) && stickSide == 'L') || (!(mode & 1) && stickSide == 'R')) { + setStickConstraint(HOLD_Y, true); + setStickY(-1.0); + onNodeYChanged(); + } } } @@ -400,22 +448,22 @@ QToolButton * VirtualJoystickWidget::createButtonWidget(int type) switch (type) { case HOLD_Y: btnLabel = tr("Hld Y"); - tooltip = tr("Hold Vertical stick position."); + tooltip = tr("Hold Vertical position."); icon = Simulator::SimulatorIcon("hold_y"); break; case FIX_Y: btnLabel = tr("Fix Y"); - tooltip = tr("Prevent Vertical movement of stick."); + tooltip = tr("Prevent Vertical movement."); icon = Simulator::SimulatorIcon("fixed_y"); break; case FIX_X: btnLabel = tr("Fix X"); - tooltip = tr("Prevent Horizontal movement of stick."); + tooltip = tr("Prevent Horizontal movement."); icon = Simulator::SimulatorIcon("fixed_x"); break; case HOLD_X: btnLabel = tr("Hld X"); - tooltip = tr("Hold Horizontal stick position."); + tooltip = tr("Hold Horizontal position."); icon = Simulator::SimulatorIcon("hold_x"); break; default: @@ -445,11 +493,7 @@ QLayout *VirtualJoystickWidget::createNodeValueLayout(QChar type, QLabel *& valL val->setObjectName(QString("val_%1").arg(type)); val->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); val->setAlignment(Qt::AlignCenter); -#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) - val->setMinimumWidth(val->fontMetrics().width("-100 ")); -#else val->setMinimumWidth(val->fontMetrics().horizontalAdvance("-100 ")); -#endif QVBoxLayout * layout = new QVBoxLayout(); layout->setContentsMargins(2, 2, 2, 2); layout->setSpacing(2); @@ -464,17 +508,33 @@ int VirtualJoystickWidget::getStickIndex(QChar type) { using namespace Board; - if (stickSide == 'L') { - if (type == 'H') - return STICK_AXIS_LH; - else - return STICK_AXIS_LV; + if (isBoardSurface) { + if (stickSide == 'L') { + if (type == 'H') + return STICK_AXIS_SURFACE_LV; + else + return STICK_AXIS_SURFACE_LV; + } + else { + if (type == 'H') + return STICK_AXIS_SURFACE_RH; + else + return STICK_AXIS_SURFACE_RH; + } } else { - if (type == 'H') - return STICK_AXIS_RH; - else - return STICK_AXIS_RV; + if (stickSide == 'L') { + if (type == 'H') + return STICK_AXIS_LH; + else + return STICK_AXIS_LV; + } + else { + if (type == 'H') + return STICK_AXIS_RH; + else + return STICK_AXIS_RV; + } } } @@ -482,17 +542,33 @@ int VirtualJoystickWidget::getTrimSliderType(QChar type) { using namespace Board; - if (stickSide == 'L') { - if (type == 'H') - return TRIM_AXIS_LH; - else - return TRIM_AXIS_LV; + if (isBoardSurface) { + if (stickSide == 'L') { + if (type == 'H') + return TRIM_AXIS_SURFACE_LH; + else + return TRIM_AXIS_SURFACE_LH; + } + else { + if (type == 'H') + return TRIM_AXIS_SURFACE_RH; + else + return TRIM_AXIS_SURFACE_RH; + } } else { - if (type == 'H') - return TRIM_AXIS_RH; - else - return TRIM_AXIS_RV; + if (stickSide == 'L') { + if (type == 'H') + return TRIM_AXIS_LH; + else + return TRIM_AXIS_LV; + } + else { + if (type == 'H') + return TRIM_AXIS_RH; + else + return TRIM_AXIS_RV; + } } } @@ -500,45 +576,86 @@ int VirtualJoystickWidget::getTrimButtonType(QChar type, int pos) { using namespace Board; - if (stickSide == 'L') { - if (type == 'H') { - if (pos == 0) - return TRIM_SW_LH_DEC; - else - return TRIM_SW_LH_INC; + if (isBoardSurface) { + if (stickSide == 'L') { + if (type == 'H') { + if (pos == 0) + return TRIM_SW_SURFACE_LH_DEC; + else + return TRIM_SW_SURFACE_LH_INC; + } + else { + if (pos == 0) + return TRIM_SW_SURFACE_LH_DEC; + else + return TRIM_SW_SURFACE_LH_INC; + } } + // right side else { - if (pos == 0) - return TRIM_SW_LV_DEC; - else - return TRIM_SW_LV_INC; + if (type == 'H') { + if (pos == 0) + return TRIM_SW_SURFACE_RH_DEC; + else + return TRIM_SW_SURFACE_RH_INC; + } + else { + if (pos == 0) + return TRIM_SW_SURFACE_RH_DEC; + else + return TRIM_SW_SURFACE_RH_INC; + } } } - // right side else { - if (type == 'H') { - if (pos == 0) - return TRIM_SW_RH_DEC; - else - return TRIM_SW_RH_INC; + if (stickSide == 'L') { + if (type == 'H') { + if (pos == 0) + return TRIM_SW_LH_DEC; + else + return TRIM_SW_LH_INC; + } + else { + if (pos == 0) + return TRIM_SW_LV_DEC; + else + return TRIM_SW_LV_INC; + } } + // right side else { - if (pos == 0) - return TRIM_SW_RV_DEC; - else - return TRIM_SW_RV_INC; + if (type == 'H') { + if (pos == 0) + return TRIM_SW_RH_DEC; + else + return TRIM_SW_RH_INC; + } + else { + if (pos == 0) + return TRIM_SW_RV_DEC; + else + return TRIM_SW_RV_INC; + } } } } RadioTrimWidget * VirtualJoystickWidget::getTrimWidget(int which) { - if ((stickSide == 'L' && which == Board::TRIM_AXIS_LH) || (stickSide == 'R' && which == Board::TRIM_AXIS_RH)) - return hTrimWidget; - else if ((stickSide == 'L' && which == Board::TRIM_AXIS_LV) || (stickSide == 'R' && which == Board::TRIM_AXIS_RV)) - return vTrimWidget; - else - return NULL; + if (isBoardSurface) { + if ((stickSide == 'L' && which == Board::TRIM_AXIS_SURFACE_LH) || (stickSide == 'R' && which == Board::TRIM_AXIS_SURFACE_RH)) + return hTrimWidget; + else + return nullptr; + } + else { + if ((stickSide == 'L' && which == Board::TRIM_AXIS_LH) || (stickSide == 'R' && which == Board::TRIM_AXIS_RH)) + return hTrimWidget; + else if ((stickSide == 'L' && which == Board::TRIM_AXIS_LV) || (stickSide == 'R' && which == Board::TRIM_AXIS_RV)) + return vTrimWidget; + else + return nullptr; + } } void VirtualJoystickWidget::onButtonChange(bool checked) @@ -564,10 +681,26 @@ void VirtualJoystickWidget::onButtonChange(bool checked) void VirtualJoystickWidget::updateNodeValueLabels() { - if (nodeLabelX) - nodeLabelX->setText(QString("%1").arg(getStickX() * 100.0f, 2, 'f', 0)); - if (nodeLabelY) - nodeLabelY->setText(QString("%1").arg(getStickY() * 100.0f, 2, 'f', 0)); + if (isBoardSurface) { + if (nodeLabelX) { + if (stickSide == 'L') + nodeLabelX->setText(QString("%1").arg(0)); // workaround for resize event and no analog mapped to set + else + nodeLabelX->setText(QString("%1").arg(getStickX() * 100.0f, 2, 'f', 0)); + } + if (nodeLabelY) { + if (stickSide == 'L') + nodeLabelY->setText(QString("%1").arg(getStickY() * 100.0f, 2, 'f', 0)); + else + nodeLabelY->setText(QString("%1").arg(0)); // workaround for resize event and no analog mapped to set + } + } + else { + if (nodeLabelX) + nodeLabelX->setText(QString("%1").arg(getStickX() * 100.0f, 2, 'f', 0)); + if (nodeLabelY) + nodeLabelY->setText(QString("%1").arg(getStickY() * 100.0f, 2, 'f', 0)); + } } void VirtualJoystickWidget::onGsMouseEvent(QGraphicsSceneMouseEvent * event) diff --git a/companion/src/simulation/widgets/virtualjoystickwidget.h b/companion/src/simulation/widgets/virtualjoystickwidget.h index e864a202dc6..bc4c2837e84 100644 --- a/companion/src/simulation/widgets/virtualjoystickwidget.h +++ b/companion/src/simulation/widgets/virtualjoystickwidget.h @@ -19,8 +19,7 @@ * GNU General Public License for more details. */ -#ifndef VIRTUALJOYSTICKWIDGET_H -#define VIRTUALJOYSTICKWIDGET_H +#pragma once #include "radiowidget.h" @@ -62,8 +61,8 @@ class VirtualJoystickWidget : public QWidget int getStickScale() const; void setStickScale(int stickScale); - const RadioTrimWidget *horizontalTrim() { return hTrimWidget; } - const RadioTrimWidget *verticalTrim() { return vTrimWidget; } + const RadioTrimWidget *horizontalTrim() { return hTrimWidget; } + const RadioTrimWidget *verticalTrim() { return vTrimWidget; } public slots: void setStickX(qreal x); @@ -120,6 +119,7 @@ class VirtualJoystickWidget : public QWidget int m_yIndex; int m_stickScale; bool m_stickPressed; + bool isBoardSurface; }; @@ -143,5 +143,3 @@ class CustomGraphicsScene : public QGraphicsScene virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event); }; - -#endif // VIRTUALJOYSTICKWIDGET_H diff --git a/radio/src/hal/key_driver.h b/radio/src/hal/key_driver.h index d960e232443..933fbd08119 100644 --- a/radio/src/hal/key_driver.h +++ b/radio/src/hal/key_driver.h @@ -23,6 +23,7 @@ #include +// Match with /companion/src/simulation/simulateduiwidget.h enum EnumKeys { KEY_MENU, KEY_EXIT, diff --git a/tools/build-companion.sh b/tools/build-companion.sh index 9f5a0168999..70e4f8b2751 100755 --- a/tools/build-companion.sh +++ b/tools/build-companion.sh @@ -69,7 +69,7 @@ cd build declare -a simulator_plugins=(x9lite x9lites x7 x7access t8 t12 t12max tx12 tx12mk2 - zorro commando8 boxer pocket + zorro commando8 boxer pocket mt12 tlite tpro tprov2 tpros lr3pro t14 x9d x9dp x9dp2019 x9e xlite xlites