diff --git a/companion/src/eepromimportexport.h b/companion/src/eepromimportexport.h index 6be4826e7..645ca6818 100644 --- a/companion/src/eepromimportexport.h +++ b/companion/src/eepromimportexport.h @@ -505,7 +505,7 @@ class ConversionTable { { after = 0; - for (std::list::iterator it=internalTable.begin(); it!=internalTable.end(); it++) { + for (std::list::iterator it=exportTable.begin(); it!=exportTable.end(); it++) { ConversionTuple tuple = *it; if (before == tuple.a) { after = tuple.b; @@ -520,7 +520,7 @@ class ConversionTable { { after = 0; - for (std::list::iterator it=internalTable.begin(); it!=internalTable.end(); it++) { + for (std::list::iterator it=importTable.begin(); it!=importTable.end(); it++) { ConversionTuple tuple = *it; if (before == tuple.b) { after = tuple.a; @@ -547,10 +547,23 @@ class ConversionTable { void addConversion(const int a, const int b) { - internalTable.push_back(ConversionTuple(a, b)); + ConversionTuple conversion(a, b); + importTable.push_back(conversion); + exportTable.push_back(conversion); } - std::list internalTable; + void addImportConversion(const int a, const int b) + { + importTable.push_back(ConversionTuple(a, b)); + } + + void addExportConversion(const int a, const int b) + { + exportTable.push_back(ConversionTuple(a, b)); + } + + std::list importTable; + std::list exportTable; }; template diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index b8997fcb2..f24be19f3 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -56,8 +56,15 @@ class SwitchesConversionTable: public ConversionTable { for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) { int s = switchIndex(i, board, version); - addConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val+offset); - addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val++); + addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val); + if (IS_TARANIS(board) && s>=21/*SHup/SHdown*/) { + addImportConversion(RawSwitch(SWITCH_TYPE_SWITCH, 21+22-s), -val+offset); + addExportConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val+offset); + } + else { + addConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val+offset); + } + val++; } if (IS_TARANIS(board) && version >= 216) { @@ -124,6 +131,16 @@ class SwitchesConversionTable: public ConversionTable { ConversionTable::addConversion(sw.toValue(), b); } + void addImportConversion(const RawSwitch & sw, const int b) + { + ConversionTable::addImportConversion(sw.toValue(), b); + } + + void addExportConversion(const RawSwitch & sw, const int b) + { + ConversionTable::addExportConversion(sw.toValue(), b); + } + class Cache { public: Cache(BoardEnum board, unsigned int version, unsigned long flags, SwitchesConversionTable * table):