From a5d62805c393ac44a728126ea7f98cef75bb487b Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 29 Aug 2019 17:11:53 +0200 Subject: [PATCH] Companion import / export issue for switches from X9D+ 2019 --- companion/src/firmwares/opentx/opentxeeprom.cpp | 9 +++++++-- radio/src/dataconstants.h | 3 +-- radio/src/strhelpers.cpp | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index ff991cf48..76d2ae687 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -89,13 +89,18 @@ inline int MAX_SWITCHES_POSITION(Board::Type board, int version) { if (version < 219) { if (IS_TARANIS_X7(board) || IS_HORUS(board)) - return Boards::getCapability(board, Board::SwitchPositions) - 2*3; + return Boards::getCapability(board, Board::SwitchPositions) - 2 * 3; + if (IS_TARANIS_X9D(board)) + return 8 * 3; + } + + if (IS_TARANIS_X9D(board)) { + return 9 * 3; // all X9D have storage for 9 switches (X9D+ 2019) } return Boards::getCapability(board, Board::SwitchPositions); } -//#define MAX_SWITCHES_POSITION(board, version) (Boards::getCapability(board, Board::SwitchPositions)) #define MAX_ROTARY_ENCODERS(board) (IS_SKY9X(board) ? 1 : 0) #define MAX_FLIGHT_MODES(board, version) 9 #define MAX_TIMERS(board, version) 3 diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index d6e74cd95..803261c6b 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -482,7 +482,6 @@ enum SwitchSources { SWSRC_SR2, #endif - #if defined(PCBSKY9X) SWSRC_ID0 = SWSRC_FIRST_SWITCH, SWSRC_ID1, @@ -501,7 +500,7 @@ enum SwitchSources { #if NUM_XPOTS > 0 SWSRC_FIRST_MULTIPOS_SWITCH, - SWSRC_LAST_MULTIPOS_SWITCH = SWSRC_FIRST_MULTIPOS_SWITCH + (NUM_POTS * XPOTS_MULTIPOS_COUNT) - 1, + SWSRC_LAST_MULTIPOS_SWITCH = SWSRC_FIRST_MULTIPOS_SWITCH + (NUM_XPOTS * XPOTS_MULTIPOS_COUNT) - 1, #endif SWSRC_FIRST_TRIM, diff --git a/radio/src/strhelpers.cpp b/radio/src/strhelpers.cpp index 3473cc5ab..1ebc326fd 100644 --- a/radio/src/strhelpers.cpp +++ b/radio/src/strhelpers.cpp @@ -293,7 +293,7 @@ char * getSwitchPositionName(char * dest, swsrc_t idx) } #else #define IDX_TRIMS_IN_STR_VSWITCHES (1) - #define IDX_ON_IN_STR_VSWITCHES (IDX_TRIMS_IN_STR_VSWITCHES+SWSRC_LAST_TRIM-SWSRC_FIRST_TRIM+1) + #define IDX_ON_IN_STR_VSWITCHES (IDX_TRIMS_IN_STR_VSWITCHES + SWSRC_LAST_TRIM - SWSRC_FIRST_TRIM + 1) if (idx <= SWSRC_LAST_SWITCH) { div_t swinfo = switchInfo(idx); s = getSwitchName(s, idx);