From e053f75b763c3d4733a95cd0b40f2cbd236722f4 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 7 Apr 2016 20:21:14 +0200 Subject: [PATCH] Move ppm options in companion to substruct like in datastructs.h --- companion/src/eeprominterface.cpp | 6 +-- companion/src/eeprominterface.h | 12 +++-- companion/src/firmwares/er9x/er9xeeprom.cpp | 6 +-- .../src/firmwares/ersky9x/ersky9xeeprom.cpp | 12 ++--- .../src/firmwares/gruvin9x/gruvin9xeeprom.cpp | 16 +++--- .../firmwares/opentx/open9xGruvin9xeeprom.cpp | 30 +++++------ .../firmwares/opentx/open9xSky9xeeprom.cpp | 30 +++++------ .../firmwares/opentx/open9xStockeeprom.cpp | 52 +++++++++---------- .../src/firmwares/opentx/opentxeeprom.cpp | 20 +++---- companion/src/firmwares/th9x/th9xeeprom.cpp | 2 +- companion/src/modeledit/setup.cpp | 16 +++--- companion/src/modelprinter.cpp | 4 +- companion/src/xmlinterface.cpp | 6 +-- 13 files changed, 107 insertions(+), 105 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 5a4043bd9..7ecd5535e 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -1380,9 +1380,9 @@ void ModelData::clear() moduleData[0].channelsCount = 8; moduleData[1].channelsStart = 0; moduleData[1].channelsCount = 8; - moduleData[0].ppmDelay = 300; - moduleData[1].ppmDelay = 300; - moduleData[2].ppmDelay = 300; + moduleData[0].ppm.delay = 300; + moduleData[1].ppm.delay = 300; + moduleData[2].ppm.delay = 300; int board = GetEepromInterface()->getBoard(); if (IS_TARANIS(board)) { moduleData[0].protocol = PULSES_PXX_XJT_X16; diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index f7d8f9a1b..79ca36573 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -870,12 +870,14 @@ class ModuleData { int channelsCount; // 0=8 channels unsigned int failsafeMode; int failsafeChannels[C9X_NUM_CHNOUT]; - int ppmDelay; - bool ppmPulsePol; // false = positive - bool ppmOutputType; // false = open drain, true = push pull - int ppmFrameLength; + struct { + int delay; + bool pulsePol; // false = positive + bool outputType; // false = open drain, true = push pull + int frameLength; + } ppm; void clear() { memset(this, 0, sizeof(ModuleData)); } - QString polarityToString() const { return ppmPulsePol ? QObject::tr("Positive") : QObject::tr("Negative"); } // TODO ModelPrinter + QString polarityToString() const { return ppm.pulsePol ? QObject::tr("Positive") : QObject::tr("Negative"); } // TODO ModelPrinter }; #define C9X_MAX_SCRIPTS 7 diff --git a/companion/src/firmwares/er9x/er9xeeprom.cpp b/companion/src/firmwares/er9x/er9xeeprom.cpp index f7342161b..082afb42f 100644 --- a/companion/src/firmwares/er9x/er9xeeprom.cpp +++ b/companion/src/firmwares/er9x/er9xeeprom.cpp @@ -373,17 +373,17 @@ t_Er9xModelData::operator ModelData () c9x.moduleData[0].protocol = PULSES_PPM; break; } - c9x.moduleData[0].ppmFrameLength=ppmFrameLength; + c9x.moduleData[0].ppm.frameLength=ppmFrameLength; c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH; c9x.thrTrim = thrTrim; c9x.trimInc = trimInc-2; - c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay; + c9x.moduleData[0].ppm.delay = 300 + 50 * ppmDelay; c9x.customFn[0].func = FuncInstantTrim; if (trimSw) { c9x.customFn[0].swtch = er9xToSwitch(trimSw); } c9x.beepANACenter = beepANACenter; - c9x.moduleData[0].ppmPulsePol = pulsePol; + c9x.moduleData[0].ppm.pulsePol = pulsePol; c9x.extendedLimits = extendedLimits; c9x.swashRingData.elevatorWeight = swashInvertELE ? -100 : 100; c9x.swashRingData.aileronWeight = swashInvertAIL ? -100 : 100; diff --git a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp index 9442868e4..5897842ce 100644 --- a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp @@ -505,17 +505,17 @@ t_Ersky9xModelData_v10::operator ModelData () c9x.moduleData[0].protocol = PULSES_PPM; break; } - c9x.moduleData[0].ppmFrameLength=ppmFrameLength; + c9x.moduleData[0].ppm.frameLength=ppmFrameLength; c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH; c9x.thrTrim = thrTrim; c9x.trimInc = trimInc-2; - c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay; + c9x.moduleData[0].ppm.delay = 300 + 50 * ppmDelay; c9x.customFn[0].func = FuncInstantTrim; if (trimSw) { c9x.customFn[0].swtch = er9xToSwitch(trimSw); } c9x.beepANACenter = beepANACenter; - c9x.moduleData[0].ppmPulsePol = pulsePol; + c9x.moduleData[0].ppm.pulsePol = pulsePol; c9x.extendedLimits = extendedLimits; c9x.swashRingData.elevatorWeight = swashInvertELE ? -100 : 100; c9x.swashRingData.aileronWeight = swashInvertAIL ? -100 : 100; @@ -620,17 +620,17 @@ t_Ersky9xModelData_v11::operator ModelData () c9x.moduleData[0].protocol = PULSES_PPM; break; } - c9x.moduleData[0].ppmFrameLength=ppmFrameLength; + c9x.moduleData[0].ppm.frameLength=ppmFrameLength; c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH; c9x.thrTrim = thrTrim; c9x.trimInc = trimInc-2; - c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay; + c9x.moduleData[0].ppm.delay = 300 + 50 * ppmDelay; c9x.customFn[0].func = FuncInstantTrim; if (trimSw) { c9x.customFn[0].swtch = er9xToSwitch(trimSw); } c9x.beepANACenter = beepANACenter; - c9x.moduleData[0].ppmPulsePol = pulsePol; + c9x.moduleData[0].ppm.pulsePol = pulsePol; c9x.extendedLimits = extendedLimits; c9x.swashRingData.elevatorWeight = swashInvertELE ? -100 : 100; c9x.swashRingData.aileronWeight = swashInvertAIL ? -100 : 100; diff --git a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp index dc7fda802..da6caa866 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp +++ b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp @@ -447,9 +447,9 @@ t_Gruvin9xModelData_v102::operator ModelData () c9x.moduleData[0].channelsCount = 8 + (2 * ppmNCH); c9x.thrTrim = thrTrim; c9x.trimInc = trimInc-2; - c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay; + c9x.moduleData[0].ppm.delay = 300 + 50 * ppmDelay; c9x.beepANACenter = beepANACenter; - c9x.moduleData[0].ppmPulsePol = pulsePol; + c9x.moduleData[0].ppm.pulsePol = pulsePol; c9x.extendedLimits = extendedLimits; for (int i=0; i= 216)) internalField.Append(new BoolField<1>(modelData.displayChecklist)); else - internalField.Append(new BoolField<1>(modelData.moduleData[0].ppmPulsePol)); + internalField.Append(new BoolField<1>(modelData.moduleData[0].ppm.pulsePol)); internalField.Append(new BoolField<1>(modelData.extendedLimits)); internalField.Append(new BoolField<1>(modelData.extendedTrims)); internalField.Append(new BoolField<1>(modelData.throttleReversed)); if (!IS_ARM(board) || version < 216) { - internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].ppmDelay, exportPpmDelay, importPpmDelay)); + internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].ppm.delay, exportPpmDelay, importPpmDelay)); } if (IS_ARM(board) || IS_2560(board)) @@ -3091,7 +3091,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne } if (!IS_ARM(board) || version < 216) { - internalField.Append(new SignedField<8>(modelData.moduleData[0].ppmFrameLength)); + internalField.Append(new SignedField<8>(modelData.moduleData[0].ppm.frameLength)); } internalField.Append(new UnsignedField<8>(modelData.thrTraceSrc, "Throttle Source")); @@ -3186,15 +3186,15 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne internalField.Append(new SignedField<16>(modelData.moduleData[module].failsafeChannels[i])); } if (version >= 217) { - internalField.Append(new ConversionField< SignedField<6> >(modelData.moduleData[module].ppmDelay, exportPpmDelay, importPpmDelay)); - internalField.Append(new BoolField<1>(modelData.moduleData[module].ppmPulsePol)); - internalField.Append(new BoolField<1>(modelData.moduleData[module].ppmOutputType)); - internalField.Append(new SignedField<8>(modelData.moduleData[module].ppmFrameLength)); + internalField.Append(new ConversionField< SignedField<6> >(modelData.moduleData[module].ppm.delay, exportPpmDelay, importPpmDelay)); + internalField.Append(new BoolField<1>(modelData.moduleData[module].ppm.pulsePol)); + internalField.Append(new BoolField<1>(modelData.moduleData[module].ppm.outputType)); + internalField.Append(new SignedField<8>(modelData.moduleData[module].ppm.frameLength)); } else { - internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[module].ppmDelay, exportPpmDelay, importPpmDelay)); - internalField.Append(new SignedField<8>(modelData.moduleData[module].ppmFrameLength)); - internalField.Append(new BoolField<8>(modelData.moduleData[module].ppmPulsePol)); + internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[module].ppm.delay, exportPpmDelay, importPpmDelay)); + internalField.Append(new SignedField<8>(modelData.moduleData[module].ppm.frameLength)); + internalField.Append(new BoolField<8>(modelData.moduleData[module].ppm.pulsePol)); } } } diff --git a/companion/src/firmwares/th9x/th9xeeprom.cpp b/companion/src/firmwares/th9x/th9xeeprom.cpp index aa15b1af4..a2732d2d1 100644 --- a/companion/src/firmwares/th9x/th9xeeprom.cpp +++ b/companion/src/firmwares/th9x/th9xeeprom.cpp @@ -273,7 +273,7 @@ t_Th9xModelData::operator ModelData () c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH; c9x.thrTrim = thrTrim; c9x.trimInc = trimInc; - c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay; + c9x.moduleData[0].ppm.delay = 300 + 50 * ppmDelay; c9x.customFn[0].func = FuncTrims2Offsets; if (trimSw) { c9x.customFn[0].swtch = trimSw; diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index fd141b128..f615a5102 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -293,18 +293,18 @@ void ModulePanel::update() // PPM settings fields ui->label_ppmPolarity->setVisible(mask & MASK_PPM_FIELDS); ui->ppmPolarity->setVisible(mask & MASK_PPM_FIELDS); - ui->ppmPolarity->setCurrentIndex(module.ppmPulsePol); + ui->ppmPolarity->setCurrentIndex(module.ppm.pulsePol); ui->label_ppmOutputType->setVisible(mask & MASK_OPEN_DRAIN); ui->ppmOutputType->setVisible(mask & MASK_OPEN_DRAIN); - ui->ppmOutputType->setCurrentIndex(module.ppmOutputType); + ui->ppmOutputType->setCurrentIndex(module.ppm.outputType); ui->label_ppmDelay->setVisible(mask & MASK_PPM_FIELDS); ui->ppmDelay->setVisible(mask & MASK_PPM_FIELDS); - ui->ppmDelay->setValue(module.ppmDelay); + ui->ppmDelay->setValue(module.ppm.delay); ui->label_ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS); ui->ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS); ui->ppmFrameLength->setMinimum(module.channelsCount*(model->extendedLimits ? 2.250 : 2)+3.5); ui->ppmFrameLength->setMaximum(firmware->getCapability(PPMFrameLength)); - ui->ppmFrameLength->setValue(22.5+((double)module.ppmFrameLength)*0.5); + ui->ppmFrameLength->setValue(22.5+((double)module.ppm.frameLength)*0.5); if (firmware->getCapability(HasFailsafe)) { ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES); @@ -356,13 +356,13 @@ void ModulePanel::on_protocol_currentIndexChanged(int index) void ModulePanel::on_ppmPolarity_currentIndexChanged(int index) { - module.ppmPulsePol = index; + module.ppm.pulsePol = index; emit modified(); } void ModulePanel::on_ppmOutputType_currentIndexChanged(int index) { - module.ppmOutputType = index; + module.ppm.outputType = index; emit modified(); } @@ -388,7 +388,7 @@ void ModulePanel::on_ppmDelay_editingFinished() { if (!lock) { // TODO only accept valid values - module.ppmDelay = ui->ppmDelay->value(); + module.ppm.delay = ui->ppmDelay->value(); emit modified(); } } @@ -401,7 +401,7 @@ void ModulePanel::on_rxNumber_editingFinished() void ModulePanel::on_ppmFrameLength_editingFinished() { - module.ppmFrameLength = (ui->ppmFrameLength->value()-22.5) / 0.5; + module.ppm.frameLength = (ui->ppmFrameLength->value()-22.5) / 0.5; emit modified(); } diff --git a/companion/src/modelprinter.cpp b/companion/src/modelprinter.cpp index f3650d184..b0faaba26 100644 --- a/companion/src/modelprinter.cpp +++ b/companion/src/modelprinter.cpp @@ -110,7 +110,7 @@ QString ModelPrinter::printModule(int idx) if (module.protocol == PULSES_OFF) return printModuleProtocol(module.protocol); else if (module.protocol == PULSES_PPM) - return tr("%1, Channels(%2-%3), PPM delay(%4usec), Pulse polarity(%5)").arg(printModuleProtocol(module.protocol)).arg(module.channelsStart+1).arg(module.channelsStart+module.channelsCount).arg(module.ppmDelay).arg(module.polarityToString()); + return tr("%1, Channels(%2-%3), PPM delay(%4usec), Pulse polarity(%5)").arg(printModuleProtocol(module.protocol)).arg(module.channelsStart + 1).arg(module.channelsStart + module.channelsCount).arg(module.ppm.delay).arg(module.polarityToString()); else { QString result = tr("%1, Channels(%2-%3)").arg(printModuleProtocol(module.protocol)).arg(module.channelsStart+1).arg(module.channelsStart+module.channelsCount); if (module.protocol != PULSES_PXX_XJT_D8) { @@ -125,7 +125,7 @@ QString ModelPrinter::printTrainerMode() QString result; switch (model.trainerMode) { case 1: - result = tr("Slave/Jack"); // TODO + tr(": Channel start: %1, %2 Channels, %3usec Delay, Pulse polarity %4").arg(module.channelsStart+1).arg(module.channelsCount).arg(module.ppmDelay).arg(module.polarityToString()); + result = tr("Slave/Jack"); // TODO + tr(": Channel start: %1, %2 Channels, %3usec Delay, Pulse polarity %4").arg(module.channelsStart+1).arg(module.channelsCount).arg(module.ppm.delay).arg(module.polarityToString()); break; case 2: result = tr("Master/SBUS Module"); diff --git a/companion/src/xmlinterface.cpp b/companion/src/xmlinterface.cpp index 1f88b0116..94fd58b84 100644 --- a/companion/src/xmlinterface.cpp +++ b/companion/src/xmlinterface.cpp @@ -124,12 +124,12 @@ void saveModel(ModelData & m, model & xm) } } */ - if (m.moduleData[0].protocol != PULSES_PPM || m.moduleData[0].channelsCount != 8 || m.moduleData[0].ppmDelay != 300 || m.moduleData[0].ppmPulsePol != 0) { + if (m.moduleData[0].protocol != PULSES_PPM || m.moduleData[0].channelsCount != 8 || m.moduleData[0].ppm.delay != 300 || m.moduleData[0].ppm.pulsePol != 0) { modulation mod; mod.type(modulation::type_type::value(m.moduleData[0].protocol)); mod.channels(m.moduleData[0].channelsCount); - mod.delay(m.moduleData[0].ppmDelay); - mod.polarity(modulation::polarity_type::value(m.moduleData[0].ppmPulsePol)); + mod.delay(m.moduleData[0].ppm.delay); + mod.polarity(modulation::polarity_type::value(m.moduleData[0].ppm.pulsePol)); xm.modulation(mod); } {