From 559bb838649d28dd59c9d532ad067b33c43958d6 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Mon, 14 Jul 2014 19:13:39 +0200 Subject: [PATCH 1/2] Re #1510 - This might be a better warning message --- companion/src/firmwares/opentx/opentxeeprom.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 48e4e22de..abcf53721 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -504,7 +504,8 @@ template class SourceField: public ConversionField< UnsignedField > { public: SourceField(RawSource & source, BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags=0): - ConversionField< UnsignedField >(_source, SourcesConversionTable::getInstance(board, version, variant, flags), "Source", "This source cannot be exported on this board!"), + ConversionField< UnsignedField >(_source, SourcesConversionTable::getInstance(board, version, variant, flags), + "Source", "Source "+ source.toString(ModelData())+" cannot be exported on this board!"), source(source), _source(0) { From 4ae9585080285d40290f3984c1f4e3d946842f17 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Mon, 14 Jul 2014 20:11:21 +0200 Subject: [PATCH 2/2] Re #1510 - Added switches warning, better protocol warnings and limited display to max 10 warnings --- companion/src/eepromimportexport.h | 2 +- companion/src/eeprominterface.cpp | 2 +- companion/src/eeprominterface.h | 2 +- .../src/firmwares/opentx/open9xSky9xeeprom.cpp | 4 ++-- .../src/firmwares/opentx/open9xStockeeprom.cpp | 2 +- companion/src/firmwares/opentx/opentxeeprom.cpp | 13 +++++++------ .../src/firmwares/opentx/opentxinterface.cpp | 15 +++++++++++++-- companion/src/firmwares/th9x/th9xeeprom.cpp | 2 +- 8 files changed, 27 insertions(+), 15 deletions(-) diff --git a/companion/src/eepromimportexport.h b/companion/src/eepromimportexport.h index 0d7ea49ec..6be4826e7 100644 --- a/companion/src/eepromimportexport.h +++ b/companion/src/eepromimportexport.h @@ -648,7 +648,7 @@ class ConversionField: public TransformedField { if (table->exportValue(_field, _field)) return; if (!error.isEmpty()) - EEPROMWarnings += error + "\n"; + EEPROMWarnings.push_back(error); } if (shift) { diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 4cf29b34f..b8798ef8b 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -12,7 +12,7 @@ #include "helpers.h" #include "wizarddata.h" -QString EEPROMWarnings; +std::list EEPROMWarnings; const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" }; const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH" }; diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 277fca225..fd08c8df7 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -1198,7 +1198,7 @@ class EEPROMInterface }; -extern QString EEPROMWarnings; +extern std::list EEPROMWarnings; /* EEPROM string conversion functions */ void setEEPROMString(char *dst, const char *src, int size); diff --git a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp index a7002e53c..249c2b6ce 100644 --- a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp @@ -149,7 +149,7 @@ t_Open9xArmExpoData_v208::operator ExpoData () c9x.chn = chn; if (expo!=0 && curve!=0) { - EEPROMWarnings += ::QObject::tr("Simultaneous usage of expo and curves is no longer supported") + "\n"; + EEPROMWarnings.push_back(::QObject::tr("Simultaneous usage of expo and curves is no longer supported")); } else { if (curve == 0) { @@ -179,7 +179,7 @@ t_Open9xArmExpoData_v210::operator ExpoData () c9x.chn = chn; if (expo!=0 && curve!=0) { - EEPROMWarnings += ::QObject::tr("Simultaneous usage of expo and curves is no longer supported") + "\n"; + EEPROMWarnings.push_back(::QObject::tr("Simultaneous usage of expo and curves is no longer supported")); } else { if (curve == 0) { diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.cpp b/companion/src/firmwares/opentx/open9xStockeeprom.cpp index 898743af1..0f26c96a6 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xStockeeprom.cpp @@ -89,7 +89,7 @@ t_Open9xExpoData_v201::operator ExpoData () c9x.mode = mode; c9x.chn = chn; if (expo!=0 && curve!=0) { - EEPROMWarnings += ::QObject::tr("Simultaneous usage of expo and curves is no longer supported in OpenTX") + "\n"; + EEPROMWarnings.push_back(::QObject::tr("Simultaneous usage of expo and curves is no longer supported in OpenTX")); } else { if (curve == 0) { diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index abcf53721..cad02a119 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -370,7 +370,8 @@ template class SwitchField: public ConversionField< SignedField > { public: SwitchField(RawSwitch & sw, BoardEnum board, unsigned int version, unsigned long flags=0): - ConversionField< SignedField >(_switch, SwitchesConversionTable::getInstance(board, version, flags), "Switch"), + ConversionField< SignedField >(_switch, SwitchesConversionTable::getInstance(board, version, flags), "Switch", + "Switch "+ sw.toString()+" cannot be exported on this board!"), sw(sw), _switch(0) { @@ -1257,14 +1258,14 @@ class CurvesField: public TransformedField { if (IS_TARANIS(board) && version >= 216) { offset += (curve->type == CurveData::CURVE_TYPE_CUSTOM ? curve->count * 2 - 2 : curve->count); if (offset > maxPoints) { - EEPROMWarnings += ::QObject::tr("OpenTX only accepts %1 points in all curves").arg(maxPoints) + "\n"; + EEPROMWarnings.push_back(::QObject::tr("OpenTX only accepts %1 points in all curves").arg(maxPoints)); break; } } else { offset += (curve->type == CurveData::CURVE_TYPE_CUSTOM ? curve->count * 2 - 2 : curve->count) - 5; if (offset > maxPoints - 5 * maxCurves) { - EEPROMWarnings += ::QObject::tr("OpenTx only accepts %1 points in all curves").arg(maxPoints) + "\n"; + EEPROMWarnings.push_back(::QObject::tr("OpenTx only accepts %1 points in all curves").arg(maxPoints)); break; } _curves[i] = offset; @@ -2430,7 +2431,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne if (IS_ARM(board)) internalField.Append(new UnsignedField<3>(modelData.telemetryProtocol)); else - internalField.Append(new ConversionField< UnsignedField<3> >((unsigned int &)modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this protocol"))); + internalField.Append(new ConversionField< UnsignedField<3> >((unsigned int &)modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this telemetry protocol"))); internalField.Append(new BoolField<1>(modelData.thrTrim)); @@ -2534,12 +2535,12 @@ 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 protocol"))); + internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[1].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this rado protocol"))); internalField.Append(new UnsignedField<8>(modelData.trainerMode)); } else if (IS_ARM(board) && version >= 216) { modulesCount = 3; - internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this protocol"))); + internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol"))); } if (IS_ARM(board) && version >= 215) { diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 707b1030a..ff1fe846d 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -402,10 +402,21 @@ int OpenTxEepromInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t } } - if (!EEPROMWarnings.isEmpty()) + if (!EEPROMWarnings.empty()) { + QString msg; + int noErrorsToDisplay = std::min((int)EEPROMWarnings.size(),10); + for (int n = 0; n < noErrorsToDisplay; n++) { + msg += "-" + EEPROMWarnings.front() + "\n"; + EEPROMWarnings.pop_front(); + } + if (!EEPROMWarnings.empty()) { + msg = QObject::tr("(displaying only first 10 warnings)") + "\n" + msg; + } + EEPROMWarnings.clear(); QMessageBox::warning(NULL, QObject::tr("Warning"), - QObject::tr("EEPROM saved with these warnings:") + "\n- " + EEPROMWarnings.remove(EEPROMWarnings.length()-1, 1).replace("\n", "\n- ")); + QObject::tr("EEPROM saved with these warnings:") + "\n" + msg); + } return size; } diff --git a/companion/src/firmwares/th9x/th9xeeprom.cpp b/companion/src/firmwares/th9x/th9xeeprom.cpp index fa8947a91..144c8bf4e 100644 --- a/companion/src/firmwares/th9x/th9xeeprom.cpp +++ b/companion/src/firmwares/th9x/th9xeeprom.cpp @@ -197,7 +197,7 @@ int8_t t_Th9xLogicalSwitchData::fromSource(RawSource source) if (source.type == SOURCE_TYPE_STICK) v1 = 1+source.index; else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) { - EEPROMWarnings += ::QObject::tr("th9x on this board doesn't have Rotary Encoders") + "\n"; + EEPROMWarnings.push_back(::QObject::tr("th9x on this board doesn't have Rotary Encoders")); v1 = 5+source.index; } else if (source.type == SOURCE_TYPE_MAX)