From f250d381e5aefa2125cbb86270fbd4671cb50943 Mon Sep 17 00:00:00 2001 From: bsongis Date: Fri, 28 Feb 2014 12:16:43 +0100 Subject: [PATCH] Issue #764 fixed --- companion/src/eeprominterface.h | 2 +- .../src/firmwares/opentx/open9xSky9xeeprom.cpp | 16 ++++++++-------- companion/src/firmwares/opentx/opentxeeprom.cpp | 3 ++- companion/src/helpers.cpp | 2 +- radio/src/eeprom_conversions.cpp | 3 +++ radio/src/gui/menu_model.cpp | 2 +- radio/src/myeeprom.h | 17 ++++++++++++++++- radio/src/opentx.cpp | 6 +++--- radio/src/opentx.h | 12 +----------- 9 files changed, 36 insertions(+), 27 deletions(-) diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 78d142230..78ee98ff3 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -162,7 +162,7 @@ enum HeliSwashTypes { #define BOARD_X9D_NUM_POTS 4 #define C9X_NUM_POTS 4 #define NUM_CAL_PPM 4 -#define NUM_PPM 8 +#define NUM_PPM(board) (IS_ARM(board) ? 16 : 8) #define NUM_CYC 3 #define C9X_NUM_SWITCHES 10 #define C9X_NUM_KEYS 6 diff --git a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp index 01a7a01b2..36b6229ac 100644 --- a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp @@ -268,11 +268,11 @@ t_Open9xArmMixData_v208::operator MixData () else if (srcRaw <= 9+9+O9X_ARM_NUM_CSW+NUM_CYC) { c9x.srcRaw = RawSource(SOURCE_TYPE_CYC, srcRaw-10-9-O9X_ARM_NUM_CSW); } - else if (srcRaw <= 9+9+O9X_ARM_NUM_CSW+NUM_CYC+NUM_PPM) { + else if (srcRaw <= 9+9+O9X_ARM_NUM_CSW+NUM_CYC+8) { c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-10-9-O9X_ARM_NUM_CSW-NUM_CYC); } else { - c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-10-9-O9X_ARM_NUM_CSW-NUM_CYC-NUM_PPM); + c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-10-9-O9X_ARM_NUM_CSW-NUM_CYC-8); } c9x.weight = weight; c9x.swtch = open9xArmToSwitch(swtch); @@ -334,11 +334,11 @@ t_Open9xArmMixData_v209::operator MixData () else if (srcRaw <= 13+9+O9X_ARM_NUM_CSW+NUM_CYC) { c9x.srcRaw = RawSource(SOURCE_TYPE_CYC, srcRaw-14-9-O9X_ARM_NUM_CSW); } - else if (srcRaw <= 13+9+O9X_ARM_NUM_CSW+NUM_CYC+NUM_PPM) { + else if (srcRaw <= 13+9+O9X_ARM_NUM_CSW+NUM_CYC+8) { c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-14-9-O9X_ARM_NUM_CSW-NUM_CYC); } else { - c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-14-9-O9X_ARM_NUM_CSW-NUM_CYC-NUM_PPM); + c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-14-9-O9X_ARM_NUM_CSW-NUM_CYC-8); } c9x.weight = weight; @@ -400,11 +400,11 @@ t_Open9xArmMixData_v210::operator MixData () else if (srcRaw <= 13+9+O9X_ARM_NUM_CSW+NUM_CYC) { c9x.srcRaw = RawSource(SOURCE_TYPE_CYC, srcRaw-14-9-O9X_ARM_NUM_CSW); } - else if (srcRaw <= 13+9+O9X_ARM_NUM_CSW+NUM_CYC+NUM_PPM) { + else if (srcRaw <= 13+9+O9X_ARM_NUM_CSW+NUM_CYC+8) { c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-14-9-O9X_ARM_NUM_CSW-NUM_CYC); } else { - c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-14-9-O9X_ARM_NUM_CSW-NUM_CYC-NUM_PPM); + c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-14-9-O9X_ARM_NUM_CSW-NUM_CYC-8); } c9x.weight = weight; @@ -470,11 +470,11 @@ t_Open9xArmMixData_v212::operator MixData () else if (srcRaw <= 14+9+O9X_ARM_NUM_CSW+NUM_CYC) { c9x.srcRaw = RawSource(SOURCE_TYPE_CYC, srcRaw-15-9-O9X_ARM_NUM_CSW); } - else if (srcRaw <= 14+9+O9X_ARM_NUM_CSW+NUM_CYC+NUM_PPM) { + else if (srcRaw <= 14+9+O9X_ARM_NUM_CSW+NUM_CYC+8) { c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-15-9-O9X_ARM_NUM_CSW-NUM_CYC); } else { - c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-15-9-O9X_ARM_NUM_CSW-NUM_CYC-NUM_PPM); + c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-15-9-O9X_ARM_NUM_CSW-NUM_CYC-8); } c9x.weight = weight; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index e6f02db9e..5be9f0917 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -23,6 +23,7 @@ #define MAX_CUSTOM_FUNCTIONS(board, version) (IS_ARM(board) ? (version >= 216 ? 64 : 32) : (IS_DBLEEPROM(board, version) ? 24 : 16)) #define MAX_CURVES(board, version) (IS_ARM(board) ? ((IS_TARANIS(board) && version >= 216) ? 32 : 16) : O9X_MAX_CURVES) #define MAX_GVARS(board, version) ((IS_ARM(board) && version >= 216) ? 9 : 5) +#define NUM_PPM_INPUTS(board, version) ((IS_ARM(board) && version >= 216) ? 16 : 8) #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)) @@ -218,7 +219,7 @@ class SourcesConversionTable: public ConversionTable { addConversion(RawSource(SOURCE_TYPE_CYC, i), val++); } - for (int i=0; i<8; i++) + for (int i=0; isetCurrentIndex(b->count()-1); } - for (int i=0; igetBoard()); i++) { item = RawSource(SOURCE_TYPE_PPM, i); b->addItem(item.toString(), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index a10b36c78..a4d79de2a 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -270,6 +270,9 @@ int ConvertSource_215_to_216(int source, bool insertZero=false) // Virtual Inputs and Lua Outputs added if (source > 0) source += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; + // PPM9-PPM16 added + if (source > MIXSRC_FIRST_PPM+7) + source += 8; // 4 GVARS added if (source > MIXSRC_GVAR1+4) source += 4; diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index ea18a60f0..0ac5af663 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -2186,7 +2186,7 @@ void menuModelHeli(uint8_t event) uint8_t attr = (sub == i ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); switch(i) { case ITEM_HELI_SWASHTYPE: - g_model.swashR.type = selectMenuItem(HELI_PARAM_OFS, y, STR_SWASHTYPE, STR_VSWASHTYPE, g_model.swashR.type, 0, SWASH_TYPE_NUM, attr, event); + g_model.swashR.type = selectMenuItem(HELI_PARAM_OFS, y, STR_SWASHTYPE, STR_VSWASHTYPE, g_model.swashR.type, 0, SWASH_TYPE_MAX, attr, event); break; case ITEM_HELI_COLLECTIVE: diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 4882671dc..b3b5b7de5 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -77,6 +77,7 @@ #define NUM_CFN 64 // number of functions assigned to switches #define MAX_SCRIPTS 7 #define MAX_INPUTS 32 + #define NUM_PPM 16 #elif defined(CPUARM) #define MAX_MODELS 60 #define NUM_CHNOUT 32 // number of real output channels CH1-CH32 @@ -85,6 +86,7 @@ #define MAX_EXPOS 32 #define NUM_CSW 32 // number of custom switches #define NUM_CFN 64 // number of functions assigned to switches + #define NUM_PPM 16 #elif defined(CPUM2560) || defined(CPUM2561) #define MAX_MODELS 30 #define NUM_CHNOUT 16 // number of real output channels CH1-CH16 @@ -93,6 +95,7 @@ #define MAX_EXPOS 16 #define NUM_CSW 15 // number of custom switches #define NUM_CFN 24 // number of functions assigned to switches + #define NUM_PPM 8 #elif defined(CPUM128) #define MAX_MODELS 30 #define NUM_CHNOUT 16 // number of real output channels CH1-CH16 @@ -101,6 +104,7 @@ #define MAX_EXPOS 14 #define NUM_CSW 15 // number of custom switches #define NUM_CFN 24 // number of functions assigned to switches + #define NUM_PPM 8 #else #define MAX_MODELS 16 #define NUM_CHNOUT 16 // number of real output channels CH1-CH16 @@ -109,9 +113,12 @@ #define MAX_EXPOS 14 #define NUM_CSW 12 // number of custom switches #define NUM_CFN 16 // number of functions assigned to switches + #define NUM_PPM 8 #endif #define MAX_TIMERS 2 +#define NUM_CYC 3 +#define NUM_CAL_PPM 4 #if defined(PCBTARANIS) enum CurveType { @@ -1156,6 +1163,14 @@ PACK(typedef struct t_MavlinkData { }) MavlinkData; #endif +enum SwashType { + SWASH_TYPE_120, + SWASH_TYPE_120X, + SWASH_TYPE_140, + SWASH_TYPE_90, + SWASH_TYPE_MAX = SWASH_TYPE_90 +}; + PACK(typedef struct t_SwashRingData { // Swash Ring data uint8_t invertELE:1; uint8_t invertAIL:1; @@ -1427,7 +1442,7 @@ enum MixSources { MIXSRC_LAST_CSW = MIXSRC_FIRST_CSW+NUM_CSW-1, MIXSRC_FIRST_PPM, - MIXSRC_LAST_PPM = MIXSRC_FIRST_PPM + 7, + MIXSRC_LAST_PPM = MIXSRC_FIRST_PPM+NUM_PPM-1, MIXSRC_FIRST_CH, MIXSRC_CH1 = MIXSRC_FIRST_CH, diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 0db7325cb..96e19bfff 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -4875,10 +4875,10 @@ void perMain() #endif } } -} //endfunc void perMain() +} -int16_t g_ppmIns[8]; -uint8_t ppmInState = 0; //0=unsync 1..8= wait for value i-1 +int16_t g_ppmIns[NUM_PPM]; +uint8_t ppmInState = 0; // 0=unsync 1..8= wait for value i-1 #if !defined(SIMU) && !defined(CPUARM) diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 4b8da9dbe..0ee4b3bf1 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -622,16 +622,6 @@ enum BaseCurves { CURVE_BASE }; -#define SWASH_TYPE_120 1 -#define SWASH_TYPE_120X 2 -#define SWASH_TYPE_140 3 -#define SWASH_TYPE_90 4 -#define SWASH_TYPE_NUM 4 - -#define NUM_CYC 3 -#define NUM_CAL_PPM 4 -#define NUM_PPM 8 - #define THRCHK_DEADBAND 16 #if defined(FSPLASH) || defined(XSPLASH) @@ -1205,7 +1195,7 @@ extern uint8_t g_beepCnt; extern uint8_t g_beepVal[5]; extern uint8_t ppmInState; //0=unsync 1..8= wait for value i-1 -extern int16_t g_ppmIns[8]; +extern int16_t g_ppmIns[NUM_PPM]; extern int32_t chans[NUM_CHNOUT]; extern int16_t ex_chans[NUM_CHNOUT]; // Outputs (before LIMITS) of the last perMain extern int16_t channelOutputs[NUM_CHNOUT];