From a61a7228da7b86ccdaea9dad06564f5024ca193b Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 10 Mar 2015 22:58:51 +0100 Subject: [PATCH] [Companion] Latest changes taken into account --- companion/src/eepromimportexport.h | 40 +- companion/src/eeprominterface.cpp | 30 +- companion/src/eeprominterface.h | 62 +- .../src/firmwares/opentx/opentxeeprom.cpp | 120 +- companion/src/firmwares/opentx/opentxeeprom.h | 2 +- .../src/firmwares/opentx/opentxinterface.cpp | 28 +- companion/src/generaledit/calibration.cpp | 237 ++-- companion/src/generaledit/calibration.h | 15 +- companion/src/generaledit/calibration.ui | 1129 +++++++++-------- companion/src/generaledit/generaledit.cpp | 2 +- companion/src/helpers.cpp | 4 +- companion/src/modeledit/setup.cpp | 123 +- companion/src/shared/autocombobox.h | 13 +- 13 files changed, 973 insertions(+), 832 deletions(-) diff --git a/companion/src/eepromimportexport.h b/companion/src/eepromimportexport.h index 645ca6818..7f64a5a5b 100644 --- a/companion/src/eepromimportexport.h +++ b/companion/src/eepromimportexport.h @@ -104,10 +104,10 @@ class ProxyField: public DataField { }; -template -class UnsignedField: public DataField { +template +class BaseUnsignedField: public DataField { public: - explicit UnsignedField(unsigned int & field): + explicit BaseUnsignedField(container & field): DataField("Unsigned"), field(field), min(0), @@ -115,7 +115,7 @@ class UnsignedField: public DataField { { } - UnsignedField(unsigned int & field, const char *name): + BaseUnsignedField(container & field, const char *name): DataField(name), field(field), min(0), @@ -123,7 +123,7 @@ class UnsignedField: public DataField { { } - UnsignedField(unsigned int & field, unsigned int min, unsigned int max, const char *name="Unsigned"): + BaseUnsignedField(container & field, unsigned int min, unsigned int max, const char *name="Unsigned"): DataField(name), field(field), min(min), @@ -133,7 +133,7 @@ class UnsignedField: public DataField { virtual void ExportBits(QBitArray & output) { - unsigned int value = field; + container value = field; if (value > max) value = max; if (value < min) value = min; @@ -159,12 +159,32 @@ class UnsignedField: public DataField { } protected: - unsigned int & field; - unsigned int min; - unsigned int max; + container & field; + container min; + container max; private: - UnsignedField(); + BaseUnsignedField(); +}; + +template +class UnsignedField : public BaseUnsignedField +{ + public: + explicit UnsignedField(unsigned int & field): + BaseUnsignedField(field) + { + } + + UnsignedField(unsigned int & field, const char *name): + BaseUnsignedField(field, name) + { + } + + UnsignedField(unsigned int & field, unsigned int min, unsigned int max, const char *name="Unsigned"): + BaseUnsignedField(field, min, max, name) + { + } }; template diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 7df295d20..b62ddcd76 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -16,7 +16,7 @@ std::list EEPROMWarnings; const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" }; -const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN" }; +const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SP", "SQ", "SR" }; const char leftArrow[] = {(char)0xE2, (char)0x86, (char)0x90, 0}; const char rightArrow[] = {(char)0xE2, (char)0x86, (char)0x92, 0}; const char upArrow[] = {(char)0xE2, (char)0x86, (char)0x91, 0}; @@ -405,12 +405,16 @@ 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 potsTaranisX9E[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), QObject::tr("S4"), QObject::tr("LS"), QObject::tr("RS"), QObject::tr("LS2"), QObject::tr("RS2") }; static const QString potsTaranis[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), QObject::tr("LS"), QObject::tr("RS") }; - if (index < 4) return CHECK_IN_ARRAY(sticks, index); + else if (IS_TARANIS_X9E(GetEepromInterface()->getBoard())) + return CHECK_IN_ARRAY(potsTaranisX9E, index-4); + else if (IS_TARANIS(GetEepromInterface()->getBoard())) + return CHECK_IN_ARRAY(potsTaranis, index-4); else - return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(potsTaranis, index-4) : CHECK_IN_ARRAY(pots9X, index-4)); + return CHECK_IN_ARRAY(pots9X, index-4); } QString RotaryEncoderString(int index) @@ -1002,12 +1006,10 @@ bool GeneralSettings::switchPositionAllowedTaranis(int index) const if (index == 0) return true; SwitchInfo info = switchInfoFromSwitchPositionTaranis(abs(index)); - if (index < 0 && switchConfigTaranis(info.index) != SWITCH_3POS) + if (index < 0 && switchConfig[info.index] != SWITCH_3POS) return false; - else if (info.index >= 8) - return switchConfigTaranis(info.index-8) == SWITCH_2x2POS; else if (info.position == 1) - return switchConfigTaranis(info.index) == SWITCH_3POS; + return switchConfig[info.index] == SWITCH_3POS; else return true; } @@ -1027,8 +1029,18 @@ GeneralSettings::GeneralSettings() BoardEnum board = GetEepromInterface()->getBoard(); if (IS_TARANIS(board)) { - potsType[0] = 1; - potsType[1] = 1; + potConfig[0] = POT_WITH_DETENT; + potConfig[1] = POT_WITH_DETENT; + sliderConfig[0] = SLIDER_WITH_DETENT; + sliderConfig[1] = SLIDER_WITH_DETENT; + switchConfig[0] = SWITCH_3POS; + switchConfig[1] = SWITCH_3POS; + switchConfig[2] = SWITCH_3POS; + switchConfig[3] = SWITCH_3POS; + switchConfig[4] = SWITCH_3POS; + switchConfig[5] = SWITCH_2POS; + switchConfig[6] = SWITCH_3POS; + switchConfig[7] = SWITCH_TOGGLE; } if (IS_ARM(board)) { diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 34186c882..96da8cc1c 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -62,6 +62,7 @@ QString getBoardName(BoardEnum board); #define IS_9XRPRO(board) (board==BOARD_9XRPRO) #define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E) #define IS_TARANIS_PLUS(board) (board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E) +#define IS_TARANIS_X9E(board) (board==BOARD_TARANIS_X9E) #define IS_ARM(board) (IS_TARANIS(board) || IS_SKY9X(board)) const uint8_t modn12x3[4][4]= { @@ -198,7 +199,7 @@ enum HeliSwashTypes { #define NUM_STICKS 4 #define BOARD_9X_NUM_POTS 3 -#define C9X_NUM_POTS 5 +#define C9X_NUM_POTS 8 #define NUM_CAL_PPM 4 #define NUM_CYC 3 #define C9X_NUM_SWITCHES 10 @@ -1013,9 +1014,10 @@ class ModelData { SwashRingData swashRingData; unsigned int thrTraceSrc; unsigned int modelId; - unsigned int switchWarningStates; + uint64_t switchWarningStates; unsigned int switchWarningEnable; - unsigned int nPotsToWarn; + unsigned int potsWarningMode; + bool potsWarningEnabled[C9X_NUM_POTS]; int potPosition[C9X_NUM_POTS]; bool displayChecklist; // TODO structure @@ -1087,12 +1089,23 @@ class GeneralSettings { BEEPER_ALL = 1 }; + enum PotConfig { + POT_NONE, + POT_WITH_DETENT, + POT_MULTIPOS_SWITCH, + POT_WITHOUT_DETENT + }; + + enum SliderConfig { + SLIDER_NONE, + SLIDER_WITH_DETENT + }; + enum SwitchConfig { - SWITCH_DEFAULT, + SWITCH_NONE, SWITCH_TOGGLE, SWITCH_2POS, SWITCH_3POS, - SWITCH_2x2POS }; GeneralSettings(); @@ -1179,12 +1192,15 @@ class GeneralSettings { unsigned int mavbaud; unsigned int switchUnlockStates; unsigned int hw_uartMode; - unsigned int potsType[8]; unsigned int backlightColor; CustomFunctionData customFn[C9X_MAX_CUSTOM_FUNCTIONS]; - unsigned int switchConfig[8]; - char switchNames[32][3+1]; - char anaNames[32][3+1]; + char switchName[18][3+1]; + unsigned int switchConfig[18]; + char stickName[4][3+1]; + char potName[4][3+1]; + unsigned int potConfig[4]; + char sliderName[4][3+1]; + unsigned int sliderConfig[4]; struct SwitchInfo { SwitchInfo(unsigned int index, unsigned int position): @@ -1198,33 +1214,6 @@ class GeneralSettings { static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index); bool switchPositionAllowedTaranis(int index) const; - - static unsigned int switchDefaultConfigTaranis(unsigned int index) - { - if (index == 5) - return SWITCH_2POS; - else if (index == 7) - return SWITCH_TOGGLE; - else - return SWITCH_3POS; - } - - unsigned int switchConfigTaranis(unsigned int index) const - { - unsigned int result = switchConfig[index]; - if (result == SWITCH_DEFAULT) - result = switchDefaultConfigTaranis(index); - return result; - } - - bool isSwitchWarningAllowedTaranis(unsigned int index) const - { - if (index < 8) - return switchConfigTaranis(index) != SWITCH_TOGGLE; - else - return switchConfig[index-8] == SWITCH_2x2POS; - } - }; class RadioData { @@ -1250,6 +1239,7 @@ enum Capability { MultiLangVoice, ModelImage, Pots, + Sliders, Switches, SwitchesPositions, LogicalSwitches, diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 20ae50cac..e319a9730 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -11,8 +11,9 @@ #define HAS_PERSISTENT_TIMERS(board) (IS_ARM(board) || IS_2560(board)) #define HAS_LARGE_LCD(board) IS_TARANIS(board) #define MAX_VIEWS(board) (HAS_LARGE_LCD(board) ? 2 : 256) -#define MAX_POTS(board) (IS_TARANIS(board) ? 5 : 3) -#define MAX_SWITCHES(board, version) (version >= 217 ? (IS_TARANIS(board) ? 8+6 : 7) : (IS_TARANIS(board) ? 8 : 7)) +#define MAX_POTS(board) (IS_TARANIS(board) ? (IS_TARANIS_X9E(board) ? 4 : 3) : 3) +#define MAX_SLIDERS(board) (IS_TARANIS(board) ? (IS_TARANIS_X9E(board) ? 4 : 2) : 0) +#define MAX_SWITCHES(board, version) (IS_TARANIS(board) ? (IS_TARANIS_X9E(board) ? 18 : 8) : 7) #define MAX_SWITCHES_POSITION(board, version) (IS_TARANIS(board) ? (version >= 217 ? 22+12 : 22) : 9) #define MAX_ROTARY_ENCODERS(board) (IS_2560(board) ? 2 : (IS_SKY9X(board) ? 1 : 0)) #define MAX_FLIGHT_MODES(board, version) (IS_ARM(board) ? 9 : (IS_DBLRAM(board, version) ? 6 : 5)) @@ -211,9 +212,7 @@ class SourcesConversionTable: public ConversionTable { } } - for (int i=0; i<4+MAX_POTS(board); i++) { - if (IS_TARANIS(board) && version < 216 && i==6) - continue; + for (int i=0; i class SwitchesWarningField: public TransformedField { public: - SwitchesWarningField(unsigned int & sw, BoardEnum board, unsigned int version): + SwitchesWarningField(uint64_t & sw, BoardEnum board, unsigned int version): TransformedField(internalField), internalField(_sw, "SwitchesWarning"), sw(sw), @@ -1971,9 +1970,9 @@ class SwitchesWarningField: public TransformedField { } protected: - UnsignedField internalField; - unsigned int &sw; - unsigned int _sw; + BaseUnsignedField internalField; + uint64_t &sw; + uint64_t _sw; BoardEnum board; unsigned int version; }; @@ -2903,16 +2902,16 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne internalField.Append(new UnsignedField<8>(modelData.modelId)); } - if (IS_TARANIS(board) && version >= 217) - internalField.Append(new SwitchesWarningField<32>(modelData.switchWarningStates, board, version)); + if (IS_TARANIS_X9E(board) && version >= 217) + internalField.Append(new SwitchesWarningField<64>(modelData.switchWarningStates, board, version)); else if (IS_TARANIS(board)) internalField.Append(new SwitchesWarningField<16>(modelData.switchWarningStates, board, version)); else internalField.Append(new SwitchesWarningField<8>(modelData.switchWarningStates, board, version)); - if (IS_TARANIS(board) && version >= 217) - internalField.Append(new UnsignedField<16>(modelData.switchWarningEnable)); + if (IS_TARANIS_X9E(board) && version >= 217) + internalField.Append(new UnsignedField<32>(modelData.switchWarningEnable)); else if (version >= 216) internalField.Append(new UnsignedField<8>(modelData.switchWarningEnable)); @@ -2948,8 +2947,15 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne if (IS_TARANIS(board)) { modulesCount = 3; - internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[1].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol"))); - internalField.Append(new UnsignedField<8>(modelData.trainerMode)); + if (version >= 217) { + internalField.Append(new ConversionField< SignedField<3> >(modelData.moduleData[1].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol"))); + internalField.Append(new UnsignedField<3>(modelData.trainerMode)); + internalField.Append(new UnsignedField<2>(modelData.potsWarningMode)); + } + else { + internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[1].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol"))); + internalField.Append(new UnsignedField<8>(modelData.trainerMode)); + } } else if (IS_ARM(board) && version >= 216) { modulesCount = 3; @@ -3005,8 +3011,26 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne } } + if (IS_ARM(board) && version >= 217) { + int size = IS_TARANIS_X9E(board) ? 32 : 8; + for (int i=0; i(modelData.potsWarningEnabled[i])); + else + internalField.Append(new SpareBitsField<1>()); + } + } + else if (IS_ARM(board) && version >= 216) { + for (int i=0; i<6; i++) { + if (i < MAX_POTS(board)+MAX_SLIDERS(board)) + internalField.Append(new BoolField<1>(modelData.potsWarningEnabled[i])); + else + internalField.Append(new SpareBitsField<1>()); + } + internalField.Append(new UnsignedField<2>(modelData.potsWarningMode)); + } + if (IS_ARM(board) && version >= 216) { - internalField.Append(new UnsignedField<8>(modelData.nPotsToWarn)); for (int i=0; i < GetCurrentFirmware()->getCapability(Pots); i++) { internalField.Append(new SignedField<8>(modelData.potPosition[i])); } @@ -3076,7 +3100,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo generalData(generalData), board(board), version(version), - inputsCount(4 + MAX_POTS(board)) + inputsCount(NUM_STICKS+MAX_POTS(board)+MAX_SLIDERS(board)) { generalData.version = version; generalData.variant = variant; @@ -3219,19 +3243,32 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo internalField.Append(new SignedField<8>(generalData.backgroundVolume)); } if (IS_TARANIS(board) && version >= 216) { - internalField.Append(new UnsignedField<8>(generalData.hw_uartMode)); + if (version >= 217) { + internalField.Append(new UnsignedField<6>(generalData.hw_uartMode)); + if (IS_TARANIS_X9E(board)) { + internalField.Append(new UnsignedField<1>(generalData.sliderConfig[2])); + internalField.Append(new UnsignedField<1>(generalData.sliderConfig[3])); + } + else { + internalField.Append(new SpareBitsField<2>()); + } + } + else { + internalField.Append(new UnsignedField<8>(generalData.hw_uartMode)); + } for (int i=0; i<4; i++) { - internalField.Append(new UnsignedField<2>(potsType[i])); + if (i < MAX_POTS(board)) + internalField.Append(new UnsignedField<2>(generalData.potConfig[i])); + else + internalField.Append(new SpareBitsField<2>()); } internalField.Append(new UnsignedField<8>(generalData.backlightColor)); } - if (IS_TARANIS(board)) { - if (version >= 217) - internalField.Append(new SpareBitsField<32>()); - else - internalField.Append(new SpareBitsField<16>()); - } + if (IS_TARANIS_X9E(board)) + internalField.Append(new SpareBitsField<64>()); + else if (IS_TARANIS(board)) + internalField.Append(new SpareBitsField<16>()); if (version >= 217) { for (int i=0; i= 217) { - for (int i=0; i<8; i++) { - internalField.Append(new UnsignedField<4>(generalData.switchConfig[i])); + for (int i=0; i(generalData.switchConfig[i])); + } + if (IS_TARANIS_X9E(board)) { + internalField.Append(new SpareBitsField<64-2*18>()); } for (int i=0; i(generalData.switchNames[i])); + internalField.Append(new ZCharField<3>(generalData.switchName[i])); } - for (int i=0; i(generalData.anaNames[i])); + for (int i=0; i(generalData.stickName[i])); + } + for (int i=0; i(generalData.potName[i])); + } + for (int i=0; i(generalData.sliderName[i])); } } } @@ -3266,13 +3312,6 @@ void OpenTxGeneralData::beforeExport() sum += generalData.calibSpanPos[i]; if (++count == 12) break; } - if (IS_TARANIS(board)) { - for (int i=0; i<4; i++) { - potsType[i] = generalData.potsType[i]; - if (i<2 && potsType[i] == 1) - potsType[i] = 0; - } - } } else { for (int i=0; igetBoard())) { + if (IS_TARANIS_X9E(firmware->getBoard())) { + enabled = true; + type->addItem(tr("None"), GeneralSettings::SWITCH_NONE); + } + else if (index < 8) { + enabled = true; + } + } + + if (enabled) { + type->addItem(tr("2 Positions Toggle"), GeneralSettings::SWITCH_TOGGLE); + type->addItem(tr("2 Positions"), GeneralSettings::SWITCH_2POS); + type->addItem(tr("3 Positions"), GeneralSettings::SWITCH_3POS); + name->setField(generalSettings.switchName[index], 3, this); + type->setField(generalSettings.switchConfig[index], this); + } + else { + label->hide(); + name->hide(); + type->hide(); + } +} + +void CalibrationPanel::setupPotConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type) +{ + bool enabled = false; + + if (IS_TARANIS_X9E(firmware->getBoard()) && index < 4) { + enabled = true; + } + else if (IS_TARANIS_PLUS(firmware->getBoard()) && index < 3) { + enabled = true; + } + else if (IS_TARANIS(firmware->getBoard()) && index < 2) { + enabled = true; + } + + if (enabled) { + type->addItem(tr("None"), GeneralSettings::POT_NONE); + type->addItem(tr("Pot with detent"), GeneralSettings::POT_WITH_DETENT); + type->addItem(tr("Multipos switch"), GeneralSettings::POT_MULTIPOS_SWITCH); + type->addItem(tr("Pot without detent"), GeneralSettings::POT_WITHOUT_DETENT); + name->setField(generalSettings.potName[index], 3, this); + type->setField(generalSettings.potConfig[index], this); + } + else { + label->hide(); + name->hide(); + type->hide(); + } +} + +void CalibrationPanel::setupSliderConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type) +{ + bool enabled = false; + + if (IS_TARANIS(firmware->getBoard()) && index < 2) { + type->setEnabled(false); + enabled = true; + } + else if (IS_TARANIS_X9E(firmware->getBoard()) && index < 4) { + enabled = true; + } + + if (enabled) { + type->addItem(tr("None"), GeneralSettings::SLIDER_NONE); + type->addItem(tr("Slider with detent"), GeneralSettings::SLIDER_WITH_DETENT); + name->setField(generalSettings.sliderName[index], 3, this); + type->setField(generalSettings.sliderConfig[index], this); + } + else { + label->hide(); + name->hide(); + type->hide(); + } +} + CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware): GeneralPanel(parent, generalSettings, firmware), ui(new Ui::Calibration) { ui->setupUi(this); - if (firmware->getCapability(MultiposPots)) { - ui->pot1Type->setCurrentIndex(generalSettings.potsType[0]); - ui->pot2Type->setCurrentIndex(generalSettings.potsType[1]); - ui->pot3Type->setCurrentIndex(generalSettings.potsType[2]); - } - else { + if (!firmware->getCapability(MultiposPots)) { ui->potsTypeSeparator->hide(); - ui->pot1Type->hide(); - ui->pot1TypeLabel->hide(); - ui->pot2Type->hide(); - ui->pot2TypeLabel->hide(); - ui->pot3Type->hide(); - ui->pot3TypeLabel->hide(); - ui->pot4Label->hide(); - ui->pot5Label->hide(); } if (IS_TARANIS(firmware->getBoard())) { - ui->rudName->setField(generalSettings.anaNames[0], 3, this); - ui->eleName->setField(generalSettings.anaNames[1], 3, this); - ui->thrName->setField(generalSettings.anaNames[2], 3, this); - ui->ailName->setField(generalSettings.anaNames[3], 3, this); - ui->pot1Name->setField(generalSettings.anaNames[4], 3, this); - ui->pot2Name->setField(generalSettings.anaNames[5], 3, this); - ui->pot3Name->setField(generalSettings.anaNames[6], 3, this); - ui->pot4Name->setField(generalSettings.anaNames[7], 3, this); - ui->pot5Name->setField(generalSettings.anaNames[8], 3, this); - ui->saName->setField(generalSettings.switchNames[0], 3, this); - ui->saType->setField(generalSettings.switchConfig[0], this); - ui->sbName->setField(generalSettings.switchNames[1], 3, this); - ui->sbType->setField(generalSettings.switchConfig[1], this); - ui->scName->setField(generalSettings.switchNames[2], 3, this); - ui->scType->setField(generalSettings.switchConfig[2], this); - ui->sdName->setField(generalSettings.switchNames[3], 3, this); - ui->sdType->setField(generalSettings.switchConfig[3], this); - ui->seName->setField(generalSettings.switchNames[4], 3, this); - ui->seType->setField(generalSettings.switchConfig[4], this); - ui->sfName->setField(generalSettings.switchNames[5], 3, this); - ui->sfType->setField(generalSettings.switchConfig[5], this); - ui->sgName->setField(generalSettings.switchNames[6], 3, this); - ui->sgType->setField(generalSettings.switchConfig[6], this); - ui->shName->setField(generalSettings.switchNames[7], 3, this); - ui->shType->setField(generalSettings.switchConfig[7], this); - ui->siName->setField(generalSettings.switchNames[8], 3, this); - ui->sjName->setField(generalSettings.switchNames[9], 3, this); - ui->skName->setField(generalSettings.switchNames[10], 3, this); - ui->slName->setField(generalSettings.switchNames[11], 3, this); - ui->smName->setField(generalSettings.switchNames[12], 3, this); - ui->snName->setField(generalSettings.switchNames[13], 3, this); - connect(ui->saType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); - connect(ui->sbType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); - connect(ui->scType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); - connect(ui->sdType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); - connect(ui->seType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); - connect(ui->sgType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); + ui->rudName->setField(generalSettings.stickName[0], 3, this); + ui->eleName->setField(generalSettings.stickName[1], 3, this); + ui->thrName->setField(generalSettings.stickName[2], 3, this); + ui->ailName->setField(generalSettings.stickName[3], 3, this); } else { ui->rudLabel->hide(); @@ -72,46 +108,39 @@ CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSe ui->thrName->hide(); ui->ailLabel->hide(); ui->ailName->hide(); - ui->pot1Name->hide(); - ui->pot2Name->hide(); - ui->pot3Name->hide(); - ui->pot4Name->hide(); - ui->pot5Name->hide(); - ui->saLabel->hide(); - ui->saName->hide(); - ui->saType->hide(); - ui->sbLabel->hide(); - ui->sbName->hide(); - ui->sbType->hide(); - ui->scLabel->hide(); - ui->scName->hide(); - ui->scType->hide(); - ui->sdLabel->hide(); - ui->sdName->hide(); - ui->sdType->hide(); - ui->seLabel->hide(); - ui->seName->hide(); - ui->seType->hide(); - ui->sfLabel->hide(); - ui->sfName->hide(); - ui->sfType->hide(); - ui->sgLabel->hide(); - ui->sgName->hide(); - ui->sgType->hide(); - ui->shLabel->hide(); - ui->shName->hide(); - ui->shType->hide(); - ui->siName->hide(); - ui->sjName->hide(); - ui->skName->hide(); - ui->slName->hide(); - ui->smName->hide(); - ui->snName->hide(); } + setupPotConfig(0, ui->pot1Label, ui->pot1Name, ui->pot1Type); + setupPotConfig(1, ui->pot2Label, ui->pot2Name, ui->pot2Type); + setupPotConfig(2, ui->pot3Label, ui->pot3Name, ui->pot3Type); + setupPotConfig(3, ui->pot4Label, ui->pot4Name, ui->pot4Type); + + setupSliderConfig(0, ui->lsLabel, ui->lsName, ui->lsType); + setupSliderConfig(1, ui->rsLabel, ui->rsName, ui->rsType); + setupSliderConfig(2, ui->ls2Label, ui->ls2Name, ui->ls2Type); + setupSliderConfig(3, ui->rs2Label, ui->rs2Name, ui->rs2Type); + + setupSwitchConfig(0, ui->saLabel, ui->saName, ui->saType); + setupSwitchConfig(1, ui->sbLabel, ui->sbName, ui->sbType); + setupSwitchConfig(2, ui->scLabel, ui->scName, ui->scType); + setupSwitchConfig(3, ui->sdLabel, ui->sdName, ui->sdType); + setupSwitchConfig(4, ui->seLabel, ui->seName, ui->seType); + setupSwitchConfig(5, ui->sfLabel, ui->sfName, ui->sfType); + setupSwitchConfig(6, ui->sgLabel, ui->sgName, ui->sgType); + setupSwitchConfig(7, ui->shLabel, ui->shName, ui->shType); + setupSwitchConfig(8, ui->siLabel, ui->siName, ui->siType); + setupSwitchConfig(9, ui->sjLabel, ui->sjName, ui->sjType); + setupSwitchConfig(10, ui->skLabel, ui->skName, ui->skType); + setupSwitchConfig(11, ui->slLabel, ui->slName, ui->slType); + setupSwitchConfig(12, ui->smLabel, ui->smName, ui->smType); + setupSwitchConfig(13, ui->snLabel, ui->snName, ui->snType); + setupSwitchConfig(14, ui->soLabel, ui->soName, ui->soType); + setupSwitchConfig(15, ui->spLabel, ui->spName, ui->spType); + setupSwitchConfig(16, ui->sqLabel, ui->sqName, ui->sqType); + setupSwitchConfig(17, ui->srLabel, ui->srName, ui->srType); + int potsCount = GetCurrentFirmware()->getCapability(Pots); if (potsCount == 3) { - ui->label_pot4->hide(); ui->ana8Neg->hide(); ui->ana8Mid->hide(); ui->ana8Pos->hide(); @@ -133,22 +162,10 @@ CalibrationPanel::~CalibrationPanel() delete ui; } -void CalibrationPanel::update() +/*void CalibrationPanel::update() { - ui->siLabel->setVisible(generalSettings.switchConfig[0] == GeneralSettings::SWITCH_2x2POS); - ui->siName->setVisible(generalSettings.switchConfig[0] == GeneralSettings::SWITCH_2x2POS); - ui->sjLabel->setVisible(generalSettings.switchConfig[1] == GeneralSettings::SWITCH_2x2POS); - ui->sjName->setVisible(generalSettings.switchConfig[1] == GeneralSettings::SWITCH_2x2POS); - ui->skLabel->setVisible(generalSettings.switchConfig[2] == GeneralSettings::SWITCH_2x2POS); - ui->skName->setVisible(generalSettings.switchConfig[2] == GeneralSettings::SWITCH_2x2POS); - ui->slLabel->setVisible(generalSettings.switchConfig[3] == GeneralSettings::SWITCH_2x2POS); - ui->slName->setVisible(generalSettings.switchConfig[3] == GeneralSettings::SWITCH_2x2POS); - ui->smLabel->setVisible(generalSettings.switchConfig[4] == GeneralSettings::SWITCH_2x2POS); - ui->smName->setVisible(generalSettings.switchConfig[4] == GeneralSettings::SWITCH_2x2POS); - ui->snLabel->setVisible(generalSettings.switchConfig[6] == GeneralSettings::SWITCH_2x2POS); - ui->snName->setVisible(generalSettings.switchConfig[6] == GeneralSettings::SWITCH_2x2POS); } - +*/ void CalibrationPanel::on_PPM_MultiplierDSB_editingFinished() { generalSettings.PPM_Multiplier = (int)(ui->PPM_MultiplierDSB->value()*10)-10; @@ -377,24 +394,6 @@ void CalibrationPanel::on_ana8Pos_editingFinished() emit modified(); } -void CalibrationPanel::on_pot1Type_currentIndexChanged(int index) -{ - generalSettings.potsType[0] = index; - emit modified(); -} - -void CalibrationPanel::on_pot2Type_currentIndexChanged(int index) -{ - generalSettings.potsType[1] = index; - emit modified(); -} - -void CalibrationPanel::on_pot3Type_currentIndexChanged(int index) -{ - generalSettings.potsType[2] = index; - emit modified(); -} - void CalibrationPanel::on_serialPortMode_currentIndexChanged(int index) { generalSettings.hw_uartMode = index; diff --git a/companion/src/generaledit/calibration.h b/companion/src/generaledit/calibration.h index 67db4e85e..b2ceee604 100644 --- a/companion/src/generaledit/calibration.h +++ b/companion/src/generaledit/calibration.h @@ -7,6 +7,10 @@ namespace Ui { class Calibration; } +class QLabel; +class AutoLineEdit; +class AutoComboBox; + class CalibrationPanel : public GeneralPanel { Q_OBJECT @@ -14,7 +18,7 @@ class CalibrationPanel : public GeneralPanel public: CalibrationPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware); virtual ~CalibrationPanel(); - virtual void update(); + // virtual void update(); private slots: void on_battCalibDSB_editingFinished(); @@ -53,12 +57,13 @@ class CalibrationPanel : public GeneralPanel void on_ana7Pos_editingFinished(); void on_ana8Pos_editingFinished(); - void on_pot1Type_currentIndexChanged(int index); - void on_pot2Type_currentIndexChanged(int index); - void on_pot3Type_currentIndexChanged(int index); - void on_serialPortMode_currentIndexChanged(int index); + protected: + void setupPotConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type); + void setupSliderConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type); + void setupSwitchConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type); + private: Ui::Calibration *ui; diff --git a/companion/src/generaledit/calibration.ui b/companion/src/generaledit/calibration.ui index 1de906f85..0c832a7c0 100644 --- a/companion/src/generaledit/calibration.ui +++ b/companion/src/generaledit/calibration.ui @@ -6,51 +6,115 @@ 0 0 - 802 - 1036 + 805 + 1188 Form - - - - - + + + + + SQ + + + + + + 3 + + + + + + + SR + + + + + + + 3 + + + + + - - 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. + + -9999 + + + 9999 + + + + + + + 3 + + + + + + + LS2 + + + + + + + 3 + + + + + + + SP + + + + + + + 3 + + + + + + + SO + + + + + + + S4 + + + + + + + + + + -9999 + + + 9999 - - - None - - - - - Pot with detent (normal) - - - - - Multipos Switch - - - - - Pot without detent - - @@ -60,21 +124,21 @@ - - + + RS - + SB - + Serial Port @@ -91,7 +155,7 @@ - + @@ -108,34 +172,9 @@ 3 - Loud. 4 - Extra loud. - - - Default - - - - - 2POS Toggle - - - - - 2POS - - - - - 3POS - - - - - 2x2POS - - - + @@ -148,46 +187,7 @@ - - - - - - - - - - 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. - - - - None - - - - - Pot with detent (normal) - - - - - Multipos Switch - - - - - Pot without detent - - - - - + @@ -204,34 +204,9 @@ 3 - Loud. 4 - Extra loud. - - - Default - - - - - 2POS Toggle - - - - - 2POS - - - - - 3POS - - - - - 2x2POS - - - + @@ -260,46 +235,7 @@ - - - - - - - - - - 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. - - - - None - - - - - Pot with detent (normal) - - - - - Multipos Switch - - - - - Pot without detent - - - - - + 3 @@ -313,7 +249,7 @@ - + 3 @@ -327,8 +263,18 @@ - - + + + + Mid value + + + Qt::AlignCenter + + + + + @@ -401,7 +347,7 @@ - + PPM 1 @@ -481,7 +427,7 @@ - + PPM 2 @@ -521,19 +467,6 @@ - - - - - - - -9999 - - - 9999 - - - @@ -622,14 +555,14 @@ - + Battery - + @@ -651,14 +584,14 @@ - + PPM Multiplier - + @@ -677,7 +610,7 @@ - + @@ -696,7 +629,7 @@ - + @@ -715,7 +648,7 @@ - + @@ -734,21 +667,21 @@ - + PPM 3 - + PPM 4 - + -49 @@ -758,7 +691,7 @@ - + Current @@ -817,19 +750,6 @@ - - - - - - - -9999 - - - 9999 - - - @@ -843,32 +763,6 @@ - - - - - - - -9999 - - - 9999 - - - - - - - - - - -9999 - - - 9999 - - - @@ -882,6 +776,19 @@ + + + + + + + -9999 + + + 9999 + + + @@ -895,6 +802,19 @@ + + + + + + + -9999 + + + 9999 + + + @@ -905,26 +825,6 @@ - - - - Mid value - - - Qt::AlignCenter - - - - - - - Positive span - - - Qt::AlignCenter - - - @@ -938,27 +838,23 @@ + + + + Positive span + + + Qt::AlignCenter + + + - + S1 - - - - S2 - - - - - - - S3 - - - @@ -966,7 +862,21 @@ - + + + + S2 + + + + + + + S3 + + + + SA @@ -980,20 +890,6 @@ - - - - Ail - - - - - - - Thr - - - @@ -1001,6 +897,13 @@ + + + + Ail + + + @@ -1008,6 +911,13 @@ + + + + Thr + + + @@ -1015,35 +925,42 @@ - + + + + 3 + + + + SC - - + + + + 3 + + + + + LS - - + + 3 - - - - 3 - - - - + @@ -1054,48 +971,23 @@ - - - Default - - - - - 2POS Toggle - - - - - 2POS - - - - - 3POS - - - - - 2x2POS - - - - + + 3 - + SD - + @@ -1106,48 +998,23 @@ - - - Default - - - - - 2POS Toggle - - - - - 2POS - - - - - 3POS - - - - - 2x2POS - - - - + + 3 - + SE - + @@ -1158,48 +1025,23 @@ - - - Default - - - - - 2POS Toggle - - - - - 2POS - - - - - 3POS - - - - - 2x2POS - - - - + + 3 - + SF - + @@ -1210,48 +1052,23 @@ - - - Default - - - - - 2POS Toggle - - - - - 2POS - - - - - 3POS - - - - - 2x2POS - - - - + + 3 - + SG - + @@ -1262,190 +1079,107 @@ - - - Default - - - - - 2POS Toggle - - - - - 2POS - - - - - 3POS - - - - - 2x2POS - - - - - - 3 - - - - - - - SH - - - - - - - - - - - - - - - - - Default - - - - - 2POS Toggle - - - - - 2POS - - - - - 3POS - - - - - 2x2POS - - - - - + 3 - - + + - SI + SH - + 3 - - + + - SJ + SI - + 3 - - + + - SK + SJ - + 3 - - + + - SL + SK - + 3 - - + + - SM + SL - + 3 - - + + - SN + SM - + 3 - - - - 1 - - - 5.000000000000000 - - - 1.000000000000000 + + + + SN - + @@ -1458,7 +1192,7 @@ - + @@ -1471,6 +1205,335 @@ + + + + 1 + + + 5.000000000000000 + + + 1.000000000000000 + + + + + + + RS2 + + + + + + + 3 + + + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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. + + + + + + + + + + + + + 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. + + + + + + + + + + + + + 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. + + + + + + + + + + + + + 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. + + + + + + + + + + + + + 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. + + + + + + + + + + + + + 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. + + + + + + + + + + + + + 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. + + + + + + + + + + + + + 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. + + + diff --git a/companion/src/generaledit/generaledit.cpp b/companion/src/generaledit/generaledit.cpp index 38db64010..cd4625de2 100644 --- a/companion/src/generaledit/generaledit.cpp +++ b/companion/src/generaledit/generaledit.cpp @@ -43,7 +43,7 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir addTab(new CustomFunctionsPanel(this, NULL, generalSettings, firmware), tr("Global Functions")); } addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer")); - addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration")); + addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Hardware / Calibration")); } GeneralEdit::~GeneralEdit() diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 9d9345cde..8a5cad2a3 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -402,7 +402,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin } for (int i=GetCurrentFirmware()->getCapability(MultiposPots)-1; i>=0; i--) { - if (generalSettings.potsType[i] == 2/* TODO constant*/) { + if (generalSettings.potConfig[i] == GeneralSettings::POT_MULTIPOS_SWITCH) { for (int j=-GetCurrentFirmware()->getCapability(MultiposPotsPositions); j<0; j++) { item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i*GetCurrentFirmware()->getCapability(MultiposPotsPositions)+j); b->addItem(item.toString(), item.toValue()); @@ -441,7 +441,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin } for (int i=0; igetCapability(MultiposPots); i++) { - if (generalSettings.potsType[i] == 2/* TODO constant*/) { + if (generalSettings.potConfig[i] == GeneralSettings::POT_MULTIPOS_SWITCH) { for (int j=1; j<=GetCurrentFirmware()->getCapability(MultiposPotsPositions); j++) { item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i*GetCurrentFirmware()->getCapability(MultiposPotsPositions)+j); b->addItem(item.toString(), item.toValue()); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index c9296de3f..861f11d41 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -447,7 +447,7 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen // Beep Center checkboxes prevFocus = ui->trimsDisplay; - int analogs = 4 + firmware->getCapability(Pots); + int analogs = NUM_STICKS + firmware->getCapability(Pots) + firmware->getCapability(Sliders); for (int i=0; igetCapability(RotaryEncoders); i++) { QCheckBox * checkbox = new QCheckBox(this); checkbox->setProperty("index", i); @@ -455,8 +455,17 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen ui->centerBeepLayout->addWidget(checkbox, 0, i+1); connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool))); centerBeepCheckboxes << checkbox; - if (!IS_TARANIS_PLUS(board) && i==6) { - checkbox->hide(); + if (IS_TARANIS(board)) { + if (i >= NUM_STICKS && i < NUM_STICKS + firmware->getCapability(Pots)) { + if (generalSettings.potConfig[i-NUM_STICKS] == GeneralSettings::POT_NONE) { + checkbox->hide(); + } + } + else if (i >= NUM_STICKS + firmware->getCapability(Pots) && i < analogs) { + if (generalSettings.sliderConfig[i-NUM_STICKS-firmware->getCapability(Pots)] == GeneralSettings::SLIDER_NONE) { + checkbox->hide(); + } + } } QWidget::setTabOrder(prevFocus, checkbox); prevFocus = checkbox; @@ -464,35 +473,41 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen // Startup switches warnings for (int i=0; igetCapability(Switches); i++) { - if (!IS_TARANIS(firmware->getBoard()) && i==firmware->getCapability(Switches)-1) - continue; + if (IS_TARANIS(firmware->getBoard())) { + if (generalSettings.switchConfig[i] == GeneralSettings::SWITCH_NONE || generalSettings.switchConfig[i] == GeneralSettings::SWITCH_TOGGLE) { + continue; + } + } + else { + if (i==firmware->getCapability(Switches)-1) { + continue; + } + } QLabel * label = new QLabel(this); QSlider * slider = new QSlider(this); QCheckBox * cb = new QCheckBox(this); - if (IS_TARANIS(firmware->getBoard()) && !generalSettings.isSwitchWarningAllowedTaranis(i)) { - label->hide(); - slider->hide(); - cb->hide(); - } - slider->setProperty("index", i+1); + slider->setProperty("index", i); slider->setOrientation(Qt::Vertical); slider->setMinimum(0); - slider->setSingleStep(1); - slider->setPageStep(1); slider->setInvertedAppearance(true); slider->setTickPosition(QSlider::TicksBothSides); - slider->setTickInterval(1); slider->setMinimumSize(QSize(30, 50)); slider->setMaximumSize(QSize(50, 50)); if (IS_TARANIS(board)) { label->setText(switchesX9D[i]); - slider->setMaximum((i==5 || i>=7) ? 1 : 2); + slider->setMaximum(2); + slider->setSingleStep(generalSettings.switchConfig[i] == GeneralSettings::SWITCH_3POS ? 1 : 2); + slider->setPageStep(slider->singleStep()); + slider->setTickInterval(slider->singleStep()); } else { label->setText(switches9X[i]); slider->setMaximum(i==0 ? 2 : 1); + slider->setSingleStep(1); + slider->setPageStep(1); + slider->setTickInterval(1); } - cb->setProperty("index", i+1); + cb->setProperty("index", i); ui->switchesStartupLayout->addWidget(label, 0, i+1); ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter); ui->switchesStartupLayout->addWidget(slider, 1, i+1); @@ -512,15 +527,22 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen // Pot warnings prevFocus = ui->potWarningMode; if (IS_TARANIS(board)) { - for (int i=0; igetCapability(Pots); i++) { + for (int i=0; igetCapability(Pots)+firmware->getCapability(Sliders); i++) { QCheckBox * cb = new QCheckBox(this); - cb->setProperty("index", i+1); + cb->setProperty("index", i); cb->setText(AnalogString(i+4)); ui->potWarningLayout->addWidget(cb, 0, i+1); connect(cb, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool))); potWarningCheckboxes << cb; - if (!IS_TARANIS_PLUS(board) && i==2) { - cb->hide(); + if (i < firmware->getCapability(Pots)) { + if (generalSettings.potConfig[i] == GeneralSettings::POT_NONE) { + cb->hide(); + } + } + else { + if (generalSettings.sliderConfig[i-firmware->getCapability(Pots)] == GeneralSettings::SLIDER_NONE) { + cb->hide(); + } } QWidget::setTabOrder(prevFocus, cb); prevFocus = cb; @@ -712,24 +734,13 @@ void SetupPanel::updateStartupSwitches() { lock = true; - unsigned int switchStates = model->switchWarningStates; - - for (int i=0; igetCapability(Switches); i++) { - if (!IS_TARANIS(firmware->getBoard()) && i==firmware->getCapability(Switches)-1) - continue; - QSlider * slider = startupSwitchesSliders[i]; + for (int i=0; iswitchWarningEnable & (1 << i)); + int index = slider->property("index").toInt(); + bool enabled = !(model->switchWarningEnable & (1 << index)); slider->setEnabled(enabled); cb->setChecked(enabled); - if (IS_TARANIS(GetEepromInterface()->getBoard())) { - slider->setValue((i==5 || i>=7) ? (switchStates & 0x3)/2 : switchStates & 0x3); - switchStates >>= 2; - } - else { - slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1); - switchStates >>= (i==0 ? 2 : 1); - } } lock = false; @@ -743,15 +754,8 @@ void SetupPanel::startupSwitchEdited(int value) int index = sender()->property("index").toInt(); if (IS_TARANIS(GetEepromInterface()->getBoard())) { - if (index == 6 || index >= 8) { - shift = (index - 1) * 2; - mask = 0x02 << shift; - shift++; - } - else { - shift = (index - 1) * 2; - mask = 0x03 << shift; - } + shift = index * 2; + mask = 0x03 << shift; } else { if (index == 1) { @@ -777,7 +781,7 @@ void SetupPanel::startupSwitchEdited(int value) void SetupPanel::startupSwitchToggled(bool checked) { if (!lock) { - int index = sender()->property("index").toInt()-1; + int index = sender()->property("index").toInt(); if (checked) model->switchWarningEnable &= ~(1 << index); @@ -792,17 +796,12 @@ void SetupPanel::startupSwitchToggled(bool checked) void SetupPanel::updatePotWarnings() { lock = true; - int mode = model->nPotsToWarn >> 6; - ui->potWarningMode->setCurrentIndex(mode); - - if (mode == 0) - model->nPotsToWarn = 0x3F; - + ui->potWarningMode->setCurrentIndex(model->potsWarningMode); for (int i=0; inPotsToWarn & (1 << i)); - - potWarningCheckboxes[i]->setChecked(enabled); - potWarningCheckboxes[i]->setDisabled(mode == 0); + QCheckBox *checkbox = potWarningCheckboxes[i]; + int index = checkbox->property("index").toInt(); + checkbox->setChecked(!model->potsWarningEnabled[index]); + checkbox->setDisabled(model->potsWarningMode == 0); } lock = false; } @@ -810,13 +809,8 @@ void SetupPanel::updatePotWarnings() void SetupPanel::potWarningToggled(bool checked) { if (!lock) { - int index = sender()->property("index").toInt()-1; - - if(checked) - model->nPotsToWarn &= ~(1 << index); - else - model->nPotsToWarn |= (1 << index); - + int index = sender()->property("index").toInt(); + model->potsWarningEnabled[index] = !checked; updatePotWarnings(); emit modified(); } @@ -825,10 +819,7 @@ void SetupPanel::potWarningToggled(bool checked) void SetupPanel::on_potWarningMode_currentIndexChanged(int index) { if (!lock) { - int mask = 0xC0; - model->nPotsToWarn = model->nPotsToWarn & ~mask; - model->nPotsToWarn = model->nPotsToWarn | ((index << 6) & mask); - + model->potsWarningMode = index; updatePotWarnings(); emit modified(); } diff --git a/companion/src/shared/autocombobox.h b/companion/src/shared/autocombobox.h index d106359af..316da3a03 100644 --- a/companion/src/shared/autocombobox.h +++ b/companion/src/shared/autocombobox.h @@ -40,8 +40,7 @@ class AutoComboBox: public QComboBox this->field = (int *)&field; this->panel = panel; for (int i=0; ifield = &field; this->panel = panel; + for (int i=0; ifield == i) setCurrentIndex(i); } }