From 380b42c57f10b3ef7a2ce162a8fb91b12262c999 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 21 Nov 2016 23:28:21 +0100 Subject: [PATCH] [Companion] Horus support. Now the Logical switches, Special functions and Flight modes --- companion/src/constants.h | 1 + companion/src/eeprominterface.h | 6 +++--- companion/src/firmwares/opentx/opentxeeprom.cpp | 17 +++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/companion/src/constants.h b/companion/src/constants.h index 15d4aeb5a..79adce4e7 100644 --- a/companion/src/constants.h +++ b/companion/src/constants.h @@ -32,6 +32,7 @@ enum BoardEnum { #define C9X_MAX_CUSTOM_FUNCTIONS 64 // number of functions assigned to switches #define C9X_NUM_MODULES 2 #define NUM_STICKS 4 +#define NUM_AUX_TRIMS 2 #define BOARD_9X_NUM_POTS 3 #define C9X_NUM_POTS 8 #define NUM_CAL_PPM 4 diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 2ac99ff00..ca2fe11f7 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -613,9 +613,9 @@ class CustomFunctionData { // Function Switches data class FlightModeData { public: FlightModeData() { clear(0); } - int trimMode[NUM_STICKS]; - int trimRef[NUM_STICKS]; - int trim[NUM_STICKS]; + int trimMode[NUM_STICKS+NUM_AUX_TRIMS]; + int trimRef[NUM_STICKS+NUM_AUX_TRIMS]; + int trim[NUM_STICKS+NUM_AUX_TRIMS]; RawSwitch swtch; char name[10+1]; unsigned int fadeIn; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 7a4407c3a..7de760123 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -28,7 +28,8 @@ #define MAX_SCRIPTS(board) (IS_HORUS(board) ? 9 : 7) #define MAX_TELEMETRY_SENSORS(board, version) (32) #define NUM_PPM_INPUTS(board, version) ((IS_ARM(board) && version >= 216) ? 16 : 8) -#define ROTENC_COUNT(board, version) (IS_ARM(board) ? ((IS_TARANIS(board) && version >= 218) ? 0 : 1) : (IS_2560(board) ? 2 : 0)) +#define ROTENC_COUNT(board, version) (IS_ARM(board) ? ((IS_STM32(board) && version >= 218) ? 0 : 1) : (IS_2560(board) ? 2 : 0)) +#define MAX_AUX_TRIMS(board) (IS_HORUS(board) ? 2 : 0) #define IS_AFTER_RELEASE_21_MARCH_2013(board, version) (version >= 214 || (!IS_ARM(board) && version >= 213)) #define IS_AFTER_RELEASE_23_MARCH_2013(board, version) (version >= 214 || (board==BOARD_STOCK && version >= 213)) @@ -795,7 +796,7 @@ class FlightModeField: public TransformedField { internalField.Append(new SignedField<2>(trimExt[i])); } else if (IS_ARM(board) && version >= 218) { - for (int i=0; i(phase.trim[i])); internalField.Append(new UnsignedField<5>(trimMode[i])); } @@ -848,7 +849,7 @@ class FlightModeField: public TransformedField { virtual void beforeExport() { - for (int i=0; i= 216) { if (phase.trimMode[i] < 0) trimMode[i] = TRIM_MODE_NONE; @@ -876,7 +877,7 @@ class FlightModeField: public TransformedField { virtual void afterImport() { - for (int i=0; i= 216) { if (trimMode[i] == TRIM_MODE_NONE) { phase.trimMode[i] = -1; @@ -923,9 +924,9 @@ class FlightModeField: public TransformedField { BoardEnum board; unsigned int version; int rotencCount; - int trimBase[NUM_STICKS]; - int trimExt[NUM_STICKS]; - unsigned int trimMode[NUM_STICKS]; + int trimBase[NUM_STICKS+NUM_AUX_TRIMS]; + int trimExt[NUM_STICKS+NUM_AUX_TRIMS]; + unsigned int trimMode[NUM_STICKS+NUM_AUX_TRIMS]; }; class MixField: public TransformedField { @@ -2129,7 +2130,7 @@ class ArmCustomFunctionField: public TransformedField { internalField.Append(new ConversionField< UnsignedField<8> >(_func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); } - if (IS_STM32(board) && version >= 216) + if (IS_TARANIS(board) && version >= 216) internalField.Append(new CharField<8>(_param, false)); else if (IS_TARANIS(board)) internalField.Append(new CharField<10>(_param, false));