From 71c763f94336d3b501ca27ca6f6011ecba0aa1ea Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 6 Jan 2020 10:28:29 +0100 Subject: [PATCH] Bsongis/x9lites sources companion fix (#7275) Fixes #7215 Fixes #7244 --- companion/src/firmwares/boards.h | 5 +++++ companion/src/firmwares/opentx/opentxeeprom.cpp | 3 --- companion/src/firmwares/opentx/opentxeeprom.h | 2 +- companion/src/firmwares/opentx/opentxinterface.cpp | 10 ++++++++++ radio/src/storage/eeprom_rlc.cpp | 9 +++++++++ radio/src/targets/taranis/CMakeLists.txt | 2 +- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/companion/src/firmwares/boards.h b/companion/src/firmwares/boards.h index 1057d3706..74e690ebf 100644 --- a/companion/src/firmwares/boards.h +++ b/companion/src/firmwares/boards.h @@ -255,6 +255,11 @@ inline bool IS_TARANIS_X9LITE(Board::Type board) return board == Board::BOARD_TARANIS_X9LITE || board == Board::BOARD_TARANIS_X9LITES; } +inline bool IS_TARANIS_X9LITES(Board::Type board) +{ + return board == Board::BOARD_TARANIS_X9LITES; +} + inline bool IS_TARANIS_X9(Board::Type board) { return board==Board::BOARD_TARANIS_X9D || board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9DP_2019 || board==Board::BOARD_TARANIS_X9E; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 21e067a2d..18dfc7379 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -45,9 +45,6 @@ inline int MAX_SWITCHES(Board::Type board, int version) if (IS_TARANIS_X9D(board)) return 9; - if (IS_TARANIS_X9LITE(board)) - return 7; - if (IS_JUMPER_T12(board)) return 8; diff --git a/companion/src/firmwares/opentx/opentxeeprom.h b/companion/src/firmwares/opentx/opentxeeprom.h index 95f75ce19..ac1cf09dc 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.h +++ b/companion/src/firmwares/opentx/opentxeeprom.h @@ -28,13 +28,13 @@ #define GVARS_VARIANT 0x0001 #define FRSKY_VARIANT 0x0002 -#define MAVLINK_VARIANT 0x0008 #define M128_VARIANT 0x8000 #define TARANIS_X9E_VARIANT 0x8000 #define TARANIS_X7_VARIANT 0x4000 #define TARANIS_XLITE_VARIANT 0x2000 #define TARANIS_XLITES_VARIANT 0x1000 #define TARANIS_X9LITE_VARIANT 0x0800 +#define TARANIS_X9LITES_VARIANT 0x0801 #define JUMPER_T12_VARIANT 0x4001 #define SIMU_STOCK_VARIANTS (GVARS_VARIANT|FRSKY_VARIANT) diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index aaff3123b..741db16b6 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -329,6 +329,9 @@ int OpenTxEepromInterface::save(uint8_t * eeprom, const RadioData & radioData, u else if (IS_TARANIS_X9E(board)) { variant |= TARANIS_X9E_VARIANT; } + else if (IS_TARANIS_X9LITES(board)) { + variant |= TARANIS_X9LITES_VARIANT; + } else if (IS_TARANIS_X9LITE(board)) { variant |= TARANIS_X9LITE_VARIANT; } @@ -718,6 +721,8 @@ int OpenTxFirmware::getCapability(::Capability capability) return SIMU_M128_VARIANTS; else if (IS_TARANIS_X9E(board)) return TARANIS_X9E_VARIANT; + else if (IS_TARANIS_X9LITES(board)) + return TARANIS_X9LITES_VARIANT; else if (IS_TARANIS_X9LITE(board)) return TARANIS_X9LITE_VARIANT; else if (IS_TARANIS_X7(board)) @@ -991,6 +996,11 @@ bool OpenTxEepromInterface::checkVariant(unsigned int version, unsigned int vari variantError = true; } } + else if (IS_TARANIS_X9LITES(board)) { + if (variant != TARANIS_X9LITES_VARIANT) { + variantError = true; + } + } else if (IS_TARANIS_X9LITE(board)) { if (variant != TARANIS_X9LITE_VARIANT) { variantError = true; diff --git a/radio/src/storage/eeprom_rlc.cpp b/radio/src/storage/eeprom_rlc.cpp index 3d77e3dbe..d1e28254c 100644 --- a/radio/src/storage/eeprom_rlc.cpp +++ b/radio/src/storage/eeprom_rlc.cpp @@ -776,6 +776,15 @@ bool eeLoadGeneral(bool allowFixes) } #endif +#if defined(PCBX9LITES) + if (g_eeGeneral.variant == 0x0800) { + TRACE("Pre release EEPROM detected, variant %d instead of %d for X9LiteS radio. Loading anyway", g_eeGeneral.variant, EEPROM_VARIANT); + g_eeGeneral.variant = EEPROM_VARIANT; + storageDirty(EE_GENERAL); + return true; + } +#endif + #if defined(RADIO_T12) if (g_eeGeneral.variant != (EEPROM_VARIANT & 0xFFFE)) { TRACE("EEPROM variant %d instead of %d", g_eeGeneral.variant, EEPROM_VARIANT); diff --git a/radio/src/targets/taranis/CMakeLists.txt b/radio/src/targets/taranis/CMakeLists.txt index db593064e..fe9a02922 100644 --- a/radio/src/targets/taranis/CMakeLists.txt +++ b/radio/src/targets/taranis/CMakeLists.txt @@ -207,7 +207,7 @@ elseif(PCB STREQUAL X9LITES) set(FLAVOUR x9lites) add_definitions(-DBOARD_NAME="x9lites") add_definitions(-DPCBX9LITES -DPCBX9LITE -DPCBX9 -DSOFTWARE_VOLUME -DHARDWARE_POWER_MANAGEMENT_UNIT) - add_definitions(-DEEPROM_VARIANT=0x0800) + add_definitions(-DEEPROM_VARIANT=0x0801) add_definitions(-DPWR_BUTTON_${PWR_BUTTON}) set(PXX2 ON) set(GUI_DIR 128x64)