diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 65abe0833..14d70483e 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1595,7 +1595,7 @@ class CurvesField: public TransformedField { for (int i=0; i #include #include +#include using namespace Board; @@ -95,30 +96,6 @@ const char * OpenTxEepromInterface::getName() } } -uint32_t OpenTxEepromInterface::getFourCC() -{ - switch (board) { - case BOARD_X12S: - case BOARD_X10: - return 0x3478746F; - case BOARD_TARANIS_X7: - return 0x3678746F; - case BOARD_TARANIS_X9E: - return 0x3578746F; - case BOARD_TARANIS_X9D: - case BOARD_TARANIS_X9DP: - return 0x3378746F; - case BOARD_SKY9X: - case BOARD_AR9X: - return 0x3278746F; - case BOARD_MEGA2560: - case BOARD_GRUVIN9X: - return 0x3178746F; - default: - return 0; - } -} - bool OpenTxEepromInterface::loadRadioSettingsFromRLE(GeneralSettings & settings, RleFile * rleFile, uint8_t version) { QByteArray data(sizeof(settings), 0); // GeneralSettings should be always bigger than the EEPROM struct @@ -163,7 +140,7 @@ bool OpenTxEepromInterface::saveToByteArray(const T & src, QByteArray & data, ui // manager.Dump(); manager.Export(raw); data.resize(8); - *((uint32_t*)&data.data()[0]) = getFourCC(); + *((uint32_t*)&data.data()[0]) = StorageFormat::getFourCC(board); data[4] = version; data[5] = 'M'; *((uint16_t*)&data.data()[6]) = raw.size(); @@ -186,12 +163,12 @@ template bool OpenTxEepromInterface::loadFromByteArray(T & dest, const QByteArray & data) { uint32_t fourcc = *((uint32_t*)&data.data()[0]); - if (getFourCC() != fourcc) { + if (StorageFormat::getFourCC(board) != fourcc) { if (IS_HORUS(board) && fourcc == 0x3178396F) { - qDebug() << QString().sprintf("%s: Deprecated fourcc used %x vs %x", getName(), fourcc, getFourCC()); + qDebug() << QString().sprintf("%s: Deprecated fourcc used %x vs %x", getName(), fourcc, StorageFormat::getFourCC(board)); } else { - qDebug() << QString().sprintf("%s: Wrong fourcc %x vs %x", getName(), fourcc, getFourCC()); + qDebug() << QString().sprintf("%s: Wrong fourcc %x vs %x", getName(), fourcc, StorageFormat::getFourCC(board)); return false; } } diff --git a/companion/src/firmwares/opentx/opentxinterface.h b/companion/src/firmwares/opentx/opentxinterface.h index f9cfdf745..c8f659de1 100644 --- a/companion/src/firmwares/opentx/opentxinterface.h +++ b/companion/src/firmwares/opentx/opentxinterface.h @@ -72,8 +72,6 @@ class OpenTxEepromInterface : public EEPROMInterface uint8_t getLastDataVersion(Board::Type board); - uint32_t getFourCC(); - RleFile * efile; OpenTxFirmware * firmware; diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 7676e9b49..bddacd7ef 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -702,7 +702,7 @@ void MdiChild::onFirmwareChanged() Firmware * previous = firmware; firmware = getCurrentFirmware(); //qDebug() << "onFirmwareChanged" << previous->getName() << "=>" << firmware->getName(); - if (previous->getBoard() != firmware->getBoard()) { + if (StorageFormat::getFourCC(previous->getBoard()) != StorageFormat::getFourCC(firmware->getBoard())) { convertStorage(previous->getBoard(), firmware->getBoard()); setModified(); } diff --git a/companion/src/storage/storage.h b/companion/src/storage/storage.h index e1af73b5c..aa288451f 100644 --- a/companion/src/storage/storage.h +++ b/companion/src/storage/storage.h @@ -67,15 +67,38 @@ class StorageFormat return board; } + static uint32_t getFourCC(Board::Type board) + { + switch (board) { + case Board::BOARD_X12S: + case Board::BOARD_X10: + return 0x3478746F; + case Board::BOARD_TARANIS_X7: + return 0x3678746F; + case Board::BOARD_TARANIS_X9E: + return 0x3578746F; + case Board::BOARD_TARANIS_X9D: + case Board::BOARD_TARANIS_X9DP: + return 0x3378746F; + case Board::BOARD_SKY9X: + case Board::BOARD_AR9X: + return 0x3278746F; + case Board::BOARD_MEGA2560: + case Board::BOARD_GRUVIN9X: + return 0x3178746F; + default: + return 0; + } + } + + uint32_t getFourCC() + { + return getFourCC(board); + } + virtual bool isBoardCompatible(Board::Type board) { - if (this->board == board) - return true; - - if (IS_TARANIS_X9D(this->board) && IS_TARANIS_X9D(board)) - return true; - - return false; + return getFourCC() == getFourCC(board); } protected: