diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 02cc9650d..6f5a0cbb7 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -856,8 +856,12 @@ class ModelData { unsigned int thrTraceSrc; int8_t traineron; // 0 disable trainer, 1 allow trainer int8_t t2throttle; // Start timer2 using throttle - unsigned int modelId; + unsigned int modelId; unsigned int switchWarningStates; + unsigned int nSwToWarn; + unsigned int nPotsToWarn; + int potPosition[C9X_NUM_POTS]; + bool displayText; // TODO structure char gvars_names[C9X_MAX_GVARS][6+1]; bool gvars_popups[C9X_MAX_GVARS]; @@ -1008,6 +1012,8 @@ enum Capability { CSFunc, LCDWidth, GetThrSwitch, + HasDisplayText, + PotWarnings, VirtualInputs, LuaInputs, LimitsPer1000, diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index b723ac0a2..4c434675a 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1856,7 +1856,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u internalField.Append(new BoolField<1>(modelData.disableThrottleWarning)); if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216)) - internalField.Append(new SpareBitsField<1>()); + internalField.Append(new BoolField<1>(modelData.displayText)); else internalField.Append(new BoolField<1>(modelData.moduleData[0].ppmPulsePol)); @@ -1927,6 +1927,10 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u internalField.Append(new MavlinkField(modelData.mavlink, board, version)); } + if (!IS_ARM(board) && (version >= 216)) { + internalField.Append(new UnsignedField<8>(modelData.nSwToWarn)); + } + if (IS_TARANIS(board) && version < 215) { internalField.Append(new CharField<10>(modelData.bitmap)); } @@ -1953,6 +1957,14 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u } } + if (IS_ARM(board) && version >= 216) { + internalField.Append(new UnsignedField<8>(modelData.nSwToWarn)); + internalField.Append(new UnsignedField<8>(modelData.nPotsToWarn)); + for (int i=0; i < GetEepromInterface()->getCapability(PotWarnings); i++) { + internalField.Append(new SignedField<8>(modelData.potPosition[i])); + } + } + if (IS_TARANIS(board)) { for (int i=0; i(modelData.curves[i].name)); @@ -1964,6 +1976,11 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u internalField.Append(new SpareBitsField<720>()); // TODO char inputNames[MAX_INPUTS][4]; internalField.Append(new SpareBitsField<1024>()); + internalField.Append(new UnsignedField<8>(modelData.nSwToWarn)); + internalField.Append(new UnsignedField<8>(modelData.nPotsToWarn)); + for (int i=0; i < GetEepromInterface()->getCapability(PotWarnings); i++) { + internalField.Append(new SignedField<8>(modelData.potPosition[i])); + } } } diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 73738e0b4..58a5ecda9 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -695,6 +695,9 @@ int Open9xInterface::getCapability(const Capability capability) return (IS_TARANIS(board) ? 212 : 128) ; case GetThrSwitch: return (IS_TARANIS(board) ? DSW_SF1 : DSW_THR) ; + case PotWarnings: + return (IS_TARANIS(board) ? 4 : IS_ARM(board) ? 3 : 0); + case HasDisplayText: case VirtualInputs: case LuaInputs: case LimitsPer1000: diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 0302d367e..7b5fbae91 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -398,6 +398,10 @@ Setup::Setup(QWidget *parent, ModelData & model): ui->modelImage_label->hide(); ui->imagePreview->hide(); } + + if (!GetEepromInterface()->getCapability(HasDisplayText)) { + ui->displayText->hide(); + } // Beep Center checkboxes int analogs = 4 + GetEepromInterface()->getCapability(Pots); @@ -412,11 +416,10 @@ Setup::Setup(QWidget *parent, ModelData & model): ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, analogs+GetEepromInterface()->getCapability(RotaryEncoders)); // Startup switches warnings - ui->switchesStartupWarning->setProperty("index", 0); - connect(ui->switchesStartupWarning, SIGNAL(currentIndexChanged(int)), this, SLOT(startupSwitchEdited(int))); for (int i=0; igetCapability(Switches)-1; i++) { QLabel * label = new QLabel(); QSlider * slider = new QSlider(); + QCheckBox * cb = new QCheckBox(); slider->setProperty("index", i+1); slider->setOrientation(Qt::Vertical); slider->setMinimum(0); @@ -435,10 +438,17 @@ Setup::Setup(QWidget *parent, ModelData & model): label->setText(switches9X[i]); slider->setMaximum(i==0 ? 2 : 1); } + cb->setProperty("index", i+1); ui->switchesStartupLayout->addWidget(label, 0, i+1); + ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter); ui->switchesStartupLayout->addWidget(slider, 1, i+1); + ui->switchesStartupLayout->setAlignment(slider, Qt::AlignCenter); + ui->switchesStartupLayout->addWidget(cb, 2, i+1); + ui->switchesStartupLayout->setAlignment(cb, Qt::AlignCenter); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int))); + connect(cb, SIGNAL(toggled(bool)), this, SLOT(startupSwitchToggled(bool))); startupSwitchesSliders << slider; + startupSwitchesCheckboxes << cb; } ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches)); @@ -539,6 +549,7 @@ void Setup::update() ui->throttleTrim->setChecked(model.thrTrim); ui->extendedLimits->setChecked(model.extendedLimits); ui->extendedTrims->setChecked(model.extendedTrims); + ui->displayText->setChecked(model.displayText); updateBeepCenter(); updateStartupSwitches(); @@ -563,13 +574,14 @@ void Setup::updateStartupSwitches() lock = true; unsigned int switchStates = model.switchWarningStates; - bool enabled = !(switchStates & 0x01); - ui->switchesStartupWarning->setCurrentIndex(switchStates & 0x01); - switchStates >>= 1; + bool enabled; for (int i=0; igetCapability(Switches)-1; i++) { QSlider * slider = startupSwitchesSliders[i]; + QCheckBox * cb = startupSwitchesCheckboxes[i]; + enabled = !(model.nSwToWarn & (1 << i)); slider->setEnabled(enabled); + cb->setChecked(enabled); if (IS_TARANIS(GetEepromInterface()->getBoard())) { slider->setValue(i==5 ? (switchStates & 0x3)/2 : switchStates & 0x3); switchStates >>= 2; @@ -590,24 +602,24 @@ void Setup::startupSwitchEdited(int value) unsigned int mask; int index = sender()->property("index").toInt(); - if (index == 0) { - mask = 0x01; - } - else if (IS_TARANIS(GetEepromInterface()->getBoard())) { - if (index == 6) - mask = 0x02 << (index*2 - 1); + if (IS_TARANIS(GetEepromInterface()->getBoard())) { + if (index == 6) { + shift = (index - 1)*2; + mask = 0x02 << shift; + shift++; + } else { - shift = index*2 - 1; + shift = (index - 1)*2; mask = 0x03 << shift; } } else { if (index == 1) { - shift = 1; - mask = 0x03 << shift; + mask = 0x03; } else { - mask = 0x01 << (index+1); + shift = index; + mask = 0x01 << shift; } } @@ -615,7 +627,7 @@ void Setup::startupSwitchEdited(int value) if (value) { if (shift == 0) { - model.switchWarningStates |= mask; + model.switchWarningStates |= value; } else { model.switchWarningStates |= (value << shift); @@ -627,6 +639,25 @@ void Setup::startupSwitchEdited(int value) } } +void Setup::startupSwitchToggled(bool checked) +{ + int index = sender()->property("index").toInt()-1; + + if (checked) + model.nSwToWarn &= ~(1 << index); + else + model.nSwToWarn |= (1 << index); + + updateStartupSwitches(); + emit modified(); +} + +void Setup::on_displayText_toggled(bool checked) +{ + model.displayText = checked; + emit modified(); +} + void Setup::on_throttleTrim_toggled(bool checked) { model.thrTrim = checked; diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index 7b33ffe5a..fb63a898a 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -83,15 +83,18 @@ class Setup : public ModelPanel void on_extendedTrims_toggled(bool checked); void on_throttleWarning_toggled(bool checked); void on_throttleReverse_toggled(bool checked); + void on_displayText_toggled(bool checked); void on_image_currentIndexChanged(int index); void on_trimIncrement_currentIndexChanged(int index); void onBeepCenterToggled(bool checked); void startupSwitchEdited(int value); + void startupSwitchToggled(bool checked); void onChildModified(); private: Ui::Setup *ui; QVector startupSwitchesSliders; + QVector startupSwitchesCheckboxes; QVector centerBeepCheckboxes; ModulePanel * modules[C9X_NUM_MODULES+1]; TimerPanel * timers[C9X_MAX_TIMERS]; diff --git a/companion/src/modeledit/setup.ui b/companion/src/modeledit/setup.ui index c4a632c00..aa440a56d 100644 --- a/companion/src/modeledit/setup.ui +++ b/companion/src/modeledit/setup.ui @@ -65,7 +65,7 @@ - Switch startup Warning + Switch Warnings Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -95,55 +95,6 @@ - - - - QLayout::SetMinimumSize - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - ON - - - - - OFF - - - - - - - - - 0 - 0 - - - - Check - - - Qt::AlignCenter - - - - - @@ -288,6 +239,29 @@ + + + + Qt::RightToLeft + + + Display Checklist + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -353,6 +327,22 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi + + + + QLayout::SetMinimumSize + + + 0 + + + 6 + + + 6 + + +