diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 0ba5d360a..27fdaf155 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -220,6 +220,7 @@ void TimerPanel::onModeChanged(int index) #define MASK_RF_RACING_MODE (1<<16) #define MASK_GHOST (1<<17) #define MASK_BAUDRATE (1<<18) +#define MASK_MULTI_DSM_OPT (1<<19) quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT; @@ -492,8 +493,12 @@ void ModulePanel::update() mask |= MASK_CHANNELS_COUNT; else module.channelsCount = 16; - if (pdef.optionsstr != nullptr) - mask |= MASK_MULTIOPTION; + if (pdef.optionsstr != nullptr) { + if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_DSM2) + mask |= MASK_MULTI_DSM_OPT; + else + mask |= MASK_MULTIOPTION; + } if (pdef.hasFailsafe || (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_FRSKY && (module.subType == 0 || module.subType == 2 || module.subType > 3 ))) mask |= MASK_FAILSAFES; break; @@ -629,6 +634,10 @@ void ModulePanel::update() ui->multiProtocol->setVisible(mask & MASK_MULTIMODULE); ui->label_option->setVisible(mask & MASK_MULTIOPTION); ui->optionValue->setVisible(mask & MASK_MULTIOPTION); + ui->lblChkOption->setVisible(mask & MASK_MULTI_DSM_OPT); + ui->chkOption->setVisible(mask & MASK_MULTI_DSM_OPT); + ui->lblCboOption->setVisible(mask & MASK_MULTI_DSM_OPT); + ui->cboOption->setVisible(mask & MASK_MULTI_DSM_OPT); ui->disableTelem->setVisible(mask & MASK_MULTIMODULE); ui->disableChMap->setVisible(mask & MASK_MULTIMODULE); ui->lowPower->setVisible(mask & MASK_MULTIMODULE); @@ -653,6 +662,16 @@ void ModulePanel::update() ui->label_option->setText(qApp->translate("Multiprotocols", qPrintable(pdef.optionsstr))); } + if (mask & MASK_MULTI_DSM_OPT) { + ui->lblChkOption->setText(qApp->translate("Multiprotocols", qPrintable(pdef.optionsstr))); + ui->chkOption->setChecked(Helpers::getBitmappedValue(module.multi.optionValue, 0)); + ui->lblCboOption->setText(qApp->translate("Multiprotocols", "Servo update rate")); + ui->cboOption->clear(); + ui->cboOption->addItems({"22ms", "11ms"}); + ui->cboOption->setSizeAdjustPolicy(QComboBox::AdjustToContents); + ui->cboOption->setCurrentIndex(Helpers::getBitmappedValue(module.multi.optionValue, 1)); + } + // Ghost settings fields ui->raw12bits->setVisible(mask & MASK_GHOST); if (mask & MASK_GHOST) { @@ -854,6 +873,42 @@ void ModulePanel::on_optionValue_editingFinished() } } +void ModulePanel::on_chkOption_stateChanged(int state) +{ + if (!lock) { + if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_DSM2) { + unsigned int opt = (unsigned int)module.multi.optionValue; + if (Helpers::getBitmappedValue(opt, 0) != (state == Qt::Checked)) { + Helpers::setBitmappedValue(opt, (state == Qt::Checked), 0); + module.multi.optionValue = opt; + emit modified(); + } + } + else if (module.multi.optionValue != (state == Qt::Checked)) { + module.multi.optionValue = (state == Qt::Checked); + emit modified(); + } + } +} + +void ModulePanel::on_cboOption_currentIndexChanged(int value) +{ + if (!lock && value >= 0) { + if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_DSM2) { + unsigned int opt = (unsigned int)module.multi.optionValue; + if (Helpers::getBitmappedValue(opt, 1) != (unsigned int)value) { + Helpers::setBitmappedValue(opt, value, 1); + module.multi.optionValue = opt; + emit modified(); + } + } + else if (module.multi.optionValue != value) { + module.multi.optionValue = value; + emit modified(); + } + } +} + void ModulePanel::onSubTypeChanged() { const unsigned type = ui->multiSubType->currentData().toUInt(); diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index 6ec69d032..b793e24d8 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -113,6 +113,8 @@ class ModulePanel : public ModelPanel void updateFailsafe(unsigned channel); void on_optionValue_editingFinished(); void onClearAccessRxClicked(); + void on_chkOption_stateChanged(int state); + void on_cboOption_currentIndexChanged(int value); private: enum FailsafeValueDisplayTypes { FAILSAFE_DISPLAY_PERCENT = 1, FAILSAFE_DISPLAY_USEC = 2 }; diff --git a/companion/src/modeledit/setup_module.ui b/companion/src/modeledit/setup_module.ui index 5a7b35fea..a45a48a1b 100644 --- a/companion/src/modeledit/setup_module.ui +++ b/companion/src/modeledit/setup_module.ui @@ -1057,7 +1057,7 @@ - + Qt::Horizontal @@ -1098,6 +1098,40 @@ + + + + Option check + + + + + + + + + + + + + + Option combo + + + + + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + +