1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-16 21:05:26 +03:00

Re #1510 - Added switches warning, better protocol warnings and limited display to max 10 warnings

This commit is contained in:
Damjan Adamic 2014-07-14 20:11:21 +02:00
parent 559bb83864
commit 4ae9585080
8 changed files with 27 additions and 15 deletions

View file

@ -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) {

View file

@ -12,7 +12,7 @@
#include "helpers.h"
#include "wizarddata.h"
QString EEPROMWarnings;
std::list<QString> EEPROMWarnings;
const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" };
const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH" };

View file

@ -1198,7 +1198,7 @@ class EEPROMInterface
};
extern QString EEPROMWarnings;
extern std::list<QString> EEPROMWarnings;
/* EEPROM string conversion functions */
void setEEPROMString(char *dst, const char *src, int size);

View file

@ -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) {

View file

@ -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) {

View file

@ -370,7 +370,8 @@ template <int N>
class SwitchField: public ConversionField< SignedField<N> > {
public:
SwitchField(RawSwitch & sw, BoardEnum board, unsigned int version, unsigned long flags=0):
ConversionField< SignedField<N> >(_switch, SwitchesConversionTable::getInstance(board, version, flags), "Switch"),
ConversionField< SignedField<N> >(_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) {

View file

@ -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;
}

View file

@ -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)