[Companion] Refactoring - fixes the X9E=>X7 conversion segfault

This commit is contained in:
Bertrand Songis
2017-01-24 20:08:48 +01:00
parent 8f970fdbbf
commit 57aafeb062
19 changed files with 289 additions and 208 deletions
@@ -416,9 +416,10 @@ 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), QObject::tr("Switch").toLatin1(),
QObject::tr("Switch ").toLatin1()+ sw.toString()+ QObject::tr(" cannot be exported on this board!").toLatin1()),
QObject::tr("Switch ").toLatin1()+ sw.toString(board) + QObject::tr(" cannot be exported on this board!").toLatin1()),
sw(sw),
_switch(0)
_switch(0),
board(board)
{
}
@@ -436,12 +437,13 @@ class SwitchField: public ConversionField< SignedField<N> > {
{
ConversionField< SignedField<N> >::afterImport();
sw = RawSwitch(_switch);
eepromImportDebug() << QString("imported %1: %2").arg(ConversionField< SignedField<N> >::internalField.getName()).arg(sw.toString());
eepromImportDebug() << QString("imported %1: %2").arg(ConversionField< SignedField<N> >::internalField.getName()).arg(sw.toString(board));
}
protected:
RawSwitch & sw;
int _switch;
BoardEnum board;
};
class TelemetrySourcesConversionTable: public ConversionTable {
@@ -3814,7 +3816,7 @@ void OpenTxGeneralData::beforeExport()
void OpenTxGeneralData::afterImport()
{
if (IS_TARANIS(board) && version < 217) {
generalData.potConfig[0] = GeneralSettings::POT_WITH_DETENT;
generalData.potConfig[1] = GeneralSettings::POT_WITH_DETENT;
generalData.potConfig[0] = POT_WITH_DETENT;
generalData.potConfig[1] = POT_WITH_DETENT;
}
}
@@ -818,51 +818,6 @@ QString OpenTxFirmware::getAnalogInputName(unsigned int index)
}
}
Firmware::Switch OpenTxFirmware::getSwitch(unsigned int index)
{
typedef GeneralSettings::SwitchConfig sc;
if (board == BOARD_TARANIS_X7) {
const Switch switches[] = {{sc::SWITCH_3POS, "SA"},
{sc::SWITCH_3POS, "SB"},
{sc::SWITCH_3POS, "SC"},
{sc::SWITCH_3POS, "SD"},
{sc::SWITCH_2POS, "SF"},
{sc::SWITCH_TOGGLE, "SH"}};
return switches[index];
}
else if (IS_HORUS_OR_TARANIS(board)) {
const Switch switches[] = {{sc::SWITCH_3POS, "SA"},
{sc::SWITCH_3POS, "SB"},
{sc::SWITCH_3POS, "SC"},
{sc::SWITCH_3POS, "SD"},
{sc::SWITCH_3POS, "SE"},
{sc::SWITCH_2POS, "SF"},
{sc::SWITCH_3POS, "SG"},
{sc::SWITCH_TOGGLE, "SH"},
{sc::SWITCH_3POS, "SI"},
{sc::SWITCH_3POS, "SJ"},
{sc::SWITCH_3POS, "SK"},
{sc::SWITCH_3POS, "SL"},
{sc::SWITCH_3POS, "SM"},
{sc::SWITCH_3POS, "SN"},
{sc::SWITCH_3POS, "SO"},
{sc::SWITCH_3POS, "SP"},
{sc::SWITCH_3POS, "SQ"},
{sc::SWITCH_3POS, "SR"}};
return switches[index];
}
else {
const Switch switches[] = {{sc::SWITCH_2POS, "THR"},
{sc::SWITCH_2POS, "RUD"},
{sc::SWITCH_2POS, "ELE"},
{sc::SWITCH_3POS, "3POS"},
{sc::SWITCH_2POS, "AIL"},
{sc::SWITCH_2POS, "GEA"},
{sc::SWITCH_TOGGLE, "TRN"}};
return switches[index];
}
}
QTime OpenTxFirmware::getMaxTimerStart()
{
if (IS_HORUS_OR_TARANIS(board))
@@ -131,8 +131,6 @@ class OpenTxFirmware: public Firmware
virtual int getCapability(Capability);
virtual Switch getSwitch(unsigned int index);
virtual QString getAnalogInputName(unsigned int index);
virtual QTime getMaxTimerStart();