From 5b7654e47555cffa097216d0f4c746269583b54f Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 20 Dec 2013 19:59:47 +0100 Subject: [PATCH] StartupSwitches and BeepCenter in ModelSetup rewritten --- companion/src/eeprominterface.cpp | 45 +- companion/src/eeprominterface.h | 15 +- companion/src/helpers.cpp | 6 - companion/src/helpers.h | 2 +- companion/src/modeledit/setup.cpp | 399 +++++--------- companion/src/modeledit/setup.h | 24 +- companion/src/modeledit/setup.ui | 835 +++--------------------------- 7 files changed, 226 insertions(+), 1100 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 909a0e5e5..206804e1c 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -10,6 +10,9 @@ QString EEPROMWarnings; +const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" }; +const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH" }; + void setEEPROMString(char *dst, const char *src, int size) { memcpy(dst, src, size); @@ -244,27 +247,28 @@ double RawSource::getStep(const ModelData & Model) } } +QString AnalogString(int index) +{ + static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") }; + static const QString pots9X[] = { QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3") }; + static const QString potsX9D[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("LS"), QObject::tr("RS") }; + + if (index < 4) + return CHECK_IN_ARRAY(sticks, index); + else + return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(potsX9D, index-4) : CHECK_IN_ARRAY(pots9X, index-4)); +} + +QString RotaryEncoderString(int index) +{ + static const QString rotary[] = { QObject::tr("REa"), QObject::tr("REb") }; + return CHECK_IN_ARRAY(rotary, index); +} + QString RawSource::toString() { - static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") }; - static const QString trims[] = { QObject::tr("TrmR"), QObject::tr("TrmE"), QObject::tr("TrmT"), QObject::tr("TrmA")}; - static const QString pots9X[] = { QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3") }; - - static const QString potsX9D[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("LS"), QObject::tr("RS") }; - - static const QString rotary[] = { QObject::tr("REa"), QObject::tr("REb") }; - - static const QString switches9X[] = { QObject::tr("3POS"), - QObject::tr("THR"), QObject::tr("RUD"), QObject::tr("ELE"), - QObject::tr("AIL"), QObject::tr("GEA"), QObject::tr("TRN"), - }; - - static const QString switchesX9D[] = { QObject::tr("SA"), QObject::tr("SB"), QObject::tr("SC"), QObject::tr("SD"), - QObject::tr("SE"), QObject::tr("SF"), QObject::tr("SG"), QObject::tr("SH"), - }; - static const QString telemetry[] = { QObject::tr("Batt"), QObject::tr("Timer1"), QObject::tr("Timer2"), (IS_TARANIS(GetEepromInterface()->getBoard()) ? QObject::tr("SWR") : QObject::tr("Tx")), (IS_TARANIS(GetEepromInterface()->getBoard()) ? QObject::tr("RSSI") : QObject::tr("Rx")), QObject::tr("A1"), QObject::tr("A2"), QObject::tr("Alt"), QObject::tr("Rpm"), QObject::tr("Fuel"), QObject::tr("T1"), QObject::tr("T2"), QObject::tr("Speed"), QObject::tr("Dist"), QObject::tr("GPS Alt"), QObject::tr("Cell"), QObject::tr("Cels"), QObject::tr("Vfas"), QObject::tr("Curr"), @@ -284,14 +288,11 @@ QString RawSource::toString() } switch(type) { case SOURCE_TYPE_STICK: - if (index < 4) - return CHECK_IN_ARRAY(sticks, index); - else - return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(potsX9D, index-4) : CHECK_IN_ARRAY(pots9X, index-4)); + return AnalogString(index); case SOURCE_TYPE_TRIM: return CHECK_IN_ARRAY(trims, index); case SOURCE_TYPE_ROTARY_ENCODER: - return CHECK_IN_ARRAY(rotary, index); + return RotaryEncoderString(index); case SOURCE_TYPE_MAX: return QObject::tr("MAX"); case SOURCE_TYPE_SWITCH: diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 148f7726d..cf5e7a2dd 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -50,8 +50,8 @@ enum BoardEnum { BOARD_TARANIS_REV4a }; #define IS_STOCK(board) (board==BOARD_STOCK || board==BOARD_M128) -#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a) -#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a) +#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a) +#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a) const uint8_t modn12x3[4][4]= { {1, 2, 3, 4}, @@ -198,10 +198,13 @@ enum HeliSwashTypes { #define NUM_CAL_PPM 4 #define NUM_PPM 8 #define NUM_CYC 3 -#define C9X_NUM_SWITCHES 10 -#define C9X_NUM_KEYS 6 +#define C9X_NUM_SWITCHES 10 +#define C9X_NUM_KEYS 6 #define C9X_MAX_TIMERS 2 +extern const char * switches9X[]; +extern const char * switchesX9D[]; + enum TelemetrySource { TELEMETRY_SOURCE_TX_BATT, TELEMETRY_SOURCE_TIMER1, @@ -267,8 +270,12 @@ enum RawSourceType { SOURCE_TYPE_TELEMETRY, MAX_SOURCE_TYPE }; + class ModelData; +QString AnalogString(int index); +QString RotaryEncoderString(int index); + class RawSource { public: RawSource(): diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index fc4346a23..3639b7027 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -1138,12 +1138,6 @@ int findmult(float value, float base) return mult; } -bool checkbit(int value, int bit) -{ - return ((value & (1<swwarn_label, ui->swwarn0_label, ui->swwarn4_label, NULL}; - QCheckBox * pmchkb[] = {ui->swwarn1_ChkB,ui->swwarn2_ChkB,ui->swwarn3_ChkB,ui->swwarn5_ChkB,ui->swwarn6_ChkB, NULL}; - QSlider * tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, NULL}; + QSlider * fssld1[] = { ui->fsm1SL_1, ui->fsm1SL_2,ui->fsm1SL_3,ui->fsm1SL_4,ui->fsm1SL_5,ui->fsm1SL_6,ui->fsm1SL_7,ui->fsm1SL_8, ui->fsm1SL_9, ui->fsm1SL_10,ui->fsm1SL_11,ui->fsm1SL_12,ui->fsm1SL_13,ui->fsm1SL_14,ui->fsm1SL_15,ui->fsm1SL_16, NULL }; QSlider * fssld2[] = { ui->fsm2SL_1, ui->fsm2SL_2,ui->fsm2SL_3,ui->fsm2SL_4,ui->fsm2SL_5,ui->fsm2SL_6,ui->fsm2SL_7,ui->fsm2SL_8, @@ -133,74 +130,50 @@ void Setup::tabModelEditSetup() } } } - } - if (!GetEepromInterface()->getCapability(pmSwitchMask)) { - for (int i=0; pmsl[i]; i++) { - pmsl[i]->hide(); - } - for (int i=0; pmchkb[i]; i++) { - pmchkb[i]->hide(); - } - ui->tswwarn0_CB->hide(); - for (int i=0; tpmsld[i]; i++) { - tpmsld[i]->hide(); - } - ui->swwarn0_line->hide(); - ui->swwarn0_line->hide(); - ui->swwarn0_CB->hide(); - ui->swwarn4_CB->hide(); - ui->swwarn_line0->hide(); - ui->swwarn_line1->hide(); - ui->swwarn_line2->hide(); - ui->swwarn_line3->hide(); - ui->swwarn_line4->hide(); - ui->swwarn_line5->hide(); - ui->tswwarn0_label->hide(); - ui->tswwarn1_label->hide(); - ui->tswwarn2_label->hide(); - ui->tswwarn3_label->hide(); - ui->tswwarn4_label->hide(); - ui->tswwarn5_label->hide(); - ui->tswwarn6_label->hide(); - ui->tswwarn7_label->hide(); - } else { - if (GetEepromInterface()->getCapability(Pots)==3) { - ui->swwarn0_CB->setCurrentIndex(model.switchWarningStates & 0x01); - ui->swwarn1_ChkB->setChecked(checkbit(model.switchWarningStates, 1)); - ui->swwarn2_ChkB->setChecked(checkbit(model.switchWarningStates, 2)); - ui->swwarn3_ChkB->setChecked(checkbit(model.switchWarningStates, 3)); - ui->swwarn4_CB->setCurrentIndex((model.switchWarningStates & 0x30)>>4); - ui->swwarn5_ChkB->setChecked(checkbit(model.switchWarningStates, 6)); - ui->swwarn6_ChkB->setChecked(checkbit(model.switchWarningStates, 7)); - for (int i=0; pmchkb[i]; i++) { - connect(pmchkb[i], SIGNAL(stateChanged(int)),this,SLOT(startupSwitchEdited())); - } - connect(ui->swwarn0_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(startupSwitchEdited())); - connect(ui->swwarn4_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(startupSwitchEdited())); - } else { - ui->tswwarn0_CB->setCurrentIndex(model.switchWarningStates & 0x01); - uint16_t switchstate=(model.switchWarningStates>>1); - ui->chkSA->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSB->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSC->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSD->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSE->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSF->setValue((switchstate & 0x3)/2); - switchstate >>= 2; - ui->chkSG->setValue(switchstate & 0x3); - connect(ui->tswwarn0_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(startupSwitchEdited())); - for (int i=0; tpmsld[i]; i++) { - connect(tpmsld[i], SIGNAL(valueChanged(int)),this,SLOT(startupSwitchEdited())); - } - } + // Beep Center checkboxes + int analogs = 4 + GetEepromInterface()->getCapability(Pots); + for (int i=0; igetCapability(RotaryEncoders); i++) { + QCheckBox * checkbox = new QCheckBox(this); + checkbox->setProperty("index", i); + checkbox->setText(icenterBeepLayout->addWidget(checkbox, 0, i+1); + connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool))); + centerBeepCheckboxes << checkbox; } + ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, analogs+GetEepromInterface()->getCapability(RotaryEncoders)); + + // Startup switches warnings + ui->switchesStartupWarning_CB->setProperty("index", 0); + connect(ui->switchesStartupWarning_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(startupSwitchEdited(int))); + for (int i=0; igetCapability(Switches)-1; i++) { + QLabel * label = new QLabel(); + QSlider * slider = new QSlider(); + slider->setProperty("index", i+1); + slider->setOrientation(Qt::Vertical); + slider->setMinimum(0); + slider->setSingleStep(1); + slider->setInvertedAppearance(true); + slider->setTickPosition(QSlider::TicksBothSides); + slider->setTickInterval(1); + slider->setMinimumSize(QSize(30, 50)); + slider->setMaximumSize(QSize(50, 50)); + if (IS_TARANIS(GetEepromInterface()->getBoard())) { + label->setText(switchesX9D[i]); + slider->setMaximum(i==5 ? 1 : 2); + } + else { + label->setText(switches9X[i]); + slider->setMaximum(i==0 ? 2 : 1); + } + ui->switchesStartupLayout->addWidget(label, 0, i+1); + ui->switchesStartupLayout->addWidget(slider, 1, i+1); + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int))); + startupSwitchesSliders << slider; + } + ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches)); + int ppmmax=GetEepromInterface()->getCapability(PPMFrameLength); if (ppmmax>0) { ui->ppmFrameLengthDSB->setMaximum(ppmmax); @@ -243,52 +216,6 @@ void Setup::tabModelEditSetup() } else { populateTTraceCB(ui->ttraceCB,model.thrTraceSrc); } - if (GetEepromInterface()->getCapability(RotaryEncoders)==0) { - ui->bcREaChkB->hide(); - ui->bcREbChkB->hide(); - } - if (GetEepromInterface()->getCapability(Pots)==3) { - ui->tswwarn0_CB->hide(); - ui->tswwarn0_label->hide(); - ui->tswwarn1_label->hide(); - ui->tswwarn2_label->hide(); - ui->tswwarn3_label->hide(); - ui->tswwarn4_label->hide(); - ui->tswwarn5_label->hide(); - ui->tswwarn6_label->hide(); - ui->tswwarn7_label->hide(); - ui->chkSA->hide(); - ui->chkSB->hide(); - ui->chkSC->hide(); - ui->chkSD->hide(); - ui->chkSE->hide(); - ui->chkSF->hide(); - ui->chkSG->hide(); - this->layout()->removeItem(ui->TaranisSwitchStartup); - ui->bcP4ChkB->hide(); - } else { - ui->swwarn0_CB->hide(); - ui->swwarn0_label->hide(); - ui->swwarn0_line->hide(); - ui->swwarn1_ChkB->hide(); - ui->swwarn1_line->hide(); - ui->swwarn2_ChkB->hide(); - ui->swwarn3_ChkB->hide(); - ui->swwarn4_CB->hide(); - ui->swwarn4_label->hide(); - ui->swwarn5_ChkB->hide(); - ui->swwarn6_ChkB->hide(); - ui->swwarn_line0->hide(); - ui->swwarn_line1->hide(); - ui->swwarn_line2->hide(); - ui->swwarn_line3->hide(); - ui->swwarn_line4->hide(); - ui->swwarn_line5->hide(); - this->layout()->removeItem(ui->StockSwitchStartup); - ui->bcP1ChkB->setText(tr("S1")); - ui->bcP2ChkB->setText(tr("S2")); - ui->bcP3ChkB->setText(tr("LS")); - } if (!GetEepromInterface()->getCapability(PerModelThrottleWarning)) { ui->thrwarnChkB->setDisabled(true); @@ -471,18 +398,6 @@ void Setup::tabModelEditSetup() ui->thrExpoChkB->setChecked(model.thrExpo); ui->thrTrimChkB->setChecked(model.thrTrim); - //center beep - ui->bcRUDChkB->setChecked(model.beepANACenter & BC_BIT_RUD); - ui->bcELEChkB->setChecked(model.beepANACenter & BC_BIT_ELE); - ui->bcTHRChkB->setChecked(model.beepANACenter & BC_BIT_THR); - ui->bcAILChkB->setChecked(model.beepANACenter & BC_BIT_AIL); - ui->bcP1ChkB->setChecked(model.beepANACenter & BC_BIT_P1); - ui->bcP2ChkB->setChecked(model.beepANACenter & BC_BIT_P2); - ui->bcP3ChkB->setChecked(model.beepANACenter & BC_BIT_P3); - ui->bcP4ChkB->setChecked(model.beepANACenter & BC_BIT_P4); - ui->bcREaChkB->setChecked(model.beepANACenter & BC_BIT_REA); - ui->bcREbChkB->setChecked(model.beepANACenter & BC_BIT_REB); - // PPM settings fields ui->ppmDelaySB->setEnabled(model.moduleData[0].protocol == PPM); ui->pulsePolCB->setCurrentIndex(model.moduleData[0].ppmPulsePol); @@ -996,8 +911,6 @@ void Setup::fssbEdited() emit modified(); } - - void Setup::on_modelVoice_SB_editingFinished() { model.modelVoice=ui->modelVoice_SB->value()-260; @@ -1316,66 +1229,86 @@ void Setup::on_modelImage_CB_currentIndexChanged(int index) } } -void Setup::startupSwitchEdited() +void Setup::update() { - if (GetEepromInterface()->getCapability(Pots)==3) { - uint8_t i= 0; - i|=(uint8_t)ui->swwarn0_CB->currentIndex(); - if (i==1) { - ui->swwarn1_ChkB->setDisabled(true) ; - ui->swwarn2_ChkB->setDisabled(true) ; - ui->swwarn3_ChkB->setDisabled(true) ; - ui->swwarn4_CB->setDisabled(true) ; - ui->swwarn5_ChkB->setDisabled(true) ; - ui->swwarn6_ChkB->setDisabled(true) ; + updateBeepCenter(); + updateStartupSwitches(); +} + +void Setup::updateBeepCenter() +{ + for (int i=0; isetChecked(model.beepANACenter & (0x01 << i)); + } +} + +void Setup::updateStartupSwitches() +{ + lock = true; + + unsigned int switchStates = model.switchWarningStates; + bool enabled = !(switchStates & 0x01); + ui->switchesStartupWarning_CB->setCurrentIndex(switchStates & 0x01); + switchStates >>= 1; + + for (int i=0; igetCapability(Switches)-1; i++) { + QSlider * slider = startupSwitchesSliders[i]; + slider->setEnabled(enabled); + if (IS_TARANIS(GetEepromInterface()->getBoard())) { + slider->setValue(i==5 ? (switchStates & 0x3)/2 : switchStates & 0x3); + switchStates >>= 2; } else { - ui->swwarn1_ChkB->setEnabled(true) ; - ui->swwarn2_ChkB->setEnabled(true) ; - ui->swwarn3_ChkB->setEnabled(true) ; - ui->swwarn4_CB->setEnabled(true) ; - ui->swwarn5_ChkB->setEnabled(true) ; - ui->swwarn6_ChkB->setEnabled(true) ; - i|=(ui->swwarn1_ChkB->isChecked() ? 1 : 0)<<1; - i|=(ui->swwarn2_ChkB->isChecked() ? 1 : 0)<<2; - i|=(ui->swwarn3_ChkB->isChecked() ? 1 : 0)<<3; - i|=((uint8_t)ui->swwarn4_CB->currentIndex() & 0x03)<<4; - i|=(ui->swwarn5_ChkB->isChecked() ? 1 : 0)<<6; - i|=(ui->swwarn6_ChkB->isChecked() ? 1 : 0)<<7; + slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1); + switchStates >>= (i==0 ? 2 : 1); } - model.switchWarningStates=i; } - else { - uint16_t i= 0; - i|=(uint16_t)ui->tswwarn0_CB->currentIndex(); - if (i==1) { - ui->chkSA->setDisabled(true); - ui->chkSB->setDisabled(true); - ui->chkSC->setDisabled(true); - ui->chkSD->setDisabled(true); - ui->chkSE->setDisabled(true); - ui->chkSF->setDisabled(true); - ui->chkSG->setDisabled(true); + + lock = false; +} + +void Setup::startupSwitchEdited(int value) +{ + if (!lock) { + int shift = 0; + 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); + else { + shift = index*2 - 1; + mask = 0x03 << shift; + } } else { - ui->chkSA->setEnabled(true); - ui->chkSB->setEnabled(true); - ui->chkSC->setEnabled(true); - ui->chkSD->setEnabled(true); - ui->chkSE->setEnabled(true); - ui->chkSF->setEnabled(true); - ui->chkSG->setEnabled(true); - i|=(((uint16_t)ui->chkSA->value())<<1); - i|=(((uint16_t)ui->chkSB->value())<<3); - i|=(((uint16_t)ui->chkSC->value())<<5); - i|=(((uint16_t)ui->chkSD->value())<<7); - i|=(((uint16_t)ui->chkSE->value())<<9); - i|=(((uint16_t)ui->chkSF->value())<<12); - i|=(((uint16_t)ui->chkSG->value())<<13); + if (index == 1) { + shift = 1; + mask = 0x03 << shift; + } + else { + mask = 0x01 << (index+1); + } } - model.switchWarningStates=i; + + model.switchWarningStates &= ~mask; + + if (value) { + if (shift == 0) { + model.switchWarningStates |= mask; + } + else { + model.switchWarningStates |= (value << shift); + } + } + + updateStartupSwitches(); + emit modified(); } - emit modified(); } void Setup::on_thrTrimChkB_toggled(bool checked) @@ -1390,103 +1323,15 @@ void Setup::on_thrExpoChkB_toggled(bool checked) emit modified(); } -void Setup::on_bcRUDChkB_toggled(bool checked) +void Setup::onBeepCenterToggled(bool checked) { - if(checked) { - model.beepANACenter |= BC_BIT_RUD; - } else { - model.beepANACenter &= ~BC_BIT_RUD; - } + if (!lock) { + int index = sender()->property("index").toInt(); + unsigned int mask = (0x01 << index); + if (checked) + model.beepANACenter |= mask; + else + model.beepANACenter &= ~mask; emit modified(); + } } - -void Setup::on_bcELEChkB_toggled(bool checked) -{ - if(checked) { - model.beepANACenter |= BC_BIT_ELE; - } else { - model.beepANACenter &= ~BC_BIT_ELE; - } - emit modified(); -} - -void Setup::on_bcTHRChkB_toggled(bool checked) -{ - if(checked) { - model.beepANACenter |= BC_BIT_THR; - } else { - model.beepANACenter &= ~BC_BIT_THR; - } - emit modified(); -} - -void Setup::on_bcAILChkB_toggled(bool checked) -{ - if(checked) { - model.beepANACenter |= BC_BIT_AIL; - } else { - model.beepANACenter &= ~BC_BIT_AIL; - } - emit modified(); -} - -void Setup::on_bcP1ChkB_toggled(bool checked) -{ - if(checked) { - model.beepANACenter |= BC_BIT_P1; - } else { - model.beepANACenter &= ~BC_BIT_P1; - } - emit modified(); -} - -void Setup::on_bcP2ChkB_toggled(bool checked) -{ - if(checked) { - model.beepANACenter |= BC_BIT_P2; - } else { - model.beepANACenter &= ~BC_BIT_P2; - } - emit modified(); -} - -void Setup::on_bcP3ChkB_toggled(bool checked) -{ - if(checked) { - model.beepANACenter |= BC_BIT_P3; - } else { - model.beepANACenter &= ~BC_BIT_P3; - } - emit modified(); -} - -void Setup::on_bcP4ChkB_toggled(bool checked) -{ - if(checked) { - model.beepANACenter |= BC_BIT_P4; - } else { - model.beepANACenter &= ~BC_BIT_P4; - } - emit modified(); -} - -void Setup::on_bcREaChkB_toggled(bool checked) -{ - if(checked) { - model.beepANACenter |= BC_BIT_REA; - } else { - model.beepANACenter &= ~BC_BIT_REA; - } - emit modified(); -} - -void Setup::on_bcREbChkB_toggled(bool checked) -{ - if(checked) { - model.beepANACenter |= BC_BIT_REB; - } else { - model.beepANACenter &= ~BC_BIT_REB; - } - emit modified(); -} - diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index 87b3cc843..7b33a3af0 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -2,6 +2,9 @@ #define SETUP_H #include "modelpanel.h" +#include +#include +#include namespace Ui { class Setup; @@ -15,6 +18,8 @@ class Setup : public ModelPanel Setup(QWidget *parent, ModelData & model); virtual ~Setup(); + virtual void update(); + private slots: void on_protocolCB_currentIndexChanged(int index); void on_protocolCB_2_currentIndexChanged(int index); @@ -74,23 +79,16 @@ class Setup : public ModelPanel void on_timer2ModeBCB_currentIndexChanged(int index); void on_modelNameLE_editingFinished(); void on_modelImage_CB_currentIndexChanged(int index); - - void on_bcRUDChkB_toggled(bool checked); - void on_bcELEChkB_toggled(bool checked); - void on_bcTHRChkB_toggled(bool checked); - void on_bcAILChkB_toggled(bool checked); - void on_bcP1ChkB_toggled(bool checked); - void on_bcP2ChkB_toggled(bool checked); - void on_bcP3ChkB_toggled(bool checked); - void on_bcP4ChkB_toggled(bool checked); - void on_bcREaChkB_toggled(bool checked); - void on_bcREbChkB_toggled(bool checked); - - void startupSwitchEdited(); + void onBeepCenterToggled(bool checked); + void startupSwitchEdited(int value); private: Ui::Setup *ui; + QVector startupSwitchesSliders; + QVector centerBeepCheckboxes; void tabModelEditSetup(); + void updateStartupSwitches(); + void updateBeepCenter(); }; #endif // SETUP_H diff --git a/companion/src/modeledit/setup.ui b/companion/src/modeledit/setup.ui index 94dbaadfb..82f67f43b 100644 --- a/companion/src/modeledit/setup.ui +++ b/companion/src/modeledit/setup.ui @@ -8,6 +8,14 @@ true + + + 0 + 0 + 968 + 660 + + 0 @@ -225,784 +233,8 @@ - - - - 0 - - - 6 - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - 3POS - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Check - - - Qt::AlignCenter - - - - - - - Qt::LeftToRight - - - THR - - - - - - - - ON - - - - - OFF - - - - - - - - Qt::LeftToRight - - - RUD - - - - - - - Qt::LeftToRight - - - ELE - - - - - - - Qt::LeftToRight - - - AIL - - - - - - - Qt::LeftToRight - - - GEA - - - - - - - true - - - - ID0 - - - - - ID1 - - - - - ID2 - - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - - QLayout::SetMinimumSize - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - ON - - - - - OFF - - - - - - - - - 0 - 0 - - - - SB - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - SD - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - SA - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Check - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - SC - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - SG - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - SE - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - SF - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 1 - - - 1 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - - - REa - - - - - - - RUD - - - - - - - ELE - - - - - - - THR - - - - - - - AIL - - - - - - - P1 - - - - - - - P2 - - - - - - - P3 - - - - - - - REb - - - - - - - RS - - - - + @@ -2405,6 +1637,55 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi + + + + QLayout::SetMinimumSize + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + ON + + + + + OFF + + + + + + + + + 0 + 0 + + + + Check + + + Qt::AlignCenter + + + + +