From 5d2220c842d46ffe77a7dc1d2c6cec8c3d72cfa9 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 12 Feb 2017 22:21:18 +0100 Subject: [PATCH] [SKY9X/9XR-PRO] Shift in Switches display --- radio/src/gui/gui_common_arm.cpp | 8 +++++++- radio/src/opentx.h | 4 ++++ radio/src/strhelpers.cpp | 25 ++++++++++++++++++++----- radio/src/translations/cz.h.txt | 2 ++ radio/src/translations/de.h.txt | 2 ++ radio/src/translations/en.h.txt | 2 ++ radio/src/translations/es.h.txt | 2 ++ radio/src/translations/fi.h.txt | 2 ++ radio/src/translations/fr.h.txt | 2 ++ radio/src/translations/it.h.txt | 2 ++ radio/src/translations/nl.h.txt | 2 ++ radio/src/translations/pl.h.txt | 2 ++ radio/src/translations/pt.h.txt | 2 ++ radio/src/translations/se.h.txt | 2 ++ 14 files changed, 53 insertions(+), 6 deletions(-) diff --git a/radio/src/gui/gui_common_arm.cpp b/radio/src/gui/gui_common_arm.cpp index 1b13679e3..b529a25b6 100644 --- a/radio/src/gui/gui_common_arm.cpp +++ b/radio/src/gui/gui_common_arm.cpp @@ -275,7 +275,7 @@ bool isSwitchAvailable(int swtch, SwitchContext context) #if defined(PCBSKY9X) if (swtch >= SWSRC_FIRST_SWITCH && swtch <= SWSRC_LAST_SWITCH) { - (void)negative; + UNUSED(negative); return true; } #else @@ -310,6 +310,12 @@ bool isSwitchAvailable(int swtch, SwitchContext context) } #endif +#if defined(PCBSKY9X) && defined(REVX) + if (swtch == SWSRC_REa) { + return false; + } +#endif + if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) { if (context == GeneralCustomFunctionsContext) { return false; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index c55ef1896..429076211 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -869,6 +869,10 @@ void doLoopCommonActions(); #define BITMASK(bit) (1<<(bit)) +#if !defined(UNUSED) +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + /// returns the number of elements of an array #define DIM(arr) (sizeof((arr))/sizeof((arr)[0])) diff --git a/radio/src/strhelpers.cpp b/radio/src/strhelpers.cpp index c0a408904..35b4c6413 100644 --- a/radio/src/strhelpers.cpp +++ b/radio/src/strhelpers.cpp @@ -241,10 +241,14 @@ char * getSwitchString(char * dest, swsrc_t idx) } #if defined(PCBSKY9X) + #define IDX_TRIMS_IN_STR_VSWITCHES (1+SWSRC_LAST_SWITCH) + #define IDX_ON_IN_STR_VSWITCHES (IDX_TRIMS_IN_STR_VSWITCHES+SWSRC_LAST_TRIM-SWSRC_FIRST_TRIM+2) if (idx <= SWSRC_LAST_SWITCH) { getStringAtIndex(s, STR_VSWITCHES, 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) if (idx <= SWSRC_LAST_SWITCH) { div_t swinfo = switchInfo(idx); if (ZEXIST(g_eeGeneral.switchNames[swinfo.quot])) { @@ -267,7 +271,8 @@ char * getSwitchString(char * dest, swsrc_t idx) *s++ = "\300-\301"[swinfo.rem]; *s = '\0'; } -#endif +#endif // PCBSKY9X + #if NUM_XPOTS > 0 else if (idx <= SWSRC_LAST_MULTIPOS_SWITCH) { div_t swinfo = div(int(idx - SWSRC_FIRST_MULTIPOS_SWITCH), XPOTS_MULTIPOS_COUNT); @@ -277,14 +282,22 @@ char * getSwitchString(char * dest, swsrc_t idx) strAppendStringWithIndex(s, temp, swinfo.rem+1); } #endif - else if (idx <= SWSRC_LAST_TRIM) { - getStringAtIndex(s, STR_VSWITCHES, idx-SWSRC_FIRST_TRIM+1); + +#if defined(PCBSKY9X) + else if (idx <= SWSRC_REa) { + getStringAtIndex(s, STR_VSWITCHES, IDX_TRIMS_IN_STR_VSWITCHES+idx-SWSRC_FIRST_TRIM); } +#else + else if (idx <= SWSRC_LAST_TRIM) { + getStringAtIndex(s, STR_VSWITCHES, IDX_TRIMS_IN_STR_VSWITCHES+idx-SWSRC_FIRST_TRIM); + } +#endif + else if (idx <= SWSRC_LAST_LOGICAL_SWITCH) { strAppendStringWithIndex(s, "L", idx-SWSRC_FIRST_LOGICAL_SWITCH+1); } else if (idx <= SWSRC_ONE) { - getStringAtIndex(s, STR_VSWITCHES, idx-SWSRC_ON+2+(SWSRC_LAST_TRIM-SWSRC_FIRST_TRIM)); + getStringAtIndex(s, STR_VSWITCHES, IDX_ON_IN_STR_VSWITCHES + idx - SWSRC_ON); } else if (idx <= SWSRC_LAST_FLIGHT_MODE) { strAppendStringWithIndex(s, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE); @@ -295,7 +308,9 @@ char * getSwitchString(char * dest, swsrc_t idx) else { zchar2str(s, g_model.telemetrySensors[idx-SWSRC_FIRST_SENSOR].label, TELEM_LABEL_LEN); } - + + TRACE("idx=%d LAST_TRIM=%d LAST_LS=%d ONE=%d", idx, SWSRC_LAST_TRIM, SWSRC_LAST_LOGICAL_SWITCH, SWSRC_LAST_LOGICAL_SWITCH, SWSRC_ONE); + return dest; } diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index fd960d958..2be628ad4 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -599,6 +599,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index e373f3d5f..17ff9d8b3 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -601,6 +601,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 80343f1e0..246c2cfe4 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -578,6 +578,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index f7c7052b4..7aa82b5ec 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -576,6 +576,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index d28efd606..71a6cd43e 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -576,6 +576,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 7d9123aed..0e48bcbe9 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -589,6 +589,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index b4795b059..83bd3df09 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -583,6 +583,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index 83c414261..7fcca1368 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -569,6 +569,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index ca0d2764d..d1345bd96 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -585,6 +585,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 97472edee..45f9d2e51 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -571,6 +571,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index c44dc6a88..154fd3c11 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -594,6 +594,8 @@ #elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES +#elif defined(PCBSKY9X) + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_ON_ONE_SWITCHES #else #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW TR_ON_ONE_SWITCHES #endif