diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index ca55ccc20..69cd2d61f 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -183,19 +183,6 @@ extern const char downArrow[]; class ModelData; class GeneralSettings; -enum ThrottleSource { - THROTTLE_SOURCE_THR, - THROTTLE_SOURCE_P1, - THROTTLE_SOURCE_P2, - THROTTLE_SOURCE_P3, - THROTTLE_SOURCE_S1 = THROTTLE_SOURCE_P1, - THROTTLE_SOURCE_S2, - THROTTLE_SOURCE_S3, - THROTTLE_SOURCE_LS, - THROTTLE_SOURCE_RS, - THROTTLE_SOURCE_FIRST_CHANNEL, -}; - enum TelemetrySource { TELEMETRY_SOURCE_TX_BATT, TELEMETRY_SOURCE_TX_TIME, diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index df73bd380..36f008c2d 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -383,32 +383,6 @@ void OpenTxEepromCleanup(void) SwitchesConversionTable::Cleanup(); } -ThrottleSourceConversionTable::ThrottleSourceConversionTable(BoardEnum board, unsigned int version) -{ - int val=0; - - addConversion(THROTTLE_SOURCE_THR, val++); - - if (IS_TARANIS(board)) { - addConversion(THROTTLE_SOURCE_S1, val++); - addConversion(THROTTLE_SOURCE_S2, val++); - if (version >= 216) - addConversion(THROTTLE_SOURCE_S3, val++); - addConversion(THROTTLE_SOURCE_LS, val++); - addConversion(THROTTLE_SOURCE_RS, val++); - } - else { - addConversion(THROTTLE_SOURCE_P1, val++); - addConversion(THROTTLE_SOURCE_P2, val++); - addConversion(THROTTLE_SOURCE_P3, val++); - } - - for (int i=0; i class SwitchField: public ConversionField< SignedField > { public: @@ -2890,8 +2864,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne board(board), version(version), variant(variant), - protocolsConversionTable(board), - throttleSourceConversionTable(board, version) + protocolsConversionTable(board) { sprintf(name, "Model %s", modelData.name); @@ -3026,7 +2999,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne internalField.Append(new SignedField<8>(modelData.moduleData[0].ppmFrameLength)); } - internalField.Append(new ConversionField< UnsignedField<8> >(modelData.thrTraceSrc, &throttleSourceConversionTable, "Throttle Source")); + internalField.Append(new UnsignedField<8>(modelData.thrTraceSrc, "Throttle Source")); if (!afterrelease21March2013) { internalField.Append(new UnsignedField<8>(modelData.moduleData[0].modelId)); diff --git a/companion/src/firmwares/opentx/opentxeeprom.h b/companion/src/firmwares/opentx/opentxeeprom.h index 7efd07d6e..1664bae77 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.h +++ b/companion/src/firmwares/opentx/opentxeeprom.h @@ -84,12 +84,6 @@ class ProtocolsConversionTable: public ConversionTable } }; -class ThrottleSourceConversionTable: public ConversionTable { - - public: - ThrottleSourceConversionTable(BoardEnum board, unsigned int version); -}; - class ChannelsConversionTable: public ConversionTable { public: @@ -121,7 +115,6 @@ class OpenTxModelData: public TransformedField { char name[256]; int subprotocols[C9X_NUM_MODULES+1/*trainer*/]; ProtocolsConversionTable protocolsConversionTable; - ThrottleSourceConversionTable throttleSourceConversionTable; ChannelsConversionTable channelsConversionTable; }; diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 1f6da6d82..20e85f6af 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -689,7 +689,7 @@ void SetupPanel::on_trimIncrement_currentIndexChanged(int index) void SetupPanel::on_throttleSource_currentIndexChanged(int index) { if (!lock) { - model->thrTraceSrc = ui->throttleSource->itemData(index).toInt(); + model->thrTraceSrc = index; emit modified(); } } @@ -735,34 +735,39 @@ void SetupPanel::on_image_currentIndexChanged(int index) void SetupPanel::populateThrottleSourceCB() { - const QString sources9x[] = { QObject::tr("THR"), QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3")}; - const QString sourcesTaranis[] = { QObject::tr("THR"), QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), QObject::tr("LS"), QObject::tr("RS")}; + const QString pots9x[] = { QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3")}; + const QString potsTaranis[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), QObject::tr("LS"), QObject::tr("RS")}; + const QString potsTaranisX9E[] = { QObject::tr("F1"), QObject::tr("F2"), QObject::tr("F3"), QObject::tr("F4"), QObject::tr("S1"), QObject::tr("S2"), QObject::tr("LS"), QObject::tr("RS")}; unsigned int i; lock = true; - if (IS_TARANIS(GetEepromInterface()->getBoard())) { - for (i=0; i<6; i++) { - ui->throttleSource->addItem(sourcesTaranis[i], i); + ui->throttleSource->addItem(QObject::tr("THR")); + + if (IS_TARANIS_X9E(GetEepromInterface()->getBoard())) { + for (i=0; i<8; i++) { + ui->throttleSource->addItem(potsTaranisX9E[i], i); + } + } + else if (IS_TARANIS(GetEepromInterface()->getBoard())) { + for (i=0; i<5; i++) { + ui->throttleSource->addItem(potsTaranis[i], i); } } else { - for (i=0; i<4; i++) { - ui->throttleSource->addItem(sources9x[i], i); + for (i=0; i<3; i++) { + ui->throttleSource->addItem(pots9x[i], i); } } - if (model->thrTraceSrc < i) - ui->throttleSource->setCurrentIndex(model->thrTraceSrc); - int channels = (IS_ARM(GetEepromInterface()->getBoard()) ? 32 : 16); for (int i=0; ithrottleSource->addItem(ModelPrinter::printChannelName(i), THROTTLE_SOURCE_FIRST_CHANNEL+i); - if (model->thrTraceSrc == unsigned(THROTTLE_SOURCE_FIRST_CHANNEL+i)) - ui->throttleSource->setCurrentIndex(ui->throttleSource->count()-1); + ui->throttleSource->addItem(ModelPrinter::printChannelName(i)); } + ui->throttleSource->setCurrentIndex(model->thrTraceSrc); + lock = false; } diff --git a/radio/src/gui/Taranis/helpers.cpp b/radio/src/gui/Taranis/helpers.cpp index 0d8a56a9a..30fdff324 100755 --- a/radio/src/gui/Taranis/helpers.cpp +++ b/radio/src/gui/Taranis/helpers.cpp @@ -304,7 +304,7 @@ bool isSwitchAvailableInTimers(int swtch) bool isThrottleSourceAvailable(int source) { - if (source == THROTTLE_SOURCE_S3 && !IS_POT_AVAILABLE(POT3)) + if (source >= THROTTLE_SOURCE_FIRST_POT && source < THROTTLE_SOURCE_FIRST_POT+NUM_POTS && !IS_POT_AVAILABLE(POT1+source-THROTTLE_SOURCE_FIRST_POT)) return false; else return true; diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index aa66ba49e..f9f133fd9 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -2096,14 +2096,24 @@ PACK(typedef struct { enum ThrottleSources { THROTTLE_SOURCE_THR, -#if defined(PCBTARANIS) + THROTTLE_SOURCE_FIRST_POT, +#if defined(PCBTARANIS) && defined(REV9E) + THROTTLE_SOURCE_F1 = THROTTLE_SOURCE_FIRST_POT, + THROTTLE_SOURCE_F2, + THROTTLE_SOURCE_F3, + THROTTLE_SOURCE_F4, THROTTLE_SOURCE_S1, THROTTLE_SOURCE_S2, + THROTTLE_SOURCE_LS, + THROTTLE_SOURCE_RS, +#elif defined(PCBTARANIS) + THROTTLE_SOURCE_S1 = THROTTLE_SOURCE_FIRST_POT, + THROTTLE_SOURCE_S2, THROTTLE_SOURCE_S3, THROTTLE_SOURCE_LS, THROTTLE_SOURCE_RS, #else - THROTTLE_SOURCE_P1, + THROTTLE_SOURCE_P1 = THROTTLE_SOURCE_FIRST_POT, THROTTLE_SOURCE_P2, THROTTLE_SOURCE_P3, #endif