diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index b1a80177d..4c9bc50e3 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -576,8 +576,10 @@ int OpenTxFirmware::getCapability(const Capability capability) case Pots: if (IS_TARANIS_X9E(board)) return 4; - else if (IS_TARANIS(board)) + else if (IS_TARANIS_PLUS(board)) return 3; + else if (IS_TARANIS(board)) + return 2; else return 3; case Sliders: diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 670925a54..91a9f1f7a 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -940,10 +940,20 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx) } BoardEnum board = GetCurrentFirmware()->getBoard(); SimulatorDialog * sd; - if (IS_TARANIS(board)) + if (IS_TARANIS(board)) { + for (int i=0; igetCapability(Pots); i++) { + if (radioData.generalSettings.potConfig[i] != GeneralSettings::POT_NONE) { + flags |= (SIMULATOR_FLAGS_S1 << i); + if (radioData.generalSettings.potConfig[1] == GeneralSettings::POT_MULTIPOS_SWITCH ) { + flags |= (SIMULATOR_FLAGS_S1_MULTI << i); + } + } + } sd = new SimulatorDialogTaranis(parent, si, flags); - else + } + else { sd = new SimulatorDialog9X(parent, si, flags); + } QByteArray eeprom(GetEepromInterface()->getEEpromSize(), 0); GetEepromInterface()->save((uint8_t *)eeprom.data(), *simuData, GetCurrentFirmware()->getCapability(SimulatorVariant)); delete simuData; diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 6cf4f5caa..5824e2235 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -136,6 +136,26 @@ QString getFrSkySrc(int index); void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx); +template +QVector findWidgets(QObject * object, const QString & name) +{ + QVector result; + QRegExp rx(name.arg("([0-9]+)")); + QList children = object->findChildren(); + foreach(T child, children) { + int pos = rx.indexIn(child->objectName()); + if (pos >= 0) { + QStringList list = rx.capturedTexts(); + int index = list[1].toInt(); + if (result.size() <= index) { + result.resize(index+1); + } + result[index] = child; + } + } + return result; +} + // Format a pixmap to fit on the radio using a specific firmware QPixmap makePixMap( QImage image, QString firmwareType ); diff --git a/companion/src/simulation/simulatordialog-9x.ui b/companion/src/simulation/simulatordialog-9x.ui index 4f3dfb7c5..80e26556c 100644 --- a/companion/src/simulation/simulatordialog-9x.ui +++ b/companion/src/simulation/simulatordialog-9x.ui @@ -1020,7 +1020,7 @@ QPushButton:checked { - + 0 @@ -1054,7 +1054,7 @@ QPushButton:checked { - + 0 % @@ -1077,7 +1077,7 @@ QPushButton:checked { - + 0 @@ -1114,7 +1114,7 @@ QPushButton:checked { - + 0 % @@ -1137,7 +1137,7 @@ QPushButton:checked { - + 0 @@ -1171,7 +1171,7 @@ QPushButton:checked { - + 0 % diff --git a/companion/src/simulation/simulatordialog-taranis.ui b/companion/src/simulation/simulatordialog-taranis.ui index 0273c3c4a..34fec2025 100644 --- a/companion/src/simulation/simulatordialog-taranis.ui +++ b/companion/src/simulation/simulatordialog-taranis.ui @@ -1,1700 +1,1770 @@ - - - SimulatorDialogTaranis - - - - 0 - 0 - 726 - 688 - - - - - 0 - 0 - - - - - 739 - 16777215 - - - - Companion Simulator - - - - :/icon.png:/icon.png - - - - 5 - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 570 - 5 - - - - - - - - true - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - 0 - - - - Taranis Simulator - - - - - - QLayout::SetMinimumSize - - - 0 - - - - - - 0 - 0 - - - - - 120 - 208 - - - - true - - - background:url(:/images/x9l0.png); - - - - - - - - 0 - 0 - - - - - 424 - 38 - - - - background:url(:/images/x9t0.png) - - - - - - - - 0 - 0 - - - - - 120 - 208 - - - - background:url(:/images/x9r0.png) - - - - - - - - 0 - 0 - - - - - 424 - 128 - - - - - - - - - 0 - 0 - - - - - 424 - 42 - - - - background:url(:/images/x9b0.png) - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - 438 - 6 - - - - - - - - - - - Outputs - - - - - - - - - - - - - Outputs2 - - - - - - - - - - - - - Gvars - - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - QFrame::Panel - - - QFrame::Raised - - - 2 - - - - 5 - - - 6 - - - - - - - - - - - - 0 - 0 - - - - - 23 - 23 - - - - ^ - - - false - - - - - - - - 0 - 0 - - - - Right Double Click to Reset - - - -125 - - - 125 - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - - 23 - 23 - - - - v - - - false - - - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 5 - 20 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Hold Y - - - true - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Fix Y - - - true - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Fix X - - - true - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Hold X - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 42 - 42 - - - - - - - -1024 - - - 1024 - - - 128 - - - 64.000000000000000 - - - true - - - - - - - 20 - - - 20 - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 245 - 245 - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - SF - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - - - - - - - 1 - - - 1 - - - 0 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - - 42 - 42 - - - - - - - -1024 - - - 1024 - - - 128 - - - 64.000000000000000 - - - true - - - - - - - SA - - - Qt::AlignCenter - - - - - - - SB - - - Qt::AlignCenter - - - - - - - SE - - - Qt::AlignCenter - - - - - - - LS - - - Qt::AlignCenter - - - - - - - S1 - - - Qt::AlignCenter - - - - - - - - - - 0 - 0 - - - - - 23 - 23 - - - - <- - - - false - - - - - - - Right Double Click to Reset - - - -125 - - - 125 - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - 23 - 23 - - - - -> - - - false - - - - - - - - - - - QLayout::SetDefaultConstraint - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 5 - 20 - - - - - - - - - - - 0 - 0 - - - - - 23 - 23 - - - - ^ - - - false - - - - - - - Right Double Click to Reset - - - -125 - - - 125 - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - - 23 - 23 - - - - v - - - false - - - - - - - - - - - - 0 - 0 - - - - - 42 - 42 - - - - - - - -1024 - - - 1024 - - - 128 - - - 64.000000000000000 - - - true - - - - - - - S2 - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 245 - 245 - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Hold Y - - - true - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Fix Y - - - true - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Fix X - - - true - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Hold X - - - true - - - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - false - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - - 42 - 42 - - - - - - - -1024 - - - 1024 - - - 128 - - - 64.000000000000000 - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - - - - - - - 1 - - - 0 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - SC - - - Qt::AlignCenter - - - - - - - SD - - - Qt::AlignCenter - - - - - - - SG - - - Qt::AlignCenter - - - - - - - SH - - - Qt::AlignCenter - - - - - - - RS - - - Qt::AlignCenter - - - - - - - 20 - - - 20 - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - - - - - - 0 - 0 - - - - - 23 - 23 - - - - <- - - - false - - - - - - - - 0 - 0 - - - - Right Double Click to Reset - - - -125 - - - 125 - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - 23 - 23 - - - - -> - - - false - - - - - - - - - - - - - - - lcdWidget - QWidget -
lcdwidget.h
- 1 -
- - mySlider - QSlider -
myslider.h
-
- - xcursorWidget - QWidget -
xcursorwidget.h
- 1 -
- - xmenuWidget - QWidget -
xmenuwidget.h
- 1 -
- - myQDial - QDial -
myqdial.h
-
-
- - - - -
+ + + SimulatorDialogTaranis + + + + 0 + 0 + 739 + 658 + + + + + 0 + 0 + + + + + 739 + 16777215 + + + + Companion Simulator + + + + :/icon.png:/icon.png + + + + 5 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 570 + 5 + + + + + + + + true + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + 0 + + + + Taranis Simulator + + + + + + QLayout::SetMinimumSize + + + 0 + + + + + + 0 + 0 + + + + + 120 + 208 + + + + true + + + background:url(:/images/x9l0.png); + + + + + + + + 0 + 0 + + + + + 424 + 38 + + + + background:url(:/images/x9t0.png) + + + + + + + + 0 + 0 + + + + + 120 + 208 + + + + background:url(:/images/x9r0.png) + + + + + + + + 0 + 0 + + + + + 424 + 128 + + + + + + + + + 0 + 0 + + + + + 424 + 42 + + + + background:url(:/images/x9b0.png) + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + 438 + 6 + + + + + + + + + + + Outputs + + + + + + + + + + + + + Outputs2 + + + + + + + + + + + + + Gvars + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + QFrame::Panel + + + QFrame::Raised + + + 2 + + + + + + + + Qt::Horizontal + + + + 13 + 47 + + + + + + + + SB + + + Qt::AlignCenter + + + + + + + SA + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 13 + 47 + + + + + + + + Qt::Horizontal + + + + 13 + 47 + + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + SC + + + Qt::AlignCenter + + + + + + + SE + + + Qt::AlignCenter + + + + + + + RS + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + + + + 1 + + + 1 + + + 0 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + Qt::Horizontal + + + + 13 + 47 + + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + LS + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 13 + 47 + + + + + + + + SH + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + + + + 1 + + + 0 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + Qt::Horizontal + + + + 13 + 47 + + + + + + + + SG + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + false + + + QSlider::TicksBothSides + + + 1 + + + + + + + SF + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + SD + + + Qt::AlignCenter + + + + + + + + 16777215 + 50 + + + + -1024 + + + 1024 + + + Qt::Vertical + + + + + + + + 16777215 + 50 + + + + -1024 + + + 1024 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 84 + 1 + + + + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + + 0 + 50 + + + + + 42 + 42 + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + + 0 + 50 + + + + + 42 + 42 + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + + 42 + 0 + + + + S1 + + + Qt::AlignCenter + + + + + + + + 42 + 0 + + + + S2 + + + Qt::AlignCenter + + + + + + + + 42 + 0 + + + + S3 + + + Qt::AlignCenter + + + + + + + + 42 + 0 + + + + S4 + + + Qt::AlignCenter + + + + + + + + + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix X + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold X + + + true + + + + + + + + + + 245 + 245 + + + + + 16777215 + 16777215 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + ^ + + + false + + + + + + + + 0 + 0 + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + v + + + false + + + + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + <- + + + false + + + + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + -> + + + false + + + + + + + + + 20 + + + 20 + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + ^ + + + false + + + + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + v + + + false + + + + + + + + + + + + 0 + 0 + + + + + 245 + 245 + + + + + 16777215 + 16777215 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix X + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold X + + + true + + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + <- + + + false + + + + + + + + 0 + 0 + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + -> + + + false + + + + + + + + + 20 + + + 20 + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + + + lcdWidget + QWidget +
lcdwidget.h
+ 1 +
+ + mySlider + QSlider +
myslider.h
+
+ + xcursorWidget + QWidget +
xcursorwidget.h
+ 1 +
+ + xmenuWidget + QWidget +
xmenuwidget.h
+ 1 +
+ + myQDial + QDial +
myqdial.h
+
+
+ + + + +
diff --git a/companion/src/simulation/simulatordialog.cpp b/companion/src/simulation/simulatordialog.cpp index 97d8fa264..939d65242 100644 --- a/companion/src/simulation/simulatordialog.cpp +++ b/companion/src/simulation/simulatordialog.cpp @@ -50,7 +50,6 @@ void SimulatorDialog::updateDebugOutput() SimulatorDialog::SimulatorDialog(QWidget * parent, SimulatorInterface *simulator, unsigned int flags): QDialog(parent), flags(flags), - dialP_4(NULL), timer(NULL), lightOn(false), simulator(simulator), @@ -118,10 +117,9 @@ SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, SimulatorInterface *simul ui->trimHL_R->setText(QString::fromUtf8(rightArrow)); ui->trimVL_U->setText(QString::fromUtf8(upArrow)); ui->trimVL_D->setText(QString::fromUtf8(downArrow)); - - connect(ui->dialP_1, SIGNAL(valueChanged(int)), this, SLOT(dialChanged())); - connect(ui->dialP_2, SIGNAL(valueChanged(int)), this, SLOT(dialChanged())); - connect(ui->dialP_3, SIGNAL(valueChanged(int)), this, SLOT(dialChanged())); + for (int i=0; icursor, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); connect(ui->menu, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); connect(ui->trimHR_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); @@ -156,20 +154,31 @@ SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, SimulatorInterf { lcdWidth = 212; lcdDepth = 4; - + initUi(ui); // install simulator TRACE hook simulator->installTraceHook(traceCb); - dialP_4 = ui->dialP_4; - ui->lcd->setBackgroundColor(47, 123, 227); - //restore switches - if (g.simuSW()) + // restore switches + if (g.simuSW()) { restoreSwitches(); + } + for (int i=0; isetValue(-1024); + pots[i]->setSingleStep(2048/5); + pots[i]->setPageStep(2048/5); + } + else if (!(flags & (SIMULATOR_FLAGS_S1 << i))) { + pots[i]->hide(); + potLabels[i]->hide(); + } + } + ui->trimHR_L->setText(QString::fromUtf8(leftArrow)); ui->trimHR_R->setText(QString::fromUtf8(rightArrow)); ui->trimVR_U->setText(QString::fromUtf8(upArrow)); @@ -232,11 +241,9 @@ void SimulatorDialog::mouseReleaseEvent(QMouseEvent *event) } } -void SimulatorDialog9X::dialChanged() +void SimulatorDialog::dialChanged(int index) { - ui->dialP_1value->setText(QString("%1 %").arg((ui->dialP_1->value()*100)/1024)); - ui->dialP_2value->setText(QString("%1 %").arg((ui->dialP_2->value()*100)/1024)); - ui->dialP_3value->setText(QString("%1 %").arg((ui->dialP_3->value()*100)/1024)); + potValues[index]->setText(QString("%1 %").arg((pots[index]->value()*100)/1024)); } void SimulatorDialog::wheelEvent (QWheelEvent *event) @@ -371,9 +378,11 @@ void SimulatorDialog::initUi(T * ui) lcd = ui->lcd; leftStick = ui->leftStick; rightStick = ui->rightStick; - dialP_1 = ui->dialP_1; - dialP_2 = ui->dialP_2; - dialP_3 = ui->dialP_3; + pots = findWidgets(this, "pot%1"); + potLabels = findWidgets(this, "potLabel%1"); + potValues = findWidgets(this, "potValue%1"); + sliders = findWidgets(this, "slider%1"); + trimHLeft = ui->trimHLeft; trimVLeft = ui->trimVLeft; trimHRight = ui->trimHRight; @@ -726,9 +735,9 @@ void SimulatorDialog9X::getValues() }, { - ui->dialP_1->value(), - ui->dialP_2->value(), - ui->dialP_3->value(), 0 + pots[0]->value(), + pots[1]->value(), + pots[2]->value() }, { @@ -820,6 +829,13 @@ void SimulatorDialogTaranis::on_switchH_sliderReleased() void SimulatorDialogTaranis::getValues() { + for (int i=0; ivalue()+1024)/(2048.0/5))*(2048.0/5)-1024; + pots[i]->setValue(s1); + } + } + TxInputs inputs = { { int(1024*nodeLeft->getX()), // LEFT HORZ @@ -829,11 +845,11 @@ void SimulatorDialogTaranis::getValues() }, { - -ui->dialP_1->value(), - ui->dialP_2->value(), - 0, - -ui->dialP_3->value(), - ui->dialP_4->value() + -pots[0]->value(), + pots[1]->value(), + ((flags && SIMULATOR_FLAGS_S3) ? pots[2]->value() : 0), + -sliders[0]->value(), + sliders[1]->value() }, { @@ -1107,18 +1123,9 @@ void SimulatorDialog::onjoystickAxisValueChanged(int axis, int value) } else if (stick==4) { nodeLeft->setX(stickval/1024.0); - } - else if (stick==5) { - dialP_1->setValue(stickval); } - else if (stick==6) { - dialP_2->setValue(stickval); - } - else if (stick==7) { - dialP_3->setValue(stickval); - } - else if (stick==8 && dialP_4) { - dialP_4->setValue(stickval); + else if (stick >= 5 && stick < 5+pots.count()) { + pots[stick-5]->setValue(stickval); } } } diff --git a/companion/src/simulation/simulatordialog.h b/companion/src/simulation/simulatordialog.h index a69514e66..4111bdbe0 100644 --- a/companion/src/simulation/simulatordialog.h +++ b/companion/src/simulation/simulatordialog.h @@ -27,8 +27,16 @@ namespace Ui { class lcdWidget; class mySlider; -#define SIMULATOR_FLAGS_NOTX 1 -#define SIMULATOR_FLAGS_STICK_MODE_LEFT 2 +#define SIMULATOR_FLAGS_NOTX 1 +#define SIMULATOR_FLAGS_STICK_MODE_LEFT 2 +#define SIMULATOR_FLAGS_S1 4 +#define SIMULATOR_FLAGS_S2 8 +#define SIMULATOR_FLAGS_S3 16 +#define SIMULATOR_FLAGS_S4 32 // reserved for the future +#define SIMULATOR_FLAGS_S1_MULTI 64 +#define SIMULATOR_FLAGS_S2_MULTI 128 +#define SIMULATOR_FLAGS_S3_MULTI 256 +#define SIMULATOR_FLAGS_S4_MULTI 512 // reserved for the future class SimulatorDialog : public QDialog { @@ -50,7 +58,11 @@ class SimulatorDialog : public QDialog unsigned int flags; lcdWidget * lcd; QGraphicsView * leftStick, * rightStick; - QDial * dialP_1, * dialP_2, * dialP_3, * dialP_4; + QVector pots; + QVector potLabels; + QVector potValues; + QVector sliders; + mySlider * trimHLeft, * trimVLeft, * trimHRight, * trimVRight; QLabel * leftXPerc, * rightXPerc, * leftYPerc, * rightYPerc; QTabWidget * tabWidget; @@ -119,6 +131,7 @@ class SimulatorDialog : public QDialog private slots: void onButtonPressed(int value); + void dialChanged(int index); void on_FixRightY_clicked(bool checked); void on_FixRightX_clicked(bool checked); void on_FixLeftY_clicked(bool checked); @@ -160,9 +173,6 @@ class SimulatorDialog9X: public SimulatorDialog void saveSwitches(void); void restoreSwitches(void); - private slots: - void dialChanged(); - private: Ui::SimulatorDialog9X * ui; static uint32_t switchstatus;