From 9730f8d190a432c625ad342cce50771353b59bcf Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 3 Feb 2014 11:19:17 +0100 Subject: [PATCH 01/28] [Taranis] Issue #592 - Sticky switches --- radio/src/gui/menu_model.cpp | 29 ++++++++++++------------ radio/src/opentx.cpp | 43 +++++++++++++++++++++++++++++++----- radio/src/opentx.h | 14 +++++++++++- radio/src/translations/en.h | 10 ++++++++- 4 files changed, 73 insertions(+), 23 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 55f61707f..a335c535b 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4184,10 +4184,10 @@ enum CustomSwitchFields { #if LCD_W >= 212 #define CSW_1ST_COLUMN (4*FW-3) - #define CSW_2ND_COLUMN (8*FW+1) - #define CSW_3RD_COLUMN (14*FW) - #define CSW_4TH_COLUMN (21*FW+1) - #define CSW_5TH_COLUMN (26*FW+1) + #define CSW_2ND_COLUMN (8*FW+2+FW/2) + #define CSW_3RD_COLUMN (14*FW+1+FW/2) + #define CSW_4TH_COLUMN (22*FW) + #define CSW_5TH_COLUMN (26*FW+3) #define CSW_6TH_COLUMN (31*FW+1) #else #define CSW_1ST_COLUMN (4*FW-3) @@ -4442,15 +4442,15 @@ void menuModelCustomSwitches(uint8_t event) #endif #if defined(PCBTARANIS) - if (sub>=0 && horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { - killEvents(event); - CustomSwData * cs = cswAddress(sub); - if (cs->func) MENU_ADD_ITEM(STR_COPY); - if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH) - MENU_ADD_ITEM(STR_PASTE); - if (cs->func || cs->v1 || cs->v2 || cs->delay || cs->duration || cs->andsw) MENU_ADD_ITEM(STR_DELETE); - menuHandler = onCustomSwitchesMenu; - } + if (sub>=0 && horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { + killEvents(event); + CustomSwData * cs = cswAddress(sub); + if (cs->func) MENU_ADD_ITEM(STR_COPY); + if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH) + MENU_ADD_ITEM(STR_PASTE); + if (cs->func || cs->v1 || cs->v2 || cs->delay || cs->duration || cs->andsw) MENU_ADD_ITEM(STR_DELETE); + menuHandler = onCustomSwitchesMenu; + } #endif for (uint8_t i=0; iv1, attr1); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; @@ -4585,7 +4585,6 @@ void menuModelCustomSwitches(uint8_t event) if (cstate==CS_VOFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { killEvents(event); getvalue_t x = getValue(cs->v1); - TRACE("AUTO x=%d", x); if (cs->v1 < MIXSRC_GVAR1) cs->v2 = calcRESXto100(x); else if (cs->v1 - MIXSRC_FIRST_TELEM + 1 == TELEM_ALT) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 5a33763be..67a9e16c0 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -448,7 +448,13 @@ CustomSwData *cswAddress(uint8_t idx) uint8_t cswFamily(uint8_t func) { - return (funcv1); getvalue_t y; @@ -3460,8 +3469,6 @@ void perOut(uint8_t mode, uint8_t tick10ms) do { - // TRACE("[pass %d]", pass); - bitfield_channels_t passDirtyChannels = 0; for (uint8_t i=0; ifunc == CS_STICKY) { + uint16_t & lastValue = (uint16_t &)csLastValue[i]; + bool before = (lastValue & (1<<15)); + if (lastValue & (1<<0)) { + bool now = getSwitch(cs->v2); + if (now != before) { + lastValue ^= (1<<15); + if (!before) { + lastValue &= ~(1<<0); + } + } + } + else { + bool now = getSwitch(cs->v1); + if (before != now) { + lastValue ^= (1<<15); + if (!before) { + lastValue |= (1<<0); + } + } + } + } +#endif } if (s_cnt_1s >= 10) { // 1sec diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 981d360bd..6b704b30b 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -639,7 +639,11 @@ enum CswFunctions { CS_DIFFEGREATER, CS_ADIFFEGREATER, CS_TIMER, - CS_MAXF = CS_TIMER +#if defined(CPUARM) + CS_STICKY, +#endif + CS_COUNT, + CS_MAXF = CS_COUNT-1 }; #define CS_VOFS 0 @@ -647,9 +651,17 @@ enum CswFunctions { #define CS_VCOMP 2 #define CS_VDIFF 3 #define CS_VTIMER 4 +#define CS_VSTICKY 5 + uint8_t cswFamily(uint8_t func); int16_t cswTimerValue(int8_t val); +#if defined(CPUARM) + #define IS_VSTICKY(val) ((val) == CS_VSTICKY) +#else + #define IS_VSTICKY(val) (0) +#endif + #define NUM_CYC 3 #define NUM_CAL_PPM 4 #define NUM_PPM 8 diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 3fd7c07f2..6e228f79b 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -150,8 +150,16 @@ #define LEN_VMIXTRIMS "\003" #define TR_VMIXTRIMS "OFF""ON\0""Rud""Ele""Thr""Ail" +#if defined(CPUARM) + #define TR_CSWTIMER "Timer" + #define TR_CSWSTICKY "Stcky" +#else + #define TR_CSWTIMER "TIM\0" + #define TR_CSWSTICKY +#endif + #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a Date: Mon, 3 Feb 2014 14:05:05 +0100 Subject: [PATCH 02/28] [all] Issue #592 - Sticky switches on all boards. Saves 62bytes on stock! --- radio/src/gui/menu_model.cpp | 2 +- radio/src/lcd.cpp | 25 --------- radio/src/myeeprom.h | 22 ++------ radio/src/opentx.cpp | 103 +---------------------------------- radio/src/opentx.h | 8 --- radio/src/translations/en.h | 6 +- 6 files changed, 10 insertions(+), 156 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index a335c535b..3fbf74e30 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4476,7 +4476,7 @@ void menuModelCustomSwitches(uint8_t event) int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; #endif - if (cstate == CS_VBOOL || IS_VSTICKY(cstate)) { + if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; diff --git a/radio/src/lcd.cpp b/radio/src/lcd.cpp index e1de61641..7bfabb139 100644 --- a/radio/src/lcd.cpp +++ b/radio/src/lcd.cpp @@ -1053,31 +1053,6 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) } #endif -#if !defined(PCBSTD) - else if (idx >= SWSRC_TRAINER_SHORT) { - idx -= SWSRC_TRAINER_SHORT; - char suffix = (idx & 1) ? CHR_LONG : CHR_SHORT; -#if ROTARY_ENCODERS > 0 - if (idx >= 2) { - idx -= 2; - lcd_putsiAtt(x, y, STR_VRENCODERS, idx/2, att); - } - else -#endif - { - lcd_putsiAtt(x, y, STR_VSWITCHES, SWSRC_TRAINER-1, att); - } - return lcd_putcAtt(lcdLastPos, y, suffix, att); - } -#endif - - if (idx > SWSRC_ON) { - idx -= SWSRC_ON; - if (idx != SWSRC_ON && (~att & STRCONDENSED)) { - lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att); - return lcd_putcAtt(lcdLastPos, y, CHR_TOGGLE, att); - } - } lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att); } diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 8bb233a52..70ea3a89a 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -1198,26 +1198,12 @@ enum SwitchSources { #endif SWSRC_ON, - - SWSRC_FIRST_MOMENT_SWITCH, - SWSRC_LAST_MOMENT_SWITCH = SWSRC_FIRST_MOMENT_SWITCH+SWSRC_LAST_CSW, - -#if !defined(PCBSTD) - SWSRC_TRAINER_SHORT, - SWSRC_TRAINER_LONG, -#endif - -#if ROTARY_ENCODERS > 0 - SWSRC_FIRST_ROTENC_SWITCH, - SWSRC_LAST_ROTENC_SWITCH = SWSRC_FIRST_ROTENC_SWITCH+(2*ROTARY_ENCODERS)-1, -#endif - - SWSRC_COUNT, - SWSRC_FIRST = -SWSRC_LAST_MOMENT_SWITCH, - SWSRC_LAST = SWSRC_COUNT-1, - SWSRC_OFF = -SWSRC_ON, + SWSRC_TRAINER = SWSRC_SW1-1, + + SWSRC_FIRST = SWSRC_OFF, + SWSRC_LAST = SWSRC_ON }; enum MixSources { diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 67a9e16c0..48c82bb39 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -448,13 +448,7 @@ CustomSwData *cswAddress(uint8_t idx) uint8_t cswFamily(uint8_t func) { - return (funcv1); getvalue_t y; @@ -3093,100 +3085,11 @@ void evalFunctions() if (swtch) { MASK_FUNC_TYPE function_mask = (CFN_FUNC(sd) >= FUNC_TRAINER ? ((MASK_FUNC_TYPE)1 << (CFN_FUNC(sd)-FUNC_TRAINER)) : 0); MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i); - uint8_t momentary = 0; - -#if !defined(PCBSTD) - - #define MOMENTARY_START_TEST() ( (momentary && !(activeSwitches & switch_mask) && active) || \ - (short_long==1 && !active && mSwitchDuration[mswitch]>0 && mSwitchDuration[mswitch] NUM_SWITCH+1) { - momentary = 1; - swtch -= NUM_SWITCH+1; - } - if (swtch < -NUM_SWITCH-1) { - momentary = 1; - swtch += NUM_SWITCH+1; - } bool active = getSwitch(swtch); if (active) newActiveSwitches |= switch_mask; - if (momentary || short_long) { -#if !defined(PCBSTD) - bool swState = active; -#endif - - if (MOMENTARY_START_TEST()) { - - if (short_long) { - active = false; - momentary = true; - } - else { - active = !(activeFnSwitches & switch_mask); -#if !defined(CPUARM) - if (CFN_FUNC(sd) == FUNC_PLAY_BOTH && !active) { - momentary = true; - } - else -#endif - { - momentary = false; - } - } - } - else if (swtch == SWSRC_ON) { - active = false; - momentary = false; - } - else { - active = (activeFnSwitches & switch_mask); - momentary = false; - } -#if !defined(PCBSTD) - if (short_long && !(mSwitchDurationIncremented & (1<func == CS_STICKY) { uint16_t & lastValue = (uint16_t &)csLastValue[i]; bool before = (lastValue & (1<<15)); @@ -4075,7 +3977,6 @@ void doMixerCalculations() } } } -#endif } if (s_cnt_1s >= 10) { // 1sec diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 6b704b30b..7cbbd4aaa 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -639,9 +639,7 @@ enum CswFunctions { CS_DIFFEGREATER, CS_ADIFFEGREATER, CS_TIMER, -#if defined(CPUARM) CS_STICKY, -#endif CS_COUNT, CS_MAXF = CS_COUNT-1 }; @@ -656,12 +654,6 @@ enum CswFunctions { uint8_t cswFamily(uint8_t func); int16_t cswTimerValue(int8_t val); -#if defined(CPUARM) - #define IS_VSTICKY(val) ((val) == CS_VSTICKY) -#else - #define IS_VSTICKY(val) (0) -#endif - #define NUM_CYC 3 #define NUM_CAL_PPM 4 #define NUM_PPM 8 diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 6e228f79b..045062458 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -150,12 +150,12 @@ #define LEN_VMIXTRIMS "\003" #define TR_VMIXTRIMS "OFF""ON\0""Rud""Ele""Thr""Ail" -#if defined(CPUARM) +#if defined(PCBTARANIS) #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #else - #define TR_CSWTIMER "TIM\0" - #define TR_CSWSTICKY + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Stky\0" #endif #define LEN_VCSWFUNC "\005" From e48c27d30abb230b8663c7a668409b712f2d944f Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 3 Feb 2014 14:05:05 +0100 Subject: [PATCH 03/28] [all] Issue #592 - Sticky switches on all boards. Saves 62bytes on stock! --- radio/src/gui/menu_model.cpp | 2 +- radio/src/lcd.cpp | 25 --------- radio/src/myeeprom.h | 28 ++++------ radio/src/opentx.cpp | 103 +---------------------------------- radio/src/opentx.h | 8 --- radio/src/translations/en.h | 6 +- 6 files changed, 16 insertions(+), 156 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index a335c535b..3fbf74e30 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4476,7 +4476,7 @@ void menuModelCustomSwitches(uint8_t event) int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; #endif - if (cstate == CS_VBOOL || IS_VSTICKY(cstate)) { + if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; diff --git a/radio/src/lcd.cpp b/radio/src/lcd.cpp index e1de61641..7bfabb139 100644 --- a/radio/src/lcd.cpp +++ b/radio/src/lcd.cpp @@ -1053,31 +1053,6 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) } #endif -#if !defined(PCBSTD) - else if (idx >= SWSRC_TRAINER_SHORT) { - idx -= SWSRC_TRAINER_SHORT; - char suffix = (idx & 1) ? CHR_LONG : CHR_SHORT; -#if ROTARY_ENCODERS > 0 - if (idx >= 2) { - idx -= 2; - lcd_putsiAtt(x, y, STR_VRENCODERS, idx/2, att); - } - else -#endif - { - lcd_putsiAtt(x, y, STR_VSWITCHES, SWSRC_TRAINER-1, att); - } - return lcd_putcAtt(lcdLastPos, y, suffix, att); - } -#endif - - if (idx > SWSRC_ON) { - idx -= SWSRC_ON; - if (idx != SWSRC_ON && (~att & STRCONDENSED)) { - lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att); - return lcd_putcAtt(lcdLastPos, y, CHR_TOGGLE, att); - } - } lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att); } diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 8bb233a52..ba75d686b 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -740,6 +740,12 @@ enum Functions { FUNC_MAX }; +#if defined(CPUARM) + #define IS_PLAY_BOTH_FUNC(sd) (0) +#else + #define IS_PLAY_BOTH_FUNC(sd) (CFN_FUNC(sd) == FUNC_PLAY_BOTH) +#endif + #if defined(GVARS) #define IS_ADJUST_GV_FUNCTION(sd) (CFN_FUNC(sd) >= FUNC_ADJUST_GV1 && CFN_FUNC(sd) <= FUNC_ADJUST_GVLAST) #else @@ -1198,26 +1204,12 @@ enum SwitchSources { #endif SWSRC_ON, - - SWSRC_FIRST_MOMENT_SWITCH, - SWSRC_LAST_MOMENT_SWITCH = SWSRC_FIRST_MOMENT_SWITCH+SWSRC_LAST_CSW, - -#if !defined(PCBSTD) - SWSRC_TRAINER_SHORT, - SWSRC_TRAINER_LONG, -#endif - -#if ROTARY_ENCODERS > 0 - SWSRC_FIRST_ROTENC_SWITCH, - SWSRC_LAST_ROTENC_SWITCH = SWSRC_FIRST_ROTENC_SWITCH+(2*ROTARY_ENCODERS)-1, -#endif - - SWSRC_COUNT, - SWSRC_FIRST = -SWSRC_LAST_MOMENT_SWITCH, - SWSRC_LAST = SWSRC_COUNT-1, - SWSRC_OFF = -SWSRC_ON, + SWSRC_TRAINER = SWSRC_SW1-1, + + SWSRC_FIRST = SWSRC_OFF, + SWSRC_LAST = SWSRC_ON }; enum MixSources { diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 67a9e16c0..27dd80868 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -448,13 +448,7 @@ CustomSwData *cswAddress(uint8_t idx) uint8_t cswFamily(uint8_t func) { - return (funcv1); getvalue_t y; @@ -3093,100 +3085,11 @@ void evalFunctions() if (swtch) { MASK_FUNC_TYPE function_mask = (CFN_FUNC(sd) >= FUNC_TRAINER ? ((MASK_FUNC_TYPE)1 << (CFN_FUNC(sd)-FUNC_TRAINER)) : 0); MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i); - uint8_t momentary = 0; - -#if !defined(PCBSTD) - - #define MOMENTARY_START_TEST() ( (momentary && !(activeSwitches & switch_mask) && active) || \ - (short_long==1 && !active && mSwitchDuration[mswitch]>0 && mSwitchDuration[mswitch] NUM_SWITCH+1) { - momentary = 1; - swtch -= NUM_SWITCH+1; - } - if (swtch < -NUM_SWITCH-1) { - momentary = 1; - swtch += NUM_SWITCH+1; - } bool active = getSwitch(swtch); if (active) newActiveSwitches |= switch_mask; - if (momentary || short_long) { -#if !defined(PCBSTD) - bool swState = active; -#endif - - if (MOMENTARY_START_TEST()) { - - if (short_long) { - active = false; - momentary = true; - } - else { - active = !(activeFnSwitches & switch_mask); -#if !defined(CPUARM) - if (CFN_FUNC(sd) == FUNC_PLAY_BOTH && !active) { - momentary = true; - } - else -#endif - { - momentary = false; - } - } - } - else if (swtch == SWSRC_ON) { - active = false; - momentary = false; - } - else { - active = (activeFnSwitches & switch_mask); - momentary = false; - } -#if !defined(PCBSTD) - if (short_long && !(mSwitchDurationIncremented & (1<func == CS_STICKY) { uint16_t & lastValue = (uint16_t &)csLastValue[i]; bool before = (lastValue & (1<<15)); @@ -4075,7 +3977,6 @@ void doMixerCalculations() } } } -#endif } if (s_cnt_1s >= 10) { // 1sec diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 6b704b30b..7cbbd4aaa 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -639,9 +639,7 @@ enum CswFunctions { CS_DIFFEGREATER, CS_ADIFFEGREATER, CS_TIMER, -#if defined(CPUARM) CS_STICKY, -#endif CS_COUNT, CS_MAXF = CS_COUNT-1 }; @@ -656,12 +654,6 @@ enum CswFunctions { uint8_t cswFamily(uint8_t func); int16_t cswTimerValue(int8_t val); -#if defined(CPUARM) - #define IS_VSTICKY(val) ((val) == CS_VSTICKY) -#else - #define IS_VSTICKY(val) (0) -#endif - #define NUM_CYC 3 #define NUM_CAL_PPM 4 #define NUM_PPM 8 diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 6e228f79b..045062458 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -150,12 +150,12 @@ #define LEN_VMIXTRIMS "\003" #define TR_VMIXTRIMS "OFF""ON\0""Rud""Ele""Thr""Ail" -#if defined(CPUARM) +#if defined(PCBTARANIS) #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #else - #define TR_CSWTIMER "TIM\0" - #define TR_CSWSTICKY + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Stky\0" #endif #define LEN_VCSWFUNC "\005" From a48d76504adf650d293d04bfb13b43cae28237d4 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 3 Feb 2014 23:20:49 +0100 Subject: [PATCH 04/28] [all] Issue #592 - Sticky switches: more code rewritten, more flash saved on 9x stock. Logical Switches Delay and Duration modified on Taranis and Sky9x --- radio/src/audio_arm.cpp | 2 +- radio/src/eeprom_conversions.cpp | 2 +- radio/src/eeprom_raw.cpp | 1 - radio/src/eeprom_rlc.cpp | 1 - radio/src/gui/menu_model.cpp | 374 ++++++++++++++----------------- radio/src/gui/menus.cpp | 10 + radio/src/gui/menus.h | 3 +- radio/src/gui/view_main.cpp | 2 +- radio/src/logs.cpp | 2 +- radio/src/maths.cpp | 2 +- radio/src/myeeprom.h | 93 +++----- radio/src/opentx.cpp | 319 ++++++++++++++------------ radio/src/opentx.h | 33 ++- radio/src/translations/en.h | 17 +- 14 files changed, 429 insertions(+), 432 deletions(-) diff --git a/radio/src/audio_arm.cpp b/radio/src/audio_arm.cpp index dc16ff64a..5d2fb1be9 100644 --- a/radio/src/audio_arm.cpp +++ b/radio/src/audio_arm.cpp @@ -571,7 +571,7 @@ void AudioQueue::wakeup() } // mix the background context - if (!isFunctionActive(FUNC_BACKGND_MUSIC_PAUSE)) { + if (!isFunctionActive(FUNCTION_BACKGND_MUSIC_PAUSE)) { result = mixAudioContext(backgroundContext, buffer, g_eeGeneral.varioVolume, g_eeGeneral.backgroundVolume, fade); if (result > 0) { size = max(size, result); diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index b78db9acb..f06e02e09 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -435,7 +435,7 @@ void ConvertModel_215_to_216(ModelData &model) for (uint8_t i=0; i<32; i++) { g_model.funcSw[i] = oldModel.funcSw[i]; CustomFnData *sd = &g_model.funcSw[i]; - if (CFN_FUNC(sd) == FUNC_PLAY_VALUE || CFN_FUNC(sd) == FUNC_VOLUME || (IS_ADJUST_GV_FUNCTION(sd) && CFN_GVAR_MODE(sd) == FUNC_ADJUST_GVAR_SOURCE)) { + if (CFN_FUNC(sd) == FUNC_PLAY_VALUE || CFN_FUNC(sd) == FUNC_VOLUME || (IS_ADJUST_GV_FUNC(CFN_FUNC(sd)) && CFN_GVAR_MODE(sd) == FUNC_ADJUST_GVAR_SOURCE)) { #if defined(PCBTARANIS) CFN_PARAM(sd) += 1 + MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; #endif diff --git a/radio/src/eeprom_raw.cpp b/radio/src/eeprom_raw.cpp index 5439e89a9..718fe3558 100644 --- a/radio/src/eeprom_raw.cpp +++ b/radio/src/eeprom_raw.cpp @@ -383,7 +383,6 @@ void eeLoadModel(uint8_t id) resumePulses(); } - activeSwitches = 0; activeFnSwitches = 0; activeFunctions = 0; memclear(lastFunctionTime, sizeof(lastFunctionTime)); diff --git a/radio/src/eeprom_rlc.cpp b/radio/src/eeprom_rlc.cpp index a56834186..f6f62502e 100644 --- a/radio/src/eeprom_rlc.cpp +++ b/radio/src/eeprom_rlc.cpp @@ -948,7 +948,6 @@ void eeLoadModel(uint8_t id) resumePulses(); } - activeSwitches = 0; activeFnSwitches = 0; activeFunctions = 0; memclear(lastFunctionTime, sizeof(lastFunctionTime)); diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 3fbf74e30..a6e64c67d 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4687,7 +4687,7 @@ void onCustomFunctionsMenu(const char *result) void menuModelCustomFunctions(uint8_t event) { - MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|3/*repeated*/}); + MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/}); uint8_t y; uint8_t k = 0; @@ -4720,7 +4720,8 @@ void menuModelCustomFunctions(uint8_t event) #endif CustomFnData *sd = &g_model.funcSw[k]; - for (uint8_t j=0; j<4; j++) { + uint8_t func = CFN_FUNC(sd); + for (uint8_t j=0; j<5; j++) { uint8_t attr = ((sub==k && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t active = (attr && (s_editMode>0 || p1valdiff)); switch (j) { @@ -4731,228 +4732,197 @@ void menuModelCustomFunctions(uint8_t event) case 1: if (sd->swtch) { - uint8_t func_displayed; - if (CFN_FUNC(sd) < FUNC_TRAINER) { - func_displayed = 0; - putsChn(MODEL_CUSTOM_FUNC_2ND_COLUMN+6*FW, y, CFN_CH_NUMBER(sd)+1, attr); - } - else if (CFN_FUNC(sd) <= FUNC_TRAINER + NUM_STICKS) { - func_displayed = 1; - if (CFN_FUNC(sd) != FUNC_TRAINER) - putsMixerSource(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, MIXSRC_Rud+CFN_FUNC(sd)-FUNC_TRAINER-1, attr); - } -#if defined(DEBUG) - else if (CFN_FUNC(sd) == FUNC_TEST) { -#if defined(GVARS) - func_displayed = FUNC_TEST - FUNC_TRAINER - NUM_STICKS - MAX_GVARS + 2; -#else - func_displayed = FUNC_TEST - FUNC_TRAINER - NUM_STICKS + 1; -#endif - } -#endif -#if defined(GVARS) - else if (CFN_FUNC(sd) >= FUNC_ADJUST_GV1) { - func_displayed = FUNC_ADJUST_GV1 - FUNC_TRAINER - NUM_STICKS + 1; - putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, STR_GV, CFN_FUNC(sd)-FUNC_ADJUST_GV1+1, attr); - } -#endif - else { - func_displayed = 2 + CFN_FUNC(sd) - FUNC_TRAINER - NUM_STICKS - 1; - } - lcd_putsiAtt(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func_displayed, attr); + lcd_putsiAtt(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr); if (active) { -#if defined(CPUARM) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_FUNC(sd), FUNC_MAX-1); -#else - if (CFN_FUNC(sd) < FUNC_TRAINER) { - CHECK_INCDEC_MODELVAR_ZERO(event, sd->internal.func_safety.func, 16); - } - else { - CHECK_INCDEC_MODELVAR_ZERO(event, CFN_FUNC(sd), FUNC_MAX-1); - if (CFN_FUNC(sd) < FUNC_TRAINER) - sd->internal.func_safety.func = 15; - } -#endif if (checkIncDec_Ret) CFN_RESET(sd); } } - else if (attr) { - REPEAT_LAST_CURSOR_MOVE(); + else { + j = 4; // skip other fields + if (attr && m_posHorz > 0) { + REPEAT_LAST_CURSOR_MOVE(); + } } break; case 2: - if (sd->swtch) { - INCDEC_DECLARE_VARS(); - int16_t val_displayed = CFN_PARAM(sd); - int8_t val_min = 0; - uint8_t val_max = 255; - if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) { -#if defined(AUDIO) - val_max = AU_FRSKY_LAST-AU_FRSKY_FIRST-1; - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_FUNCSOUNDS, val_displayed, attr); -#else - break; -#endif - } -#if defined(HAPTIC) - else if (CFN_FUNC(sd) == FUNC_HAPTIC) { - val_max = 3; - lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); - } -#endif -#if defined(CPUARM) && defined(SDCARD) - else if (CFN_FUNC(sd) == FUNC_PLAY_TRACK || CFN_FUNC(sd) == FUNC_BACKGND_MUSIC) { -#if LCD_W >= 212 - xcoord_t x = MODEL_CUSTOM_FUNC_3RD_COLUMN; -#else - xcoord_t x = (CFN_FUNC(sd) == FUNC_PLAY_TRACK ? MODEL_CUSTOM_FUNC_2ND_COLUMN + FW + FW*strlen(TR_PLAY_TRACK) : MODEL_CUSTOM_FUNC_3RD_COLUMN); -#endif - if (ZEXIST(sd->param.name)) - lcd_putsnAtt(x, y, sd->param.name, sizeof(sd->param.name), attr); - else - lcd_putsiAtt(x, y, STR_VCSWFUNC, 0, attr); - if (active && event==EVT_KEY_BREAK(KEY_ENTER)) { - s_editMode = 0; - char directory[] = SOUNDS_PATH; - strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); - if (listSdFiles(directory, SOUNDS_EXT, sizeof(sd->param.name), sd->param.name)) { - menuHandler = onCustomFunctionsFileSelectionMenu; - } - else { - POPUP_WARNING(STR_NO_SOUNDS_ON_SD); - s_menu_flags = 0; - } - } - break; - } - else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) { - val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1; - putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); - INCDEC_ENABLE_CHECK(isSourceAvailable); - } -#endif -#if defined(CPUARM) - else if (CFN_FUNC(sd) == FUNC_VOLUME) { - val_max = MIXSRC_LAST_CH; - putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); - INCDEC_ENABLE_CHECK(isSourceAvailable); - } -#elif defined(VOICE) - else if (CFN_FUNC(sd) == FUNC_PLAY_TRACK) { -#if defined(GVARS) - if (attr && event==EVT_KEY_LONG(KEY_ENTER)) { - killEvents(event); - s_editMode = !s_editMode; - active = true; - val_displayed = (val_displayed > 250 ? 0 : 251); - } - if (val_displayed > 250) { - putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed-250, attr); - } - else { - lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT); - } -#else - lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT); -#endif - } - else if (CFN_FUNC(sd) == FUNC_PLAY_BOTH) { - lcd_putcAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, '|', attr); - lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, val_displayed+PROMPT_CUSTOM_BASE, attr); - lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+2+3*FWNUM, y, (val_displayed+PROMPT_CUSTOM_BASE+1)%10, attr|LEFT); - } - else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) { - val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1; - putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); - INCDEC_ENABLE_CHECK(isSourceAvailable); - } -#endif -#if defined(SDCARD) - else if (CFN_FUNC(sd) == FUNC_LOGS) { - if (val_displayed) { - lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT); - lcd_putc(lcdLastPos, y, 's'); - } - else { - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); - } - } -#endif - else if (CFN_FUNC(sd) == FUNC_RESET) { - val_max = FUNC_RESET_PARAM_LAST; - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, CFN_PARAM(sd), attr); - } - else if (CFN_FUNC(sd) < FUNC_TRAINER) { - val_displayed = (int8_t)CFN_PARAM(sd); - val_min = -125; val_max = 125; - lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); - } -#if defined(GVARS) - else if (CFN_FUNC(sd) >= FUNC_ADJUST_GV1 -#if defined(DEBUG) - && CFN_FUNC(sd) <= FUNC_ADJUST_GVLAST -#endif - ) { - switch (CFN_GVAR_MODE(sd)) { - case FUNC_ADJUST_GVAR_CONSTANT: - val_displayed = (int8_t)CFN_PARAM(sd); - val_min = -125; val_max = 125; - lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); - break; - case FUNC_ADJUST_GVAR_SOURCE: - val_max = MIXSRC_LAST_CH; - putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); - INCDEC_ENABLE_CHECK(isSourceAvailable); - break; - case FUNC_ADJUST_GVAR_GVAR: - val_max = MAX_GVARS-1; - putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr); - break; - default: // FUNC_ADJUST_GVAR_INC - val_max = 1; - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\002-1+1"), val_displayed, attr); - break; - } - - if (attr && event==EVT_KEY_LONG(KEY_ENTER)) { - killEvents(event); - s_editMode = !s_editMode; - active = true; - CFN_GVAR_MODE(sd) += 1; - val_displayed = 0; - } - } -#endif - else { - if (attr) m_posHorz = (CURSOR_MOVED_LEFT(event) ? 1 : 3); - break; - } - - if (active) { - CFN_PARAM(sd) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max); - } + { + int8_t maxParam = NUM_CHNOUT-1; + if (func == FUNC_SAFETY_CHANNEL) { + putsChn(MODEL_CUSTOM_FUNC_2ND_COLUMN+6*FW, y, CFN_CH_NUMBER(sd)+1, attr); } + else if (func == FUNC_TRAINER) { + maxParam = 4; + putsMixerSource(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, MIXSRC_Rud+CFN_CH_NUMBER(sd)-1, attr); + } +#if defined(GVARS) + else if (func == FUNC_ADJUST_GVAR) { + maxParam = MAX_GVARS-1; + putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, STR_GV, CFN_CH_NUMBER(sd)+1, attr); + } +#endif else if (attr) { REPEAT_LAST_CURSOR_MOVE(); } + if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_NUMBER(sd), maxParam); break; + } case 3: - if (sd->swtch && (CFN_FUNC(sd) <= FUNC_INSTANT_TRIM || CFN_FUNC(sd) == FUNC_RESET -#if defined(GVARS) - // TODO #define - || CFN_FUNC(sd) >= FUNC_ADJUST_GV1 + { + INCDEC_DECLARE_VARS(); + int16_t val_displayed = CFN_PARAM(sd); + int8_t val_min = 0; + uint8_t val_max = 255; + if (func == FUNC_SAFETY_CHANNEL) { + val_displayed = (int8_t)CFN_PARAM(sd); + val_min = -125; val_max = 125; + lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); + } +#if defined(AUDIO) + else if (func == FUNC_PLAY_SOUND) { + val_max = AU_FRSKY_LAST-AU_FRSKY_FIRST-1; + lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_FUNCSOUNDS, val_displayed, attr); + break; + } +#endif +#if defined(HAPTIC) + else if (func == FUNC_HAPTIC) { + val_max = 3; + lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); + } +#endif +#if defined(CPUARM) && defined(SDCARD) + else if (func == FUNC_PLAY_TRACK || func == FUNC_BACKGND_MUSIC) { +#if LCD_W >= 212 + xcoord_t x = MODEL_CUSTOM_FUNC_3RD_COLUMN; +#else + xcoord_t x = (func == FUNC_PLAY_TRACK ? MODEL_CUSTOM_FUNC_2ND_COLUMN + FW + FW*strlen(TR_PLAY_TRACK) : MODEL_CUSTOM_FUNC_3RD_COLUMN); +#endif + if (ZEXIST(sd->param.name)) + lcd_putsnAtt(x, y, sd->param.name, sizeof(sd->param.name), attr); + else + lcd_putsiAtt(x, y, STR_VCSWFUNC, 0, attr); + if (active && event==EVT_KEY_BREAK(KEY_ENTER)) { + s_editMode = 0; + char directory[] = SOUNDS_PATH; + strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); + if (listSdFiles(directory, SOUNDS_EXT, sizeof(sd->param.name), sd->param.name)) { + menuHandler = onCustomFunctionsFileSelectionMenu; + } + else { + POPUP_WARNING(STR_NO_SOUNDS_ON_SD); + s_menu_flags = 0; + } + } + break; + } + else if (func == FUNC_PLAY_VALUE) { + val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1; + putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); + INCDEC_ENABLE_CHECK(isSourceAvailable); + } #endif #if defined(CPUARM) - // TODO #define - || CFN_FUNC(sd) == FUNC_VOLUME + else if (func == FUNC_VOLUME) { + val_max = MIXSRC_LAST_CH; + putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); + INCDEC_ENABLE_CHECK(isSourceAvailable); + } +#elif defined(VOICE) + else if (func == FUNC_PLAY_TRACK) { +#if defined(GVARS) + if (attr && event==EVT_KEY_LONG(KEY_ENTER)) { + killEvents(event); + s_editMode = !s_editMode; + active = true; + val_displayed = (val_displayed > 250 ? 0 : 251); + } + if (val_displayed > 250) { + putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed-250, attr); + } + else { + lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT); + } +#else + lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT); #endif - )) { + } + else if (func == FUNC_PLAY_BOTH) { + lcd_putcAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, '|', attr); + lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, val_displayed+PROMPT_CUSTOM_BASE, attr); + lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+2+3*FWNUM, y, (val_displayed+PROMPT_CUSTOM_BASE+1)%10, attr|LEFT); + } + else if (func == FUNC_PLAY_VALUE) { + val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1; + putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); + INCDEC_ENABLE_CHECK(isSourceAvailable); + } +#endif +#if defined(SDCARD) + else if (func == FUNC_LOGS) { + if (val_displayed) { + lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT); + lcd_putc(lcdLastPos, y, 's'); + } + else { + lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); + } + } +#endif + else if (func == FUNC_RESET) { + val_max = FUNC_RESET_PARAM_LAST; + lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, CFN_PARAM(sd), attr); + } +#if defined(GVARS) + else if (func == FUNC_ADJUST_GVAR) { + switch (CFN_GVAR_MODE(sd)) { + case FUNC_ADJUST_GVAR_CONSTANT: + val_displayed = (int8_t)CFN_PARAM(sd); + val_min = -125; val_max = 125; + lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); + break; + case FUNC_ADJUST_GVAR_SOURCE: + val_max = MIXSRC_LAST_CH; + putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); + INCDEC_ENABLE_CHECK(isSourceAvailable); + break; + case FUNC_ADJUST_GVAR_GVAR: + val_max = MAX_GVARS-1; + putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr); + break; + default: // FUNC_ADJUST_GVAR_INC + val_max = 1; + lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\002-1+1"), val_displayed, attr); + break; + } + + if (attr && event==EVT_KEY_LONG(KEY_ENTER)) { + killEvents(event); + s_editMode = !s_editMode; + active = true; + CFN_GVAR_MODE(sd) += 1; + val_displayed = 0; + } + } +#endif + else if (attr) { + REPEAT_LAST_CURSOR_MOVE(); + } + + if (active) { + CFN_PARAM(sd) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max); + } + break; + } + + case 4: + if (func <= FUNC_INSTANT_TRIM || func == FUNC_RESET || IS_ADJUST_GV_FUNC(func) || IS_VOLUME_FUNC(func)) { menu_lcd_onoff(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, CFN_ACTIVE(sd), attr); if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_ACTIVE(sd), 1); } - else if (sd->swtch && HAS_REPEAT_PARAM(sd)) { + else if (HAS_REPEAT_PARAM(sd)) { if (CFN_PLAY_REPEAT(sd) == 0) { #if LCD_W >= 212 lcd_putsAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr); diff --git a/radio/src/gui/menus.cpp b/radio/src/gui/menus.cpp index 9277f05b3..69916bc19 100644 --- a/radio/src/gui/menus.cpp +++ b/radio/src/gui/menus.cpp @@ -1046,6 +1046,16 @@ int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t m } #endif +void repeatLastCursorMove(uint8_t event) +{ + if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) { + putEvent(event); + } + else { + m_posHorz = 0; + } +} + #if LCD_W >= 212 #define MENU_X 30 #define MENU_Y 16 diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index 872af4fa3..15080b7f2 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -400,7 +400,8 @@ void pushMenuTextView(const char *filename); #define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) putEvent(event); else m_posHorz = 0; } #define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE() #else - #define REPEAT_LAST_CURSOR_MOVE() m_posHorz = 0; + void repeatLastCursorMove(uint8_t event); + #define REPEAT_LAST_CURSOR_MOVE() repeatLastCursorMove(event) #define MOVE_CURSOR_FROM_HERE() REPEAT_LAST_CURSOR_MOVE() #endif diff --git a/radio/src/gui/view_main.cpp b/radio/src/gui/view_main.cpp index 93c6e0dfa..d618414ec 100644 --- a/radio/src/gui/view_main.cpp +++ b/radio/src/gui/view_main.cpp @@ -295,7 +295,7 @@ void displayTopBar() x -= 12; } - if (isFunctionActive(FUNC_LOGS)) { + if (isFunctionActive(FUNCTION_LOGS)) { LCD_NOTIF_ICON(x, ICON_LOGS); x -= 12; } diff --git a/radio/src/logs.cpp b/radio/src/logs.cpp index 58c47eacc..41cf29b8d 100644 --- a/radio/src/logs.cpp +++ b/radio/src/logs.cpp @@ -175,7 +175,7 @@ void writeLogs() { static const pm_char * error_displayed = NULL; - if (isFunctionActive(FUNC_LOGS) && logDelay > 0) { + if (isFunctionActive(FUNCTION_LOGS) && logDelay > 0) { tmr10ms_t tmr10ms = get_tmr10ms(); if (lastLogTime == 0 || (tmr10ms_t)(tmr10ms - lastLogTime) >= (tmr10ms_t)logDelay*10) { lastLogTime = tmr10ms; diff --git a/radio/src/maths.cpp b/radio/src/maths.cpp index 6cee8d2d7..346a7dba7 100644 --- a/radio/src/maths.cpp +++ b/radio/src/maths.cpp @@ -120,7 +120,7 @@ void varioWakeup() static tmr10ms_t s_varioTmr; tmr10ms_t tmr10ms = get_tmr10ms(); - if (isFunctionActive(FUNC_VARIO)) { + if (isFunctionActive(FUNCTION_VARIO)) { #if defined(AUDIO) cli(); int16_t verticalSpeed = frskyData.hub.varioSpeed; diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index ba75d686b..0aae1e8c5 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -693,63 +693,54 @@ PACK(typedef struct t_CustomSwData { // Custom Switches data #endif enum Functions { -#if defined(CPUARM) - FUNC_SAFETY_CH1, - FUNC_SAFETY_CH16=FUNC_SAFETY_CH1+15, -#else - FUNC_SAFETY_GROUP1, - FUNC_SAFETY_GROUP2, - FUNC_SAFETY_GROUP3, - FUNC_SAFETY_GROUP4, -#endif + // first the functions which need a checkbox + FUNC_SAFETY_CHANNEL, FUNC_TRAINER, - FUNC_TRAINER_RUD, - FUNC_TRAINER_ELE, - FUNC_TRAINER_THR, - FUNC_TRAINER_AIL, FUNC_INSTANT_TRIM, - FUNC_PLAY_SOUND, -#if !defined(PCBTARANIS) - FUNC_HAPTIC, -#endif FUNC_RESET, - FUNC_VARIO, + FUNC_ADJUST_GVAR, +#if defined(CPUARM) + FUNC_VOLUME, +#endif + + // then the other functions + FUNC_FIRST_WITHOUT_ENABLE, + FUNC_PLAY_SOUND = FUNC_FIRST_WITHOUT_ENABLE, FUNC_PLAY_TRACK, #if !defined(CPUARM) FUNC_PLAY_BOTH, #endif FUNC_PLAY_VALUE, -#if !defined(PCBSTD) - FUNC_LOGS, -#endif -#if defined(CPUARM) - FUNC_VOLUME, -#endif - FUNC_BACKLIGHT, #if defined(CPUARM) FUNC_BACKGND_MUSIC, FUNC_BACKGND_MUSIC_PAUSE, #endif -#if defined(GVARS) - FUNC_ADJUST_GV1, - FUNC_ADJUST_GVLAST = (FUNC_ADJUST_GV1 + (MAX_GVARS-1)), + FUNC_VARIO, + FUNC_HAPTIC, +#if !defined(PCBSTD) + FUNC_LOGS, #endif + FUNC_BACKLIGHT, #if defined(DEBUG) FUNC_TEST, // should remain the last before MAX as not added in companion9x #endif FUNC_MAX }; +#define HAS_ENABLE_PARAM(func) (func < FUNC_FIRST_WITHOUT_ENABLE) + #if defined(CPUARM) - #define IS_PLAY_BOTH_FUNC(sd) (0) + #define IS_PLAY_BOTH_FUNC(func) (0) + #define IS_VOLUME_FUNC(func) (func == FUNC_VOLUME) #else - #define IS_PLAY_BOTH_FUNC(sd) (CFN_FUNC(sd) == FUNC_PLAY_BOTH) + #define IS_PLAY_BOTH_FUNC(func) (func == FUNC_PLAY_BOTH) + #define IS_VOLUME_FUNC(func) (0) #endif #if defined(GVARS) - #define IS_ADJUST_GV_FUNCTION(sd) (CFN_FUNC(sd) >= FUNC_ADJUST_GV1 && CFN_FUNC(sd) <= FUNC_ADJUST_GVLAST) + #define IS_ADJUST_GV_FUNC(func) (func == FUNC_ADJUST_GVAR) #else - #define IS_ADJUST_GV_FUNCTION(sd) (0) + #define IS_ADJUST_GV_FUNC(func) (0) #endif #if defined(VOICE) @@ -814,34 +805,20 @@ PACK(typedef struct t_CustomFnData { // Function Switches data #define CFN_RESET(p) (p->active = 0, memset(&(p)->param, 0, sizeof((p)->param))) #else PACK(typedef struct t_CustomFnData { - int8_t swtch; // input - union { - struct { - uint8_t param:3; - uint8_t func:5; - } func_param; - - struct { - uint8_t active:1; - uint8_t param:2; - uint8_t func:5; - } func_param_enable; - - struct { - uint8_t active:1; - uint8_t func:7; - } func_safety; - } internal; - uint8_t param; + uint8_t value; + uint8_t func:5; + uint8_t active:1; + int16_t swtch:6; + uint8_t param:4; }) CustomFnData; -#define CFN_FUNC(p) ((p)->internal.func_param.func) -#define CFN_ACTIVE(p) ((p)->internal.func_param_enable.active) -#define CFN_CH_NUMBER(p) ((p)->internal.func_safety.func) -#define CFN_PLAY_REPEAT(p) ((p)->internal.func_param.param) +#define CFN_FUNC(p) ((p)->func) +#define CFN_ACTIVE(p) ((p)->active) +#define CFN_CH_NUMBER(p) ((p)->param) +#define CFN_PLAY_REPEAT(p) ((p)->param) #define CFN_PLAY_REPEAT_MUL 10 -#define CFN_GVAR_MODE(p) ((p)->internal.func_param_enable.param) -#define CFN_PARAM(p) ((p)->param) -#define CFN_RESET(p) ((p)->internal.func_param_enable.active = 0, CFN_PARAM(p) = 0) +#define CFN_GVAR_MODE(p) ((p)->param) +#define CFN_PARAM(p) ((p)->value) +#define CFN_RESET(p) ((p)->active = 0, CFN_PARAM(p) = 0) #endif enum TelemetryUnit { diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 27dd80868..f8a4eb4f5 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1531,15 +1531,17 @@ bool getSwitch(int8_t swtch) cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*50); } } + if (cs->duration) { - if (result && !cswStates[cs_idx]) + if (result && !cswStates[cs_idx]) { cswDurations[cs_idx] = get_tmr10ms() + (cs->duration*50); + } cswStates[cs_idx] = result; + result = false; if (cswDurations[cs_idx] > get_tmr10ms()) { result = true; - if (cs->delay) cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*50); } } #endif @@ -2031,7 +2033,7 @@ void checkBacklight() backlightOn(); } - bool backlightOn = (g_eeGeneral.backlightMode == e_backlight_mode_on || lightOffCounter || isFunctionActive(FUNC_BACKLIGHT)); + bool backlightOn = (g_eeGeneral.backlightMode == e_backlight_mode_on || lightOffCounter || isFunctionActive(FUNCTION_BACKLIGHT)); if (flashCounter) backlightOn = !backlightOn; if (backlightOn) BACKLIGHT_ON(); @@ -2841,7 +2843,7 @@ void evalInputs(uint8_t mode) } if (ch < NUM_STICKS) { //only do this for sticks - if (mode <= e_perout_mode_inactive_phase && (isFunctionActive(FUNC_TRAINER) || isFunctionActive(FUNC_TRAINER_RUD+ch))) { + if (mode <= e_perout_mode_inactive_phase && isFunctionActive(FUNCTION_TRAINER+ch)) { // trainer mode TrainerMix* td = &g_eeGeneral.trainer.mix[ch]; if (td->mode) { @@ -2899,7 +2901,6 @@ void testFunc() #endif MASK_FUNC_TYPE activeFunctions = 0; -MASK_CFN_TYPE activeSwitches = 0; MASK_CFN_TYPE activeFnSwitches = 0; tmr10ms_t lastFunctionTime[NUM_CFN] = { 0 }; @@ -3060,175 +3061,90 @@ bool evalFunctionsFirstTime = true; void evalFunctions() { MASK_FUNC_TYPE newActiveFunctions = 0; - MASK_CFN_TYPE newActiveSwitches = 0; MASK_CFN_TYPE newActiveFnSwitches = 0; #if defined(ROTARY_ENCODERS) && defined(GVARS) static rotenc_t rePreviousValues[ROTARY_ENCODERS]; #endif - for (uint8_t i=0; iswtch; if (swtch) { - MASK_FUNC_TYPE function_mask = (CFN_FUNC(sd) >= FUNC_TRAINER ? ((MASK_FUNC_TYPE)1 << (CFN_FUNC(sd)-FUNC_TRAINER)) : 0); MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i); bool active = getSwitch(swtch); - if (active) newActiveSwitches |= switch_mask; - if (active || IS_PLAY_BOTH_FUNC(sd)) { + if (HAS_ENABLE_PARAM(CFN_FUNC(sd))) { + active &= CFN_ACTIVE(sd); + } - if (CFN_ACTIVE(sd)) { - if (CFN_FUNC(sd) < FUNC_TRAINER) { + if (active || IS_PLAY_BOTH_FUNC(CFN_FUNC(sd))) { + + switch(CFN_FUNC(sd)) { + + case FUNC_SAFETY_CHANNEL: safetyCh[CFN_CH_NUMBER(sd)] = CFN_PARAM(sd); + break; + + case FUNC_TRAINER: + { + uint8_t mask = 0x0f; + if (CFN_CH_NUMBER(sd) > 0) { + mask = (1<<(CFN_CH_NUMBER(sd)-1)); + } + newActiveFunctions |= mask; + break; } - if (!(activeFunctions & function_mask)) { - if (CFN_FUNC(sd) == FUNC_INSTANT_TRIM) { + case FUNC_INSTANT_TRIM: + if (!isFunctionActive(FUNCTION_INSTANT_TRIM)) { + newActiveFunctions |= (1 << FUNCTION_INSTANT_TRIM); if (g_menuStack[0] == menuMainView #if defined(FRSKY) || g_menuStack[0] == menuTelemetryFrsky #endif - ) + ) instantTrim(); } - } - } - else if (CFN_FUNC(sd) <= FUNC_INSTANT_TRIM || CFN_FUNC(sd) == FUNC_RESET) { - active = false; - } + break; - if (CFN_FUNC(sd) == FUNC_RESET) { - switch (CFN_PARAM(sd)) { - case FUNC_RESET_TIMER1: - case FUNC_RESET_TIMER2: - resetTimer(CFN_PARAM(sd)); - break; - case FUNC_RESET_ALL: - resetAll(); - break; + case FUNC_RESET: + switch (CFN_PARAM(sd)) { + case FUNC_RESET_TIMER1: + case FUNC_RESET_TIMER2: + resetTimer(CFN_PARAM(sd)); + break; + case FUNC_RESET_ALL: + resetAll(); + break; #if defined(FRSKY) - case FUNC_RESET_TELEMETRY: - resetTelemetry(); - break; + case FUNC_RESET_TELEMETRY: + resetTelemetry(); + break; #endif #if ROTARY_ENCODERS > 0 - case FUNC_RESET_ROTENC1: + case FUNC_RESET_ROTENC1: #if ROTARY_ENCODERS > 1 - case FUNC_RESET_ROTENC2: + case FUNC_RESET_ROTENC2: #endif - g_rotenc[CFN_PARAM(sd)-FUNC_RESET_ROTENC1] = 0; - break; + g_rotenc[CFN_PARAM(sd)-FUNC_RESET_ROTENC1] = 0; + break; #endif - } - } - -#if defined(SDCARD) - else if (CFN_FUNC(sd) == FUNC_LOGS) { - logDelay = CFN_PARAM(sd); - } -#endif - -#if defined(HAPTIC) - else if (CFN_FUNC(sd) == FUNC_HAPTIC) { - haptic.event(AU_FRSKY_LAST+CFN_PARAM(sd)); - } -#endif - -#if defined(CPUARM) && defined(SDCARD) - else if (CFN_FUNC(sd) == FUNC_PLAY_SOUND || CFN_FUNC(sd) == FUNC_PLAY_TRACK || CFN_FUNC(sd) == FUNC_PLAY_VALUE) { - tmr10ms_t tmr10ms = get_tmr10ms(); - uint8_t repeatParam = CFN_PLAY_REPEAT(sd); - if (evalFunctionsFirstTime && repeatParam == CFN_PLAY_REPEAT_NOSTART) - lastFunctionTime[i] = tmr10ms; - if (!lastFunctionTime[i] || (repeatParam && repeatParam!=CFN_PLAY_REPEAT_NOSTART && (signed)(tmr10ms-lastFunctionTime[i])>=100*repeatParam)) { - if (!IS_PLAYING(i+1)) { - lastFunctionTime[i] = tmr10ms; - if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) { - AUDIO_PLAY(AU_FRSKY_FIRST+CFN_PARAM(sd)); - } - else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) { - PLAY_VALUE(CFN_PARAM(sd), i+1); - } - else { - playCustomFunctionFile(sd, i+1); - } } - } - } - else if (CFN_FUNC(sd) == FUNC_BACKGND_MUSIC) { - if (!IS_PLAYING(i+1)) { - playCustomFunctionFile(sd, i+1); - } - } - else if (CFN_FUNC(sd) == FUNC_VOLUME) { - if (CFN_ACTIVE(sd)) { - getvalue_t raw = getValue(CFN_PARAM(sd)); - //only set volume if input changed more than hysteresis - if (abs(requiredSpeakerVolumeRawLast - raw) > VOLUME_HYSTERESIS) { - requiredSpeakerVolumeRawLast = raw; - } - requiredSpeakerVolume = ((1024 + requiredSpeakerVolumeRawLast) * VOLUME_LEVEL_MAX) / 2048; - } - else { - active = false; - } - } -#elif defined(VOICE) - else if (CFN_FUNC(sd) == FUNC_PLAY_SOUND || CFN_FUNC(sd) == FUNC_PLAY_TRACK || CFN_FUNC(sd) == FUNC_PLAY_BOTH || CFN_FUNC(sd) == FUNC_PLAY_VALUE) { - tmr10ms_t tmr10ms = get_tmr10ms(); - uint8_t repeatParam = CFN_PLAY_REPEAT(sd); - if (!lastFunctionTime[i] || (CFN_FUNC(sd)==FUNC_PLAY_BOTH && active!=(bool)(activeFnSwitches&switch_mask)) || (repeatParam && (signed)(tmr10ms-lastFunctionTime[i])>=1000*repeatParam)) { - lastFunctionTime[i] = tmr10ms; - uint8_t param = CFN_PARAM(sd); - if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) { - AUDIO_PLAY(AU_FRSKY_FIRST+param); - } - else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) { - PLAY_VALUE(param, i+1); - } - else { -#if defined(GVARS) - if (CFN_FUNC(sd) == FUNC_PLAY_TRACK && param > 250) - param = GVAR_VALUE(param-251, getGVarFlightPhase(s_perout_flight_phase, param-251)); -#endif - PUSH_CUSTOM_PROMPT(active ? param : param+1, i+1); - } - } - } -#else - else if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) { - tmr10ms_t tmr10ms = get_tmr10ms(); - uint8_t repeatParam = CFN_PLAY_REPEAT(sd); - if (!lastFunctionTime[i] || (repeatParam && (signed)(tmr10ms-lastFunctionTime[i])>=1000*repeatParam)) { - lastFunctionTime[i] = tmr10ms; - AUDIO_PLAY(AU_FRSKY_FIRST+CFN_PARAM(sd)); - } - } -#endif - -#if defined(DEBUG) - else if (CFN_FUNC(sd) == FUNC_TEST) { - testFunc(); - } -#endif + break; #if defined(GVARS) - else if (CFN_FUNC(sd) >= FUNC_ADJUST_GV1) { - if (CFN_ACTIVE(sd)) { + case FUNC_ADJUST_GVAR: if (CFN_GVAR_MODE(sd) == 0) { SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, CFN_PARAM(sd), s_perout_flight_phase); } @@ -3254,17 +3170,130 @@ void evalFunctions() else { SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, limit((getvalue_t)-1250, getValue(CFN_PARAM(sd)), (getvalue_t)1250) / 10, s_perout_flight_phase); } - } - else { - active = false; - } - } + break; #endif - if (active) { - newActiveFnSwitches |= switch_mask; - newActiveFunctions |= function_mask; +#if defined(CPUARM) && defined(SDCARD) + case FUNC_VOLUME: + { + getvalue_t raw = getValue(CFN_PARAM(sd)); + //only set volume if input changed more than hysteresis + if (abs(requiredSpeakerVolumeRawLast - raw) > VOLUME_HYSTERESIS) { + requiredSpeakerVolumeRawLast = raw; + } + requiredSpeakerVolume = ((1024 + requiredSpeakerVolumeRawLast) * VOLUME_LEVEL_MAX) / 2048; + break; + } +#endif + +#if defined(CPUARM) && defined(SDCARD) + case FUNC_PLAY_SOUND: + case FUNC_PLAY_TRACK: + case FUNC_PLAY_VALUE: + { + tmr10ms_t tmr10ms = get_tmr10ms(); + uint8_t repeatParam = CFN_PLAY_REPEAT(sd); + if (evalFunctionsFirstTime && repeatParam == CFN_PLAY_REPEAT_NOSTART) + lastFunctionTime[i] = tmr10ms; + if (!lastFunctionTime[i] || (repeatParam && repeatParam!=CFN_PLAY_REPEAT_NOSTART && (signed)(tmr10ms-lastFunctionTime[i])>=100*repeatParam)) { + if (!IS_PLAYING(i+1)) { + lastFunctionTime[i] = tmr10ms; + if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) { + AUDIO_PLAY(AU_FRSKY_FIRST+CFN_PARAM(sd)); + } + else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) { + PLAY_VALUE(CFN_PARAM(sd), i+1); + } + else { + playCustomFunctionFile(sd, i+1); + } + } + } + break; + } + + case FUNC_BACKGND_MUSIC: + newActiveFunctions |= (1 << FUNCTION_BACKGND_MUSIC); + if (!IS_PLAYING(i+1)) { + playCustomFunctionFile(sd, i+1); + } + break; + + case FUNC_BACKGND_MUSIC_PAUSE: + newActiveFunctions |= (1 << FUNCTION_BACKGND_MUSIC_PAUSE); + break; + +#elif defined(VOICE) + case FUNC_PLAY_SOUND: + case FUNC_PLAY_TRACK: + case FUNC_PLAY_BOTH: + case FUNC_PLAY_VALUE: + { + tmr10ms_t tmr10ms = get_tmr10ms(); + uint8_t repeatParam = CFN_PLAY_REPEAT(sd); + if (!lastFunctionTime[i] || (CFN_FUNC(sd)==FUNC_PLAY_BOTH && active!=(bool)(activeFnSwitches&switch_mask)) || (repeatParam && (signed)(tmr10ms-lastFunctionTime[i])>=1000*repeatParam)) { + lastFunctionTime[i] = tmr10ms; + uint8_t param = CFN_PARAM(sd); + if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) { + AUDIO_PLAY(AU_FRSKY_FIRST+param); + } + else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) { + PLAY_VALUE(param, i+1); + } + else { +#if defined(GVARS) + if (CFN_FUNC(sd) == FUNC_PLAY_TRACK && param > 250) + param = GVAR_VALUE(param-251, getGVarFlightPhase(s_perout_flight_phase, param-251)); +#endif + PUSH_CUSTOM_PROMPT(active ? param : param+1, i+1); + } + } + break; + } +#else + case FUNC_PLAY_SOUND: + { + tmr10ms_t tmr10ms = get_tmr10ms(); + uint8_t repeatParam = CFN_PLAY_REPEAT(sd); + if (!lastFunctionTime[i] || (repeatParam && (signed)(tmr10ms-lastFunctionTime[i])>=1000*repeatParam)) { + lastFunctionTime[i] = tmr10ms; + AUDIO_PLAY(AU_FRSKY_FIRST+CFN_PARAM(sd)); + } + break; + } +#endif + +#if defined(FRSKY) && defined(VARIO) + case FUNC_VARIO: + newActiveFunctions |= (1 << FUNCTION_VARIO); + break; +#endif + +#if defined(HAPTIC) + case FUNC_HAPTIC: + haptic.event(AU_FRSKY_LAST+CFN_PARAM(sd)); + break; +#endif + +#if defined(SDCARD) + case FUNC_LOGS: + newActiveFunctions |= (1 << FUNCTION_LOGS); + logDelay = CFN_PARAM(sd); + break; +#endif + + case FUNC_BACKLIGHT: + newActiveFunctions |= (1 << FUNCTION_BACKLIGHT); + break; + +#if defined(DEBUG) + case FUNC_TEST: + testFunc(); + break; +#endif } + + newActiveFnSwitches |= switch_mask; } else { lastFunctionTime[i] = 0; @@ -3272,7 +3301,7 @@ void evalFunctions() fnSwitchDuration[i] = 0; #endif #if defined(CPUARM) && defined(SDCARD) - if (CFN_FUNC(sd) == FUNC_BACKGND_MUSIC && isFunctionActive(FUNC_BACKGND_MUSIC)) { + if (CFN_FUNC(sd) == FUNC_BACKGND_MUSIC && isFunctionActive(FUNCTION_BACKGND_MUSIC)) { STOP_PLAY(i+1); } #endif @@ -3280,13 +3309,13 @@ void evalFunctions() } } - activeSwitches = newActiveSwitches; activeFnSwitches = newActiveFnSwitches; activeFunctions = newActiveFunctions; #if defined(ROTARY_ENCODERS) && defined(GVARS) - for (uint8_t i=0; i Date: Tue, 4 Feb 2014 07:35:46 +0100 Subject: [PATCH 05/28] Issue #592 - Corrections for ARM boards --- radio/src/gui/menu_model.cpp | 4 ++++ radio/src/myeeprom.h | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index a6e64c67d..ddb5a5692 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4754,7 +4754,11 @@ void menuModelCustomFunctions(uint8_t event) } else if (func == FUNC_TRAINER) { maxParam = 4; +#if defined(CPUARM) + putsMixerSource(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, CFN_CH_NUMBER(sd)==0 ? 0 : MIXSRC_Rud+CFN_CH_NUMBER(sd)-1, attr); +#else putsMixerSource(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, MIXSRC_Rud+CFN_CH_NUMBER(sd)-1, attr); +#endif } #if defined(GVARS) else if (func == FUNC_ADJUST_GVAR) { diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 0aae1e8c5..535b65fe1 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -786,23 +786,23 @@ PACK(typedef struct t_CustomFnData { // Function Switches data char name[LEN_CFN_NAME]; struct { int16_t val; - int16_t ext1; - int16_t ext2; + uint8_t mode; + uint8_t spare1; + int16_t spare2; } composite; }) param; - uint8_t mode:2; - uint8_t active:6; + uint8_t active; }) CustomFnData; #define CFN_EMPTY(p) (!(p)->swtch) #define CFN_FUNC(p) ((p)->func) #define CFN_ACTIVE(p) ((p)->active) -#define CFN_CH_NUMBER(p) (CFN_FUNC(p)) +#define CFN_CH_NUMBER(p) ((p)->param.composite.mode) #define CFN_PLAY_REPEAT(p) ((p)->active) #define CFN_PLAY_REPEAT_MUL 1 #define CFN_PLAY_REPEAT_NOSTART 0x3F -#define CFN_GVAR_MODE(p) ((p)->mode) +#define CFN_GVAR_MODE(p) ((p)->param.composite.mode) #define CFN_PARAM(p) ((p)->param.composite.val) -#define CFN_RESET(p) (p->active = 0, memset(&(p)->param, 0, sizeof((p)->param))) +#define CFN_RESET(p) ((p)->active=0, (p)->param.composite.val=0, (p)->param.composite.mode=0, (p)->param.composite.spare1=0, (p)->param.composite.spare2=0) #else PACK(typedef struct t_CustomFnData { uint8_t value; From 9c82e62cc7ca8d4581c6572d473a4d37626057dc Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 4 Feb 2014 10:28:11 +0100 Subject: [PATCH 06/28] [all] Issue #592 - Corrections (GVARS) --- radio/src/gui/menu_model.cpp | 24 +++++++------- radio/src/lcd.cpp | 10 ------ radio/src/myeeprom.h | 64 +++++++++++++++++++++++++----------- radio/src/opentx.cpp | 20 +++++------ 4 files changed, 68 insertions(+), 50 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index ddb5a5692..49d240209 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4640,14 +4640,14 @@ void onCustomFunctionsFileSelectionMenu(const char *result) if (result == STR_UPDATE_LIST) { char directory[] = SOUNDS_PATH; strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); - if (!listSdFiles(directory, SOUNDS_EXT, sizeof(g_model.funcSw[sub].param), NULL)) { + if (!listSdFiles(directory, SOUNDS_EXT, sizeof(g_model.funcSw[sub].play.name), NULL)) { POPUP_WARNING(STR_NO_SOUNDS_ON_SD); s_menu_flags = 0; } } else { // The user choosed a wav file in the list - memcpy(g_model.funcSw[sub].param.name, result, sizeof(g_model.funcSw[sub].param.name)); + memcpy(g_model.funcSw[sub].play.name, result, sizeof(g_model.funcSw[sub].play.name)); eeDirty(EE_MODEL); } } @@ -4726,12 +4726,12 @@ void menuModelCustomFunctions(uint8_t event) uint8_t active = (attr && (s_editMode>0 || p1valdiff)); switch (j) { case 0: - putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, sd->swtch, attr | ((activeFnSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); - if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_MODELSWITCH(event, sd->swtch, SWSRC_FIRST, SWSRC_LAST); + putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(sd), attr | ((activeFnSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); + if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_MODELSWITCH(event, CFN_SWITCH(sd), SWSRC_FIRST, SWSRC_LAST); break; case 1: - if (sd->swtch) { + if (CFN_SWITCH(sd)) { lcd_putsiAtt(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr); if (active) { CHECK_INCDEC_MODELVAR_ZERO(event, CFN_FUNC(sd), FUNC_MAX-1); @@ -4740,7 +4740,7 @@ void menuModelCustomFunctions(uint8_t event) } else { j = 4; // skip other fields - if (attr && m_posHorz > 0) { + if (sub==k && m_posHorz > 0) { REPEAT_LAST_CURSOR_MOVE(); } } @@ -4763,7 +4763,9 @@ void menuModelCustomFunctions(uint8_t event) #if defined(GVARS) else if (func == FUNC_ADJUST_GVAR) { maxParam = MAX_GVARS-1; - putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, STR_GV, CFN_CH_NUMBER(sd)+1, attr); + putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, STR_GV, CFN_GVAR_NUMBER(sd)+1, attr); + if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_GVAR_NUMBER(sd), maxParam); + break; } #endif else if (attr) { @@ -4804,15 +4806,15 @@ void menuModelCustomFunctions(uint8_t event) #else xcoord_t x = (func == FUNC_PLAY_TRACK ? MODEL_CUSTOM_FUNC_2ND_COLUMN + FW + FW*strlen(TR_PLAY_TRACK) : MODEL_CUSTOM_FUNC_3RD_COLUMN); #endif - if (ZEXIST(sd->param.name)) - lcd_putsnAtt(x, y, sd->param.name, sizeof(sd->param.name), attr); + if (ZEXIST(sd->play.name)) + lcd_putsnAtt(x, y, sd->play.name, sizeof(sd->play.name), attr); else lcd_putsiAtt(x, y, STR_VCSWFUNC, 0, attr); if (active && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; char directory[] = SOUNDS_PATH; strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); - if (listSdFiles(directory, SOUNDS_EXT, sizeof(sd->param.name), sd->param.name)) { + if (listSdFiles(directory, SOUNDS_EXT, sizeof(sd->play.name), sd->play.name)) { menuHandler = onCustomFunctionsFileSelectionMenu; } else { @@ -4922,7 +4924,7 @@ void menuModelCustomFunctions(uint8_t event) } case 4: - if (func <= FUNC_INSTANT_TRIM || func == FUNC_RESET || IS_ADJUST_GV_FUNC(func) || IS_VOLUME_FUNC(func)) { + if (HAS_ENABLE_PARAM(func)) { menu_lcd_onoff(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, CFN_ACTIVE(sd), attr); if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_ACTIVE(sd), 1); } diff --git a/radio/src/lcd.cpp b/radio/src/lcd.cpp index 7bfabb139..c4532dcad 100644 --- a/radio/src/lcd.cpp +++ b/radio/src/lcd.cpp @@ -1043,16 +1043,6 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) lcd_vlineStip(x-2, y, 8, 0x5E/*'!'*/); idx = -idx; } - -#if ROTARY_ENCODERS > 0 - else if (idx >= SWSRC_FIRST_ROTENC_SWITCH) { - idx -= SWSRC_FIRST_ROTENC_SWITCH; - char suffix = (idx & 1) ? CHR_LONG : CHR_SHORT; - lcd_putsiAtt(x, y, STR_VRENCODERS, idx/2, att); - return lcd_putcAtt(lcdLastPos, y, suffix, att); - } -#endif - lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att); } diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 535b65fe1..b95760e55 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -783,42 +783,68 @@ PACK(typedef struct t_CustomFnData { // Function Switches data int8_t swtch; uint8_t func; PACK(union { - char name[LEN_CFN_NAME]; + struct { + char name[LEN_CFN_NAME]; + } play; + struct { int16_t val; uint8_t mode; - uint8_t spare1; + uint8_t param; int16_t spare2; - } composite; - }) param; + } all; + + struct { + int32_t val1; + int16_t val2; + } clear; + }); uint8_t active; }) CustomFnData; #define CFN_EMPTY(p) (!(p)->swtch) +#define CFN_SWITCH(p) ((p)->swtch) #define CFN_FUNC(p) ((p)->func) #define CFN_ACTIVE(p) ((p)->active) -#define CFN_CH_NUMBER(p) ((p)->param.composite.mode) +#define CFN_CH_NUMBER(p) ((p)->all.param) #define CFN_PLAY_REPEAT(p) ((p)->active) #define CFN_PLAY_REPEAT_MUL 1 #define CFN_PLAY_REPEAT_NOSTART 0x3F -#define CFN_GVAR_MODE(p) ((p)->param.composite.mode) -#define CFN_PARAM(p) ((p)->param.composite.val) -#define CFN_RESET(p) ((p)->active=0, (p)->param.composite.val=0, (p)->param.composite.mode=0, (p)->param.composite.spare1=0, (p)->param.composite.spare2=0) +#define CFN_GVAR_NUMBER(p) ((p)->all.param) +#define CFN_GVAR_MODE(p) ((p)->all.mode) +#define CFN_PARAM(p) ((p)->all.val) +#define CFN_RESET(p) ((p)->active=0, (p)->clear.val1=0, (p)->clear.val2=0) #else PACK(typedef struct t_CustomFnData { - uint8_t value; - uint8_t func:5; - uint8_t active:1; - int16_t swtch:6; - uint8_t param:4; + PACK(union { + struct { + int8_t swtch:6; + uint16_t func:4; + uint8_t mode:2; + uint8_t param:3; + uint8_t active:1; + } gvar; + + struct { + int8_t swtch:6; + uint16_t func:4; + uint8_t param:4; + uint8_t spare:1; + uint8_t active:1; + } all; + }); + + uint8_t value; }) CustomFnData; -#define CFN_FUNC(p) ((p)->func) -#define CFN_ACTIVE(p) ((p)->active) -#define CFN_CH_NUMBER(p) ((p)->param) -#define CFN_PLAY_REPEAT(p) ((p)->param) +#define CFN_SWITCH(p) ((p)->all.swtch) +#define CFN_FUNC(p) ((p)->all.func) +#define CFN_ACTIVE(p) ((p)->all.active) +#define CFN_CH_NUMBER(p) ((p)->all.param) +#define CFN_PLAY_REPEAT(p) ((p)->all.param) #define CFN_PLAY_REPEAT_MUL 10 -#define CFN_GVAR_MODE(p) ((p)->param) +#define CFN_GVAR_NUMBER(p) ((p)->gvar.param) +#define CFN_GVAR_MODE(p) ((p)->gvar.mode) #define CFN_PARAM(p) ((p)->value) -#define CFN_RESET(p) ((p)->active = 0, CFN_PARAM(p) = 0) +#define CFN_RESET(p) ((p)->all.active = 0, CFN_PARAM(p) = 0) #endif enum TelemetryUnit { diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index f8a4eb4f5..c3e19f4fb 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -3045,10 +3045,10 @@ uint8_t fnSwitchDuration[NUM_CFN] = { 0 }; inline void playCustomFunctionFile(CustomFnData *sd, uint8_t id) { - char filename[sizeof(SOUNDS_PATH)+sizeof(sd->param.name)+sizeof(SOUNDS_EXT)] = SOUNDS_PATH "/"; + char filename[sizeof(SOUNDS_PATH)+sizeof(sd->play.name)+sizeof(SOUNDS_EXT)] = SOUNDS_PATH "/"; strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); - strncpy(filename+sizeof(SOUNDS_PATH), sd->param.name, sizeof(sd->param.name)); - filename[sizeof(SOUNDS_PATH)+sizeof(sd->param.name)] = '\0'; + strncpy(filename+sizeof(SOUNDS_PATH), sd->play.name, sizeof(sd->play.name)); + filename[sizeof(SOUNDS_PATH)+sizeof(sd->play.name)] = '\0'; strcat(filename+sizeof(SOUNDS_PATH), SOUNDS_EXT); PLAY_FILE(filename, sd->func==FUNC_BACKGND_MUSIC ? PLAY_BACKGROUND : 0, id); } @@ -3078,7 +3078,7 @@ void evalFunctions() for (uint8_t i=0; iswtch; + int8_t swtch = CFN_SWITCH(sd); if (swtch) { MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i); @@ -3146,29 +3146,29 @@ void evalFunctions() #if defined(GVARS) case FUNC_ADJUST_GVAR: if (CFN_GVAR_MODE(sd) == 0) { - SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, CFN_PARAM(sd), s_perout_flight_phase); + SET_GVAR(CFN_GVAR_NUMBER(sd), CFN_PARAM(sd), s_perout_flight_phase); } else if (CFN_GVAR_MODE(sd) == 2) { - SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, GVAR_VALUE(CFN_PARAM(sd), s_perout_flight_phase), s_perout_flight_phase); + SET_GVAR(CFN_GVAR_NUMBER(sd), GVAR_VALUE(CFN_PARAM(sd), s_perout_flight_phase), s_perout_flight_phase); } else if (CFN_GVAR_MODE(sd) == 3) { if (!(activeFnSwitches & switch_mask)) { - SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, GVAR_VALUE(CFN_FUNC(sd)-FUNC_ADJUST_GV1, getGVarFlightPhase(s_perout_flight_phase, CFN_FUNC(sd)-FUNC_ADJUST_GV1)) + (CFN_PARAM(sd) ? +1 : -1), s_perout_flight_phase); + SET_GVAR(CFN_GVAR_NUMBER(sd), GVAR_VALUE(CFN_GVAR_NUMBER(sd), getGVarFlightPhase(s_perout_flight_phase, CFN_GVAR_NUMBER(sd))) + (CFN_PARAM(sd) ? +1 : -1), s_perout_flight_phase); } } else if (CFN_PARAM(sd) >= MIXSRC_TrimRud && CFN_PARAM(sd) <= MIXSRC_TrimAil) { - trimGvar[CFN_PARAM(sd)-MIXSRC_TrimRud] = CFN_FUNC(sd)-FUNC_ADJUST_GV1; + trimGvar[CFN_PARAM(sd)-MIXSRC_TrimRud] = CFN_GVAR_NUMBER(sd); } #if defined(ROTARY_ENCODERS) else if (CFN_PARAM(sd) >= MIXSRC_REa && CFN_PARAM(sd) < MIXSRC_TrimRud) { int8_t scroll = rePreviousValues[CFN_PARAM(sd)-MIXSRC_REa] - (g_rotenc[CFN_PARAM(sd)-MIXSRC_REa] / ROTARY_ENCODER_GRANULARITY); if (scroll) { - SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, GVAR_VALUE(CFN_FUNC(sd)-FUNC_ADJUST_GV1, getGVarFlightPhase(s_perout_flight_phase, CFN_FUNC(sd)-FUNC_ADJUST_GV1)) + scroll, s_perout_flight_phase); + SET_GVAR(CFN_GVAR_NUMBER(sd), GVAR_VALUE(CFN_GVAR_NUMBER(sd), getGVarFlightPhase(s_perout_flight_phase, CFN_GVAR_NUMBER(sd))) + scroll, s_perout_flight_phase); } } #endif else { - SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, limit((getvalue_t)-1250, getValue(CFN_PARAM(sd)), (getvalue_t)1250) / 10, s_perout_flight_phase); + SET_GVAR(CFN_GVAR_NUMBER(sd), limit((getvalue_t)-1250, getValue(CFN_PARAM(sd)), (getvalue_t)1250) / 10, s_perout_flight_phase); } break; #endif From b18a642de662d9b3a87d808fc9fa70771094237d Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 4 Feb 2014 10:48:48 +0100 Subject: [PATCH 07/28] Test Companion automatic compilation --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index c9f3d46c8..4d36d8d36 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -19,3 +19,4 @@ Grootwitbaas - 9xforums.com (mac) Adrian Amberg (splash screens) Wallaguest1 - 9xforums.com (splash screens) HC1969 - 9xforums.com (splash screens) + From c473b8e105563c72713a291d49b1e160d4b53e64 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 5 Feb 2014 22:31:43 +0100 Subject: [PATCH 08/28] Issue #592 - Support for Sticky Switches in Companion --- companion/src/comparedialog.cpp | 8 +- companion/src/eepromimportexport.h | 19 +- companion/src/eeprominterface.cpp | 271 +++++++-- companion/src/eeprominterface.h | 102 ++-- companion/src/firmwares/er9x/er9xeeprom.cpp | 8 +- .../src/firmwares/er9x/er9xinterface.cpp | 2 +- .../src/firmwares/ersky9x/ersky9xeeprom.cpp | 4 +- .../firmwares/ersky9x/ersky9xinterface.cpp | 4 +- .../firmwares/opentx/open9xSky9xeeprom.cpp | 10 +- .../firmwares/opentx/open9xStockeeprom.cpp | 10 +- .../src/firmwares/opentx/opentxeeprom.cpp | 557 +++++++++++------- companion/src/helpers.cpp | 276 +-------- companion/src/helpers.h | 6 - companion/src/modeledit/curves.cpp | 7 + companion/src/modeledit/customfunctions.cpp | 2 +- companion/src/modeledit/customswitches.cpp | 65 +- companion/src/modeledit/customswitches.h | 3 + companion/src/modeledit/telemetry.cpp | 2 +- companion/src/printdialog.cpp | 4 +- radio/src/translations/cz.h.txt | 4 +- radio/src/translations/de.h.txt | 4 +- radio/src/translations/en.h | 4 +- radio/src/translations/es.h.txt | 4 +- radio/src/translations/fr.h.txt | 4 +- radio/src/translations/it.h.txt | 2 +- radio/src/translations/pl.h.txt | 4 +- radio/src/translations/pt.h.txt | 4 +- radio/src/translations/se.h.txt | 4 +- 28 files changed, 767 insertions(+), 627 deletions(-) diff --git a/companion/src/comparedialog.cpp b/companion/src/comparedialog.cpp index e24f636c4..9a50f283c 100644 --- a/companion/src/comparedialog.cpp +++ b/companion/src/comparedialog.cpp @@ -1040,8 +1040,8 @@ void compareDialog::printSwitches() str.append("

"+tr("Logical Switches")+"

"); str.append(""); for (int i=0; igetCapability(CustomSwitches); i++) { - QString sw1 = getCustomSwitchStr(&g_model1->customSw[i], *g_model1); - QString sw2 = getCustomSwitchStr(&g_model2->customSw[i], *g_model2); + QString sw1 = g_model1->customSw[i].toString(*g_model1); + QString sw2 = g_model2->customSw[i].toString(*g_model2); if (!(sw1.isEmpty() && sw2.isEmpty())) { str.append(""); color=getColor1(sw1,sw2); @@ -1095,7 +1095,7 @@ void compareDialog::printFSwitches() str.append(""); if (g_model1->funcSw[i].swtch.type) { str.append(doTC(g_model1->funcSw[i].swtch.toString(),color1)); - str.append(doTC(getFuncName(g_model1->funcSw[i].func),color1)); + str.append(doTC(g_model1->funcSw[i].funcToString(),color1)); str.append(doTC(g_model1->funcSw[i].paramToString(),color1)); int index=g_model1->funcSw[i].func; if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { @@ -1114,7 +1114,7 @@ void compareDialog::printFSwitches() str.append(doTC(tr("CF")+QString("%1").arg(i+1),"",true)); if (g_model2->funcSw[i].swtch.type) { str.append(doTC(g_model2->funcSw[i].swtch.toString(),color2)); - str.append(doTC(getFuncName(g_model2->funcSw[i].func),color2)); + str.append(doTC(g_model2->funcSw[i].funcToString(),color2)); str.append(doTC(g_model2->funcSw[i].paramToString(),color2)); int index=g_model2->funcSw[i].func; if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { diff --git a/companion/src/eepromimportexport.h b/companion/src/eepromimportexport.h index ed5ab9ff5..91eda318c 100644 --- a/companion/src/eepromimportexport.h +++ b/companion/src/eepromimportexport.h @@ -93,6 +93,17 @@ class DataField { const char *name; }; +class ProxyField: public DataField { + public: + ProxyField(): + DataField("Proxy") + { + } + + virtual DataField * getField() = 0; + +}; + template class UnsignedField: public DataField { public: @@ -273,9 +284,10 @@ class SpareBitsField: public UnsignedField { template class CharField: public DataField { public: - CharField(char *field): + CharField(char *field, bool truncate=true): DataField("Char"), - field(field) + field(field), + truncate(truncate) { } @@ -283,7 +295,7 @@ class CharField: public DataField { { output.resize(N*8); int b = 0; - int len = strlen(field); + int len = truncate ? strlen(field) : N; for (int i=0; i=len ? 0 : field[i]); for (int j=0; j<8; j++, b++) { @@ -313,6 +325,7 @@ class CharField: public DataField { protected: char * field; + bool truncate; }; int8_t char2idx(char c); diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index cf5b22675..cd6843d5a 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -280,45 +280,8 @@ QString RawSwitch::toString() return CHECK_IN_ARRAY(multiposPots, index); case SWITCH_TYPE_ON: return QObject::tr("ON"); - case SWITCH_TYPE_ONM: - if (index==0) { - return QObject::tr("ONE"); - } - else if (index==1) { - return QObject::tr("!ONE"); - } - break; - case SWITCH_TYPE_TRN: - if (index==0) { - if (IS_TARANIS(GetEepromInterface()->getBoard())) - return SwitchDn('H')+"s"; - else - return QObject::tr("TRNs"); - } else if (index==1) { - if (IS_TARANIS(GetEepromInterface()->getBoard())) - return SwitchDn('H')+"l"; - else - return QObject::tr("TRNl"); - } - break; - case SWITCH_TYPE_REA: - if (index==0) { - if (GetEepromInterface()->getBoard() == BOARD_SKY9X) - return QObject::tr("REAs"); - } else if (index==1) { - if (GetEepromInterface()->getBoard() == BOARD_SKY9X) - return QObject::tr("REAl"); - } - break; case SWITCH_TYPE_OFF: return QObject::tr("OFF"); - case SWITCH_TYPE_MOMENT_SWITCH: - if (IS_TARANIS(GetEepromInterface()->getBoard())) - return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(switchesX9D, -index-1)+QString("t"); - else - return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(switches9X, -index-1)+QString("t"); - case SWITCH_TYPE_MOMENT_VIRTUAL: - return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(virtualSwitches, -index-1)+QString("t"); default: break; } @@ -345,6 +308,170 @@ QString CurveReference::toString() } } +CSFunctionFamily CustomSwData::getFunctionFamily() +{ + if (func == CS_FN_TIMER) + return CS_FAMILY_TIMER; + else if (func == CS_FN_STICKY) + return CS_FAMILY_STICKY; + else if (func < CS_FN_AND || func > CS_FN_ELESS) + return CS_FAMILY_VOFS; + else if (func < CS_FN_EQUAL) + return CS_FAMILY_VBOOL; + else + return CS_FAMILY_VCOMP; +} + +QString CustomSwData::funcToString() +{ + switch (func) { + case CS_FN_OFF: + return QObject::tr("---"); + case CS_FN_VPOS: + return QObject::tr("a>x"); + case CS_FN_VNEG: + return QObject::tr("ax"); + case CS_FN_ANEG: + return QObject::tr("|a|b"); + case CS_FN_LESS: + return QObject::tr("a=b"); + case CS_FN_ELESS: + return QObject::tr("a<=b"); + case CS_FN_DPOS: + return QObject::tr("d>=x"); + case CS_FN_DAPOS: + return QObject::tr("|d|>=x"); + case CS_FN_VEQUAL: + return QObject::tr("a~x"); + case CS_FN_TIMER: + return QObject::tr("Timer"); + case CS_FN_STICKY: + return QObject::tr("Sticky"); + default: + return QObject::tr("Unknown"); + } +} + +QString CustomSwData::toString(const ModelData & model) +{ + QString result = ""; + + if (!func) + return result; + + if (andsw!=0) { + result +="( "; + } + switch (getFunctionFamily()) { + case CS_FAMILY_STICKY: + result = QObject::tr("STICKY(%1 , %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString()); + break; + case CS_FAMILY_TIMER: + result = QObject::tr("TIMER(%1 , %2)").arg(ValToTim(val1)).arg(ValToTim(val2)); + break; + case CS_FAMILY_VOFS: { + RawSource source = RawSource(val1, &model); + RawSourceRange range = source.getRange(); + if (val1) + result += source.toString(); + else + result += "0"; + result.remove(" "); + if (func == CS_FN_APOS || func == CS_FN_ANEG) + result = "|" + result + "|"; + else if (func == CS_FN_DAPOS) + result = "|d(" + result + ")|"; + else if (func == CS_FN_DPOS) result = "d(" + result + ")"; + if (func == CS_FN_APOS || func == CS_FN_VPOS || func == CS_FN_DAPOS || func == CS_FN_DPOS) + result += " > "; + else if (func == CS_FN_ANEG || func == CS_FN_VNEG) + result += " < "; + result += QString::number(range.step * (val2 /*TODO+ source.getRawOffset(model)*/) + range.offset); + break; + } + case CS_FAMILY_VBOOL: + result = RawSwitch(val1).toString(); + switch (func) { + case CS_FN_AND: + result += " AND "; + break; + case CS_FN_OR: + result += " OR "; + break; + case CS_FN_XOR: + result += " XOR "; + break; + default: + break; + } + result += RawSwitch(val2).toString(); + break; + + case CS_FAMILY_VCOMP: + if (val1) + result += RawSource(val1).toString(); + else + result += "0"; + switch (func) { + case CS_FN_EQUAL: + result += " = "; + break; + case CS_FN_NEQUAL: + result += " != "; + break; + case CS_FN_GREATER: + result += " > "; + break; + case CS_FN_LESS: + result += " < "; + break; + case CS_FN_EGREATER: + result += " >= "; + break; + case CS_FN_ELESS: + result += " <= "; + break; + default: + break; + } + if (val2) + result += RawSource(val2).toString(); + else + result += "0"; + break; + } + + if (andsw!=0) { + result +=" ) AND "; + result += RawSwitch(andsw).toString(); + } + + if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + if (delay) + result += QObject::tr(" Delay %1 sec").arg(delay/2.0); + if (duration) + result += QObject::tr(" Duration %1 sec").arg(duration/2.0); + } + + return result; +} + #if 0 QStringList FuncSwData::toStringList() { @@ -416,10 +543,69 @@ QStringList FuncSwData::toStringList() break; } } + + if (func==FuncPlaySound || func==FuncPlayHaptic || func==FuncPlayValue || func==FuncPlayPrompt || func==FuncPlayBoth || func==FuncBackgroundMusic) { + str.append(doTC(QString("%1").arg(g_model->funcSw[i].repeatParam),"green")); + } else { + str.append(doTC( " ","green")); + } + if ((index<=FuncInstantTrim) || (index>FuncBackgroundMusicPause)) { + str.append(doTC((g_model->funcSw[i].enabled ? "ON" : "OFF"),"green")); + } else { + str.append(doTC( "---","green")); + } + return result; } #endif +QString FuncSwData::funcToString() +{ + if (func >= FuncSafetyCh1 && func <= FuncSafetyCh32) + return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, func).toString()); + else if (func == FuncTrainer) + return QObject::tr("Trainer"); + else if (func == FuncTrainerRUD) + return QObject::tr("Trainer RUD"); + else if (func == FuncTrainerELE) + return QObject::tr("Trainer ELE"); + else if (func == FuncTrainerTHR) + return QObject::tr("Trainer THR"); + else if (func == FuncTrainerAIL) + return QObject::tr("Trainer AIL"); + else if (func == FuncInstantTrim) + return QObject::tr("Instant Trim"); + else if (func == FuncPlaySound) + return QObject::tr("Play Sound"); + else if (func == FuncPlayHaptic) + return QObject::tr("Play Haptic"); + else if (func == FuncReset) + return QObject::tr("Reset"); + else if (func == FuncVario) + return QObject::tr("Vario"); + else if (func == FuncPlayPrompt) + return QObject::tr("Play Track"); + else if (func == FuncPlayBoth) + return QObject::tr("Play Both"); + else if (func == FuncPlayValue) + return QObject::tr("Play Value"); + else if (func == FuncLogs) + return QObject::tr("Start Logs"); + else if (func == FuncVolume) + return QObject::tr("Volume"); + else if (func == FuncBacklight) + return QObject::tr("Backlight"); + else if (func == FuncBackgroundMusic) + return QObject::tr("Background Music"); + else if (func == FuncBackgroundMusicPause) + return QObject::tr("Background Music Pause"); + else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast) + return QObject::tr("Adjust GV%1").arg(func-FuncAdjustGV1+1); + else { + return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is) + } +} + QString FuncSwData::paramToString() { QStringList qs; @@ -488,6 +674,17 @@ QString FuncSwData::paramToString() return ""; } +QString FuncSwData::repeatToString() +{ + if (repeatParam==0) { + return QObject::tr("No repeat"); + } + else { + unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10; + return QObject::tr("%1 sec").arg(step*repeatParam); + } +} + GeneralSettings::GeneralSettings() { memset(this, 0, sizeof(GeneralSettings)); diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 77fe50322..9525b47d6 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -146,44 +146,6 @@ enum EnumKeys { #endif }; -enum CSFunction { - CS_FN_OFF, - CS_FN_VPOS, - CS_FN_VNEG, - CS_FN_APOS, - CS_FN_ANEG, - CS_FN_AND, - CS_FN_OR, - CS_FN_XOR, - CS_FN_EQUAL, - CS_FN_NEQUAL, - CS_FN_GREATER, - CS_FN_LESS, - CS_FN_EGREATER, - CS_FN_ELESS, - CS_FN_DPOS, - CS_FN_DAPOS, - CS_FN_VEQUAL, // added at the end to avoid everything renumbered - CS_FN_TIM, - CS_FN_MAXF -}; - -enum CSFunctionFamily { - CS_FAMILY_VOFS, - CS_FAMILY_VBOOL, - CS_FAMILY_VCOMP, - CS_FAMILY_TIMERS -}; - -inline CSFunctionFamily getCSFunctionFamily(int fn) -{ - if (fn==CS_FN_TIM) { - return (CS_FAMILY_TIMERS); - } else { - return ((fnCS_FN_ELESS) ? CS_FAMILY_VOFS : (fnfunc = func; + } unsigned int func; + int val1; + int val2; unsigned int delay; unsigned int duration; unsigned int andsw; void clear() { memset(this, 0, sizeof(CustomSwData)); } + CSFunctionFamily getFunctionFamily(); + QString funcToString(); + QString toString(const ModelData & model); }; enum AssignFunc { @@ -656,7 +651,7 @@ enum AssignFunc { class FuncSwData { // Function Switches data public: - FuncSwData() { clear(); } + FuncSwData(AssignFunc func=FuncSafetyCh1) { clear(); this->func = func; } RawSwitch swtch; AssignFunc func; int param; @@ -665,7 +660,9 @@ class FuncSwData { // Function Switches data unsigned int adjustMode; int repeatParam; void clear() { memset(this, 0, sizeof(FuncSwData)); } + QString funcToString(); QString paramToString(); + QString repeatToString(); QStringList toStringList(); }; @@ -807,12 +804,9 @@ enum TimerMode { TMRMODE_THp, TMRMODE_THt, TMRMODE_FIRST_SWITCH, - TMRMODE_FIRST_MOMENT_SWITCH = TMRMODE_FIRST_SWITCH+64, - TMRMODE_FIRST_CHPERC = TMRMODE_FIRST_MOMENT_SWITCH+64, - + TMRMODE_FIRST_CHPERC = TMRMODE_FIRST_SWITCH+64, TMRMODE_FIRST_NEG_SWITCH=-TMRMODE_FIRST_SWITCH, - TMRMODE_FIRST_NEG_MOMENT_SWITCH=-TMRMODE_FIRST_MOMENT_SWITCH, - /* sw/!sw, !m_sw/!m_sw */ + /* sw/!sw, !m_sw/!m_sw */ }; class TimerData { @@ -1174,7 +1168,7 @@ inline void applyStickModeToModel(ModelData &model, unsigned int mode) // virtual switches for (int i=0; i 0 ? sw-22 : sw+22); + return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-22 : sw+22); else - return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9); + return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9); } t_Er9xTrainerMix::t_Er9xTrainerMix() @@ -338,7 +338,7 @@ t_Er9xFrSkyData::operator FrSkyData () TimerMode getEr9xTimerMode(int mode) { if (mode <= -33) - return TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+33)); + return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+33)); else if (mode <= -1) return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1)); else if (mode < 16) @@ -346,7 +346,7 @@ TimerMode getEr9xTimerMode(int mode) else if (mode < 16+21) return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16)); else - return TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-16-21)); + return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16-21)); } t_Er9xModelData::operator ModelData () diff --git a/companion/src/firmwares/er9x/er9xinterface.cpp b/companion/src/firmwares/er9x/er9xinterface.cpp index 2ddb828e6..9bbf4f0b3 100644 --- a/companion/src/firmwares/er9x/er9xinterface.cpp +++ b/companion/src/firmwares/er9x/er9xinterface.cpp @@ -75,7 +75,7 @@ inline void applyStickModeToModel(Er9xModelData & model, unsigned int mode) for (int i=0; i 0 ? sw-34 : sw+34); + return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-34 : sw+34); else - return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-34-9 : sw+34+9); + return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-34-9 : sw+34+9); } t_Ersky9xTrainerMix::t_Ersky9xTrainerMix() diff --git a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp index 8405bff8f..6ee792a51 100644 --- a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp @@ -74,7 +74,7 @@ inline void applyStickModeToModel(Ersky9xModelData_v10 & model, unsigned int mod for (int i=0; i 0 ? sw-42 : sw+42); + return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-42 : sw+42); else - return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-42-9 : sw+42+9); + return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-42-9 : sw+42+9); } RawSource open9xArm208ToSource(int8_t value) @@ -126,7 +126,7 @@ t_Open9xArmTimerData_v202::operator TimerData () TimerData c9x; if (mode <= -42) - c9x.mode = TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+22)); + c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22)); else if (mode <= -1) c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1)); else if (mode < 5) @@ -134,7 +134,7 @@ t_Open9xArmTimerData_v202::operator TimerData () else if (mode < 5+41) c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5)); else - c9x.mode = TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-5-21)); + c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21)); c9x.val = val; c9x.persistent = false; diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.cpp b/companion/src/firmwares/opentx/open9xStockeeprom.cpp index 18a203700..1791d78cd 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xStockeeprom.cpp @@ -74,13 +74,13 @@ RawSwitch open9xStockToSwitch(int8_t sw) else if (sw == 22) return RawSwitch(SWITCH_TYPE_ON); else if (sw == 44) - return RawSwitch(SWITCH_TYPE_ONM); + return RawSwitch(SWITCH_TYPE_ON); else if (sw == -22) return RawSwitch(SWITCH_TYPE_OFF); else if (swa <= 22+9) - return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-22 : sw+22); + return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-22 : sw+22); else - return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9); + return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9); } t_Open9xExpoData_v201::operator ExpoData () @@ -713,7 +713,7 @@ t_Open9xTimerData_v202::operator TimerData () TimerData c9x; if (mode <= -22) - c9x.mode = TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+22)); + c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22)); else if (mode <= -1) c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1)); else if (mode < 5) @@ -721,7 +721,7 @@ t_Open9xTimerData_v202::operator TimerData () else if (mode < 5+21) c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5)); else - c9x.mode = TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-5-21)); + c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21)); c9x.val = val; c9x.persistent = false; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index f74fb1106..b0d2cab59 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -67,23 +67,20 @@ class SwitchesConversionTable: public ConversionTable { addConversion(RawSwitch(SWITCH_TYPE_OFF), -val); addConversion(RawSwitch(SWITCH_TYPE_ON), val++); - for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) { - int s = switchIndex(i, board, version); - // addConversion(RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, -s), -val); - addConversion(RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, s), val++); - } + if (version < 216) { + // previous "moment" switches + for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) { + int s = switchIndex(i, board, version); + addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val++); + } - for (int i=1; i<=MAX_CUSTOM_SWITCHES(board, version); i++) { - // addConversion(RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, -i), -val); - addConversion(RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, i), val++); - } + for (int i=1; i<=MAX_CUSTOM_SWITCHES(board, version); i++) { + addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, i), val++); + } - // addConversion(RawSwitch(SWITCH_TYPE_ONM, 1 ), -val); - addConversion(RawSwitch(SWITCH_TYPE_ONM, 0 ), val++); - addConversion(RawSwitch(SWITCH_TYPE_TRN, 0), val++); - addConversion(RawSwitch(SWITCH_TYPE_TRN, 1), val++); - addConversion(RawSwitch(SWITCH_TYPE_REA, 0), val++); - addConversion(RawSwitch(SWITCH_TYPE_REA, 1), val++); + // previous "One" switch + addConversion(RawSwitch(SWITCH_TYPE_ON), val++); + } } protected: @@ -282,9 +279,9 @@ class TimerModeConversionTable: public ConversionTable { for (int i=0; i= 216) + addConversion(CS_FN_STICKY, val++); } }; @@ -1180,40 +1179,40 @@ class CustomSwitchField: public TransformedField { virtual void beforeExport() { - v1 = csw.val1; - v2 = csw.val2; - - if ((csw.func >= CS_FN_VPOS && csw.func <= CS_FN_ANEG) || (csw.func >= CS_FN_EQUAL && csw.func!=CS_FN_TIM)) { - sourcesConversionTable->exportValue(csw.val1, v1); - } - - if (csw.func >= CS_FN_EQUAL && csw.func <= CS_FN_ELESS) { - sourcesConversionTable->exportValue(csw.val2, v2); - } - - if (csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) { + if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { switchesConversionTable->exportValue(csw.val1, v1); switchesConversionTable->exportValue(csw.val2, v2); } + else if (csw.func >= CS_FN_EQUAL && csw.func <= CS_FN_ELESS) { + sourcesConversionTable->exportValue(csw.val1, v1); + sourcesConversionTable->exportValue(csw.val2, v2); + } + else { + if ((csw.func >= CS_FN_VPOS && csw.func <= CS_FN_ANEG) || (csw.func >= CS_FN_EQUAL && csw.func!=CS_FN_TIMER)) + sourcesConversionTable->exportValue(csw.val1, v1); + else + v1 = csw.val1; + v2 = csw.val2; + } } virtual void afterImport() { - csw.val1 = v1; - csw.val2 = v2; - - if ((csw.func >= CS_FN_VPOS && csw.func <= CS_FN_ANEG) || (csw.func >= CS_FN_EQUAL && csw.func!=CS_FN_TIM)) { - sourcesConversionTable->importValue(v1, csw.val1); - } - - if (csw.func >= CS_FN_EQUAL && csw.func <= CS_FN_ELESS) { - sourcesConversionTable->importValue(v2, csw.val2); - } - - if (csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) { + if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { switchesConversionTable->importValue(v1, csw.val1); switchesConversionTable->importValue(v2, csw.val2); } + else if (csw.func >= CS_FN_EQUAL && csw.func <= CS_FN_ELESS) { + sourcesConversionTable->importValue(v1, csw.val1); + sourcesConversionTable->importValue(v2, csw.val2); + } + else { + if ((csw.func >= CS_FN_VPOS && csw.func <= CS_FN_ANEG) || (csw.func >= CS_FN_EQUAL && csw.func!=CS_FN_TIMER)) + sourcesConversionTable->importValue(v1, csw.val1); + else + csw.val1 = v1; + csw.val2 = v2; + } } protected: @@ -1361,9 +1360,9 @@ class SwitchesWarningField: public TransformedField { unsigned int version; }; -class CustomFunctionField: public TransformedField { +class ArmCustomFunctionField: public TransformedField { public: - CustomFunctionField(FuncSwData & fn, BoardEnum board, unsigned int version, unsigned int variant): + ArmCustomFunctionField(FuncSwData & fn, BoardEnum board, unsigned int version, unsigned int variant): TransformedField(internalField), internalField("CustomFunction"), fn(fn), @@ -1371,201 +1370,324 @@ class CustomFunctionField: public TransformedField { version(version), variant(variant), functionsConversionTable(board, version), - sourcesConversionTable(SourcesConversionTable::getInstance(board, version, variant, FLAG_NONONE)), - _param(0), - _delay(0), - _union_param(0) + sourcesConversionTable(SourcesConversionTable::getInstance(board, version, variant, version >= 216 ? 0 : FLAG_NONONE)), + _active(0) { - memset(_arm_param, 0, sizeof(_arm_param)); + memset(_param, 0, sizeof(_param)); internalField.Append(new SwitchField<8>(fn.swtch, board, version)); - if (IS_ARM(board)) { - internalField.Append(new ConversionField< UnsignedField<8> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); - if (IS_TARANIS(board)) - internalField.Append(new CharField<10>(_arm_param)); - else - internalField.Append(new CharField<6>(_arm_param)); - if (version >= 214) { - internalField.Append(new UnsignedField<2>(_mode)); - internalField.Append(new SignedField<6>(_delay)); - } - else { - internalField.Append(new UnsignedField<8>((unsigned int &)_delay)); - } - if (version < 214) - internalField.Append(new SpareBitsField<8>()); + internalField.Append(new ConversionField< UnsignedField<8> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); + + if (IS_TARANIS(board)) + internalField.Append(new CharField<10>(_param, false)); + else + internalField.Append(new CharField<6>(_param, false)); + + if (version >= 216) { + internalField.Append(new UnsignedField<8>(_active)); + } + else if (version >= 214) { + internalField.Append(new UnsignedField<2>(_mode)); + internalField.Append(new UnsignedField<6>(_active)); } else { - if (version >= 213) { - internalField.Append(new UnsignedField<3>(_union_param)); - internalField.Append(new ConversionField< UnsignedField<5> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); - } - else { - internalField.Append(new ConversionField< UnsignedField<7> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); - internalField.Append(new BoolField<1>((bool &)fn.enabled)); - } - internalField.Append(new UnsignedField<8>(_param)); + internalField.Append(new UnsignedField<8>((unsigned int &)_active)); + internalField.Append(new SpareBitsField<8>()); } } virtual void beforeExport() { - if (IS_ARM(board)) { - _mode = 0; - if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue) - _delay = (version >= 216 ? fn.repeatParam : (fn.repeatParam/5)); - else - _delay = (fn.enabled ? 1 : 0); - if (fn.func <= FuncInstantTrim) { - *((uint32_t *)_arm_param) = fn.param; - } - else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic) { - memcpy(_arm_param, fn.paramarm, sizeof(_arm_param)); - } - else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { - unsigned int value; - if (version >= 214) { - _mode = fn.adjustMode; - if (fn.adjustMode == 1) - sourcesConversionTable->exportValue(fn.param, (int &)value); - else if (fn.adjustMode == 2) - value = RawSource(fn.param).index; - else - value = fn.param; - } - else { - unsigned int value; - sourcesConversionTable->exportValue(fn.param, (int &)value); - } - *((uint32_t *)_arm_param) = value; - } - else if (fn.func == FuncPlayValue || fn.func == FuncVolume) { - unsigned int value; - sourcesConversionTable->exportValue(fn.param, (int &)value); - *((uint32_t *)_arm_param) = value; + _mode = 0; + + if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue) + _active = (version >= 216 ? fn.repeatParam : (fn.repeatParam/5)); + else + _active = (fn.enabled ? 1 : 0); + + if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) { + if (version >= 216) { + *((uint16_t *)_param) = fn.param; + *((uint8_t *)(_param+3)) = fn.func - FuncSafetyCh1; } else { - *((uint32_t *)_arm_param) = fn.param; + *((uint32_t *)_param) = fn.param; } } + else if (fn.func >= FuncTrainer && fn.func <= FuncTrainerAIL) { + if (version >= 216) + *((uint8_t *)(_param+3)) = fn.func - FuncTrainer; + } + else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic) { + memcpy(_param, fn.paramarm, sizeof(_param)); + } + else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { + if (version >= 216) { + *((uint8_t *)(_param+2)) = fn.adjustMode; + *((uint8_t *)(_param+3)) = fn.func - FuncAdjustGV1; + unsigned int value; + if (fn.adjustMode == 1) + sourcesConversionTable->exportValue(fn.param, (int &)value); + else if (fn.adjustMode == 2) + value = RawSource(fn.param).index; + else + value = fn.param; + *((uint16_t *)_param) = value; + } + else if (version >= 214) { + unsigned int value; + _mode = fn.adjustMode; + if (fn.adjustMode == 1) + sourcesConversionTable->exportValue(fn.param, (int &)value); + else if (fn.adjustMode == 2) + value = RawSource(fn.param).index; + else + value = fn.param; + *((uint32_t *)_param) = value; + } + else { + unsigned int value; + sourcesConversionTable->exportValue(fn.param, (int &)value); + *((uint32_t *)_param) = value; + } + } + else if (fn.func == FuncPlayValue || fn.func == FuncVolume) { + unsigned int value; + sourcesConversionTable->exportValue(fn.param, (int &)value); + if (version >= 216) + *((uint16_t *)_param) = value; + else + *((uint32_t *)_param) = value; + } else { - /* the default behavior */ - _param = fn.param; - _union_param = (fn.enabled ? 1 : 0); - if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { - if (version >= 213) { - _union_param += (fn.adjustMode << 1); - if (fn.adjustMode == 1) - sourcesConversionTable->exportValue(fn.param, (int &)_param); - else if (fn.adjustMode == 2) - _param = RawSource(fn.param).index; - } - else { - sourcesConversionTable->exportValue(fn.param, (int &)_param); - } - } - else if (fn.func == FuncPlayValue) { - if (version >= 213) { - _union_param = fn.repeatParam / 10; - sourcesConversionTable->exportValue(fn.param, (int &)_param); - } - else { - SourcesConversionTable::getInstance(board, version, variant, FLAG_NONONE|FLAG_NOSWITCHES)->exportValue(fn.param, (int &)_param); - } - } - else if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayBoth) { - if (version >= 213) - _union_param = fn.repeatParam / 10; - } - else if (fn.func <= FuncSafetyCh32) { - if (version >= 213) - _union_param += ((fn.func % 4) << 1); - } + *((uint32_t *)_param) = fn.param; } } virtual void afterImport() { - if (IS_ARM(board)) { - if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue) - fn.repeatParam = (version >= 216 ? _delay : (_delay*5)); - else - fn.enabled = (_delay & 0x01); + if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue) + fn.repeatParam = (version >= 216 ? _active : (_active*5)); + else + fn.enabled = (_active & 0x01); - unsigned int value = *((uint32_t *)_arm_param); - if (fn.func <= FuncTrainer) { - fn.param = (int)value; - } - else if (fn.func <= FuncInstantTrim) { - fn.param = value; - } - else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic) { - memcpy(fn.paramarm, _arm_param, sizeof(fn.paramarm)); - } - else if (fn.func == FuncVolume) { - sourcesConversionTable->importValue(value, (int &)fn.param); - } - else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { - if (version >= 214) { - fn.adjustMode = _mode; - if (fn.adjustMode == 1) - sourcesConversionTable->importValue(value, (int &)fn.param); - else if (fn.adjustMode == 2) - fn.param = RawSource(SOURCE_TYPE_GVAR, value).toValue(); - else - fn.param = value; - } - else { - sourcesConversionTable->importValue(value, (int &)fn.param); - } - } - else if (fn.func == FuncPlayValue) { - if (version >= 213) - sourcesConversionTable->importValue(value, (int &)fn.param); - else - SourcesConversionTable::getInstance(board, version, variant, FLAG_NONONE|FLAG_NOSWITCHES)->importValue(value, (int &)fn.param); - } - else { - fn.param = value; - } + unsigned int value=0, mode=0, index=0; + if (version >= 216) { + value = *((uint16_t *)_param); + mode = *((uint8_t *)(_param+2)); + index = *((uint8_t *)(_param+3)); } else { - fn.param = _param; - if (version >= 213) { - fn.enabled = (_union_param & 0x01); + value = *((uint32_t *)_param); + } + + if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) { + fn.func = AssignFunc(fn.func + index); + fn.param = (int)value; + } + else if (fn.func >= FuncTrainer && fn.func <= FuncTrainerAIL) { + fn.func = AssignFunc(fn.func + index); + fn.param = (int)value; + } + else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic) { + memcpy(fn.paramarm, _param, sizeof(fn.paramarm)); + } + else if (fn.func == FuncVolume) { + sourcesConversionTable->importValue(value, (int &)fn.param); + } + else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { + if (version >= 216) { + fn.func = AssignFunc(fn.func + index); + fn.adjustMode = mode; + if (fn.adjustMode == 1) + sourcesConversionTable->importValue(value, (int &)fn.param); + else if (fn.adjustMode == 2) + fn.param = RawSource(SOURCE_TYPE_GVAR, value).toValue(); + else + fn.param = value; } - if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { - if (version >= 213) { - fn.adjustMode = ((_union_param >> 1) & 0x03); - if (fn.adjustMode == 1) - sourcesConversionTable->importValue(_param, (int &)fn.param); - else if (fn.adjustMode == 2) - fn.param = RawSource(SOURCE_TYPE_GVAR, _param).toValue(); - } - else { - sourcesConversionTable->importValue(_param, (int &)fn.param); - } + else if (version >= 214) { + fn.adjustMode = _mode; + if (fn.adjustMode == 1) + sourcesConversionTable->importValue(value, (int &)fn.param); + else if (fn.adjustMode == 2) + fn.param = RawSource(SOURCE_TYPE_GVAR, value).toValue(); + else + fn.param = value; } - else if (fn.func == FuncPlayValue) { - if (version >= 213) { - fn.repeatParam = _union_param * 10; - sourcesConversionTable->importValue(_param, (int &)fn.param); - } - else { - SourcesConversionTable::getInstance(board, version, variant, FLAG_NONONE|FLAG_NOSWITCHES)->importValue(_param, (int &)fn.param); - } - } - else if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayBoth) { - if (version >= 213) - fn.repeatParam = _union_param * 10; - } - else if (fn.func <= FuncSafetyCh32) { - if (version >= 213) { - fn.func = AssignFunc(((fn.func >> 2) << 2) + ((_union_param >> 1) & 0x03)); - } - fn.param = (int8_t)fn.param; + else { + sourcesConversionTable->importValue(value, (int &)fn.param); } } + else if (fn.func == FuncPlayValue) { + if (version >= 213) + sourcesConversionTable->importValue(value, (int &)fn.param); + else + SourcesConversionTable::getInstance(board, version, variant, FLAG_NONONE|FLAG_NOSWITCHES)->importValue(value, (int &)fn.param); + } + else { + fn.param = value; + } + } + + protected: + StructField internalField; + FuncSwData & fn; + BoardEnum board; + unsigned int version; + unsigned int variant; + CustomFunctionsConversionTable functionsConversionTable; + SourcesConversionTable * sourcesConversionTable; + char _param[10]; + unsigned int _active; + unsigned int _mode; +}; + +class AvrCustomFunctionField: public TransformedField { + public: + AvrCustomFunctionField(FuncSwData & fn, BoardEnum board, unsigned int version, unsigned int variant): + TransformedField(internalField), + internalField("CustomFunction"), + fn(fn), + board(board), + version(version), + variant(variant), + functionsConversionTable(board, version), + sourcesConversionTable(SourcesConversionTable::getInstance(board, version, variant, version >= 216 ? 0 : FLAG_NONONE)), + _param(0), + _union_param(0), + _active(0) + { + if (version >= 216) { + internalField.Append(new SwitchField<6>(fn.swtch, board, version)); + internalField.Append(new ConversionField< UnsignedField<4> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); + internalField.Append(new UnsignedField<5>(_union_param)); + internalField.Append(new UnsignedField<1>(_active)); + } + if (version >= 213) { + internalField.Append(new SwitchField<8>(fn.swtch, board, version)); + internalField.Append(new UnsignedField<3>(_union_param)); + internalField.Append(new ConversionField< UnsignedField<5> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); + } + else { + internalField.Append(new SwitchField<8>(fn.swtch, board, version)); + internalField.Append(new ConversionField< UnsignedField<7> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function"))); + internalField.Append(new BoolField<1>((bool &)fn.enabled)); + } + internalField.Append(new UnsignedField<8>(_param)); + } + + virtual void beforeExport() + { + _param = fn.param; + _active = (fn.enabled ? 1 : 0); + + if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) { + if (version >= 216) + _union_param = fn.func - FuncSafetyCh1; + else if (version >= 213) + _active += ((fn.func % 4) << 1); + } + else if (fn.func >= FuncTrainer && fn.func <= FuncTrainerAIL) { + if (version >= 216) + _union_param = fn.func - FuncTrainer; + } + else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { + if (version >= 216) { + _union_param = fn.adjustMode; + _union_param += (fn.func - FuncAdjustGV1) << 2; + if (fn.adjustMode == 1) + sourcesConversionTable->exportValue(fn.param, (int &)_param); + else if (fn.adjustMode == 2) + _param = RawSource(fn.param).index; + } + else if (version >= 213) { + _active += (fn.adjustMode << 1); + if (fn.adjustMode == 1) + sourcesConversionTable->exportValue(fn.param, (int &)_param); + else if (fn.adjustMode == 2) + _param = RawSource(fn.param).index; + } + else { + sourcesConversionTable->exportValue(fn.param, (int &)_param); + } + } + else if (fn.func == FuncPlayValue) { + if (version >= 216) { + _union_param = fn.repeatParam / 10; + sourcesConversionTable->exportValue(fn.param, (int &)_param); + } + else if (version >= 213) { + _active = fn.repeatParam / 10; + sourcesConversionTable->exportValue(fn.param, (int &)_param); + } + else { + SourcesConversionTable::getInstance(board, version, variant, FLAG_NONONE|FLAG_NOSWITCHES)->exportValue(fn.param, (int &)_param); + } + } + else if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayBoth) { + if (version >= 216) { + _union_param = fn.repeatParam / 10; + } + else if (version >= 213) { + _active = fn.repeatParam / 10; + } + } + } + + virtual void afterImport() + { + fn.param = _param; + if (version >= 213) { + fn.enabled = (_active & 0x01); + } + + if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) { + if (version >= 216) + fn.func = AssignFunc(fn.func + _union_param); + else if (version >= 213) + fn.func = AssignFunc(((fn.func >> 2) << 2) + ((_active >> 1) & 0x03)); + fn.param = (int8_t)fn.param; + } + else if (fn.func >= FuncTrainer && fn.func <= FuncTrainerAIL) { + if (version >= 216) + fn.func = AssignFunc(fn.func + _union_param); + } + else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) { + if (version >= 216) { + fn.func = AssignFunc(fn.func + (_union_param >> 2)); + fn.adjustMode = (_union_param & 0x03); + } + else if (version >= 213) { + fn.adjustMode = ((_active >> 1) & 0x03); + if (fn.adjustMode == 1) + sourcesConversionTable->importValue(_param, (int &)fn.param); + else if (fn.adjustMode == 2) + fn.param = RawSource(SOURCE_TYPE_GVAR, _param).toValue(); + } + else { + sourcesConversionTable->importValue(_param, (int &)fn.param); + } + } + else if (fn.func == FuncPlayValue) { + if (version >= 216) { + fn.repeatParam = _union_param * 10; + sourcesConversionTable->importValue(_param, (int &)fn.param); + } + else if (version >= 213) { + fn.repeatParam = _active * 10; + sourcesConversionTable->importValue(_param, (int &)fn.param); + } + else { + SourcesConversionTable::getInstance(board, version, variant, FLAG_NONONE|FLAG_NOSWITCHES)->importValue(_param, (int &)fn.param); + } + } + else if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayBoth) { + if (version >= 216) + fn.repeatParam = _union_param * 10; + else if (version >= 213) + fn.repeatParam = _active * 10; + } } protected: @@ -1576,11 +1698,10 @@ class CustomFunctionField: public TransformedField { unsigned int variant; CustomFunctionsConversionTable functionsConversionTable; SourcesConversionTable * sourcesConversionTable; - char _arm_param[10]; unsigned int _param; - int _delay; unsigned int _mode; unsigned int _union_param; + unsigned int _active; }; class FrskyScreenField: public DataField { @@ -1933,8 +2054,12 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u internalField.Append(new CurvesField(modelData.curves, board, version)); for (int i=0; isetMaxVisibleItems(10); } -QString getRepeatString(unsigned int val) -{ - if (val==0) { - return QObject::tr("No repeat"); - } else { - unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10; - return QObject::tr("%1 sec").arg(step*val); - } -} - -QString getFuncName(unsigned int val) -{ - if (val < C9X_NUM_CHNOUT) { - return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, val).toString()); - } - else if (val == FuncTrainer) - return QObject::tr("Trainer"); - else if (val == FuncTrainerRUD) - return QObject::tr("Trainer RUD"); - else if (val == FuncTrainerELE) - return QObject::tr("Trainer ELE"); - else if (val == FuncTrainerTHR) - return QObject::tr("Trainer THR"); - else if (val == FuncTrainerAIL) - return QObject::tr("Trainer AIL"); - else if (val == FuncInstantTrim) - return QObject::tr("Instant Trim"); - else if (val == FuncPlaySound) - return QObject::tr("Play Sound"); - else if (val == FuncPlayHaptic) - return QObject::tr("Play Haptic"); - else if (val == FuncReset) - return QObject::tr("Reset"); - else if (val == FuncVario) - return QObject::tr("Vario"); - else if (val == FuncPlayPrompt) - return QObject::tr("Play Track"); - else if (val == FuncPlayBoth) - return QObject::tr("Play Both"); - else if (val == FuncPlayValue) - return QObject::tr("Play Value"); - else if (val == FuncLogs) - return QObject::tr("Start Logs"); - else if (val == FuncVolume) - return QObject::tr("Volume"); - else if (val == FuncBacklight) - return QObject::tr("Backlight"); - else if (val == FuncBackgroundMusic) - return QObject::tr("Background Music"); - else if (val == FuncBackgroundMusicPause) - return QObject::tr("Background Music Pause"); - else if (val >= FuncAdjustGV1 && val <= FuncAdjustGVLast) - return QObject::tr("Adjust GV%1").arg(val-FuncAdjustGV1+1); - else { - return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is) - } -} - -// TODO should be a toString() method in CustoSwData ... -QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model) -{ - QString result = ""; - - if (!customSw->func) - return result; - if (customSw->andsw!=0) { - result +="( "; - } - switch (getCSFunctionFamily(customSw->func)) { - case CS_FAMILY_TIMERS: - result = QString("TIM(%1 , %2)").arg(ValToTim(customSw->val1)).arg(ValToTim(customSw->val2)); - break; - case CS_FAMILY_VOFS: { - RawSource source = RawSource(customSw->val1, &model); - RawSourceRange range = source.getRange(); - if (customSw->val1) - result += source.toString(); - else - result += "0"; - result.remove(" "); - if (customSw->func == CS_FN_APOS || customSw->func == CS_FN_ANEG) - result = "|" + result + "|"; - else if (customSw->func == CS_FN_DAPOS) - result = "|d(" + result + ")|"; - else if (customSw->func == CS_FN_DPOS) result = "d(" + result + ")"; - if (customSw->func == CS_FN_APOS || customSw->func == CS_FN_VPOS || customSw->func == CS_FN_DAPOS || customSw->func == CS_FN_DPOS) - result += " > "; - else if (customSw->func == CS_FN_ANEG || customSw->func == CS_FN_VNEG) - result += " < "; - result += QString::number(range.step * (customSw->val2 /*TODO+ source.getRawOffset(model)*/) + range.offset); - break; - } - case CS_FAMILY_VBOOL: - result = RawSwitch(customSw->val1).toString(); - switch (customSw->func) { - case CS_FN_AND: - result += " AND "; - break; - case CS_FN_OR: - result += " OR "; - break; - case CS_FN_XOR: - result += " XOR "; - break; - default: - break; - } - result += RawSwitch(customSw->val2).toString(); - break; - - case CS_FAMILY_VCOMP: - if (customSw->val1) - result += RawSource(customSw->val1).toString(); - else - result += "0"; - switch (customSw->func) { - case CS_FN_EQUAL: - result += " = "; - break; - case CS_FN_NEQUAL: - result += " != "; - break; - case CS_FN_GREATER: - result += " > "; - break; - case CS_FN_LESS: - result += " < "; - break; - case CS_FN_EGREATER: - result += " >= "; - break; - case CS_FN_ELESS: - result += " <= "; - break; - default: - break; - } - if (customSw->val2) - result += RawSource(customSw->val2).toString(); - else - result += "0"; - break; - } - - if (customSw->andsw!=0) { - result +=" ) AND "; - result += RawSwitch(customSw->andsw).toString(); - } - - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { - if (customSw->delay) - result += QObject::tr(" Delay %1 sec").arg(customSw->delay/2.0); - if (customSw->duration) - result += QObject::tr(" Duration %1 sec").arg(customSw->duration/2.0); - } - - return result; -} - QString getProtocolStr(const int proto) { static const char *strings[] = { "OFF", @@ -567,17 +408,6 @@ QString getTimerMode(int tm) { return s; } - if (tma >= TMRMODE_FIRST_MOMENT_SWITCH && tma < TMRMODE_FIRST_MOMENT_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions)) { - s = RawSwitch(SWITCH_TYPE_SWITCH, tma - TMRMODE_FIRST_MOMENT_SWITCH + 1).toString()+"t"; - if (tm < 0) s.prepend("!"); - return s; - } - - if (tma >= TMRMODE_FIRST_MOMENT_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) && tma < TMRMODE_FIRST_MOMENT_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) + GetEepromInterface()->getCapability(CustomSwitches)) { - s = RawSwitch(SWITCH_TYPE_VIRTUAL, tma - TMRMODE_FIRST_MOMENT_SWITCH - GetEepromInterface()->getCapability(SwitchesPositions) + 1).toString()+"t"; - if (tm < 0) s.prepend("!"); - return s; - } if (tma >=TMRMODE_FIRST_CHPERC && tma 33) { - tma-=32; - } - if (tma < 10) { - s=stt.mid(abs(tma)*3, 3); - } else if (tma <19) { - s=QString("SW%1").arg(tma-9); - } else { - s=QString("SW")+QChar('A'+tma-19); - } - if (tm<0) { - s.prepend("!"); - } else if (tm>33) { - s.append("m"); - } - return s; -} - void populateBacklightCB(QComboBox *b, const uint8_t value) { QString strings[] = { QObject::tr("OFF"), QObject::tr("Keys"), QObject::tr("Sticks"), QObject::tr("Keys + Sticks"), QObject::tr("ON"), NULL }; @@ -720,15 +526,6 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, if (item == value) b->setCurrentIndex(b->count()-1); } -#if 0 - // TODO One ? - if (attr & POPULATE_ONOFF) { - item = RawSwitch(SWITCH_TYPE_ONM); - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } -#endif - b->setMaxVisibleItems(10); } @@ -878,35 +675,6 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & b->setMaxVisibleItems(10); } -#define CSWITCH_STR "---- a~x a>x ax |a|b a=b a<=b d>=x |d|>=xTIM " -#define CSW_NUM_FUNC 18 // TODO enum -#define CSW_LEN_FUNC 6 -int csw_values[]={ - CS_FN_OFF, - CS_FN_VEQUAL, // added at the end to avoid everything renumbered - CS_FN_VPOS, - CS_FN_VNEG, - CS_FN_APOS, - CS_FN_ANEG, - CS_FN_AND, - CS_FN_OR, - CS_FN_XOR, - CS_FN_EQUAL, - CS_FN_NEQUAL, - CS_FN_GREATER, - CS_FN_LESS, - CS_FN_EGREATER, - CS_FN_ELESS, - CS_FN_DPOS, - CS_FN_DAPOS, - CS_FN_TIM -}; - -QString getCSWFunc(int val) -{ - return QString(CSWITCH_STR).mid(val*CSW_LEN_FUNC, CSW_LEN_FUNC); -} - float ValToTim(int value) { return ((value < -109 ? 129+value : (value < 7 ? (113+value)*5 : (53+value)*10))/10.0); @@ -927,14 +695,37 @@ int TimToVal(float value) void populateCSWCB(QComboBox *b, int value) { + int order[] = { + CS_FN_OFF, + CS_FN_VEQUAL, // added at the end to avoid everything renumbered + CS_FN_VPOS, + CS_FN_VNEG, + CS_FN_APOS, + CS_FN_ANEG, + CS_FN_AND, + CS_FN_OR, + CS_FN_XOR, + CS_FN_EQUAL, + CS_FN_NEQUAL, + CS_FN_GREATER, + CS_FN_LESS, + CS_FN_EGREATER, + CS_FN_ELESS, + CS_FN_DPOS, + CS_FN_DAPOS, + CS_FN_TIMER, + CS_FN_STICKY + }; + b->clear(); - for (int i = 0; i < CSW_NUM_FUNC; i++) { - b->addItem(getCSWFunc(i),csw_values[i]); - if (i>GetEepromInterface()->getCapability(CSFunc)) { - QModelIndex index = b->model()->index(i, 0); - QVariant v(0); - } - if (value == csw_values[i]) { + for (int i=0; iaddItem(CustomSwData(func).funcToString(), func); +// if (i>GetEepromInterface()->getCapability(CSFunc)) { +// QModelIndex index = b->model()->index(i, 0); +// QVariant v(0); +// } + if (value == func) { b->setCurrentIndex(b->count()-1); } } @@ -1143,13 +934,6 @@ QString getPhasesStr(unsigned int phases, ModelData & model) } } -float c9xexpou(float point, float coeff) -{ - float x=point*1024.0/100.0; - float k=coeff*256.0/100.0; - return ((k*x*x*x/(1024*1024) + x*(256-k) + 128) / 256)/1024.0*100; -} - QString getCenterBeep(ModelData * g_model) { //RETA123 diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 3764a0395..d3a7bc5ec 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -87,7 +87,6 @@ void populateTrimUseCB(QComboBox *b, unsigned int phase); void populateGvarUseCB(QComboBox *b, unsigned int phase); void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto); void populateTimerSwitchCB(QComboBox *b, int value); -QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model); QString getProtocolStr(const int proto); QString getPhasesStr(unsigned int phases, ModelData & model); @@ -107,12 +106,8 @@ void populateGVCB(QComboBox *b, int value); void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags); void populateCSWCB(QComboBox *b, int value); QString getTimerMode(int tm); -QString getTimerModeB(int tm); QString getPhaseName(int val, char * phasename=NULL); QString getInputStr(ModelData & model, int index); -QString getCSWFunc(int val); -QString getFuncName(unsigned int val); -QString getRepeatString(unsigned int val); QString getSignedStr(int value); QString getGVarString(int16_t val, bool sign=false); QString image2qstring(QImage image); @@ -132,7 +127,6 @@ QString getFrSkyProtocol(int protocol); QString getFrSkyMeasure(int units); QString getFrSkySrc(int index); -float c9xexpou(float point, float coeff); float ValToTim(int value); int TimToVal(float value); diff --git a/companion/src/modeledit/curves.cpp b/companion/src/modeledit/curves.cpp index fe54f3d7d..1112b1dde 100644 --- a/companion/src/modeledit/curves.cpp +++ b/companion/src/modeledit/curves.cpp @@ -495,6 +495,13 @@ void ModelEdit::on_ca_ctype_CB_currentIndexChanged() } } +float c9xexpou(float point, float coeff) +{ + float x=point*1024.0/100.0; + float k=coeff*256.0/100.0; + return ((k*x*x*x/(1024*1024) + x*(256-k) + 128) / 256)/1024.0*100; +} + void ModelEdit::on_ca_apply_PB_clicked() { int index=ui->ca_ctype_CB->currentIndex(); diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 711ddd380..98c331f5d 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -513,7 +513,7 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value) { b->clear(); for (unsigned int i=0; iaddItem(getFuncName(i)); + b->addItem(FuncSwData(AssignFunc(i)).funcToString()); if (!GetEepromInterface()->getCapability(HasVolume)) { if (i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) { QModelIndex index = b->model()->index(i, 0); diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp index 68d3fc34f..db3f69311 100644 --- a/companion/src/modeledit/customswitches.cpp +++ b/companion/src/modeledit/customswitches.cpp @@ -78,7 +78,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): // AND cswitchAnd[i] = new QComboBox(this); cswitchAnd[i]->setProperty("index", i); - connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int))); gridLayout->addWidget(cswitchAnd[i], i+1, 4); cswitchAnd[i]->setVisible(false); @@ -91,7 +91,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): cswitchDuration[i]->setMinimum(0); cswitchDuration[i]->setAccelerated(true); cswitchDuration[i]->setDecimals(1); - connect(cswitchDuration[i],SIGNAL(editingFinished()), this, SLOT(edited())); + connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double))); gridLayout->addWidget(cswitchDuration[i], i+1, 5); cswitchDuration[i]->setVisible(false); @@ -103,7 +103,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): cswitchDelay[i]->setMinimum(0); cswitchDelay[i]->setAccelerated(true); cswitchDelay[i]->setDecimals(1); - connect(cswitchDelay[i], SIGNAL(editingFinished()), this, SLOT(edited())); + connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double))); gridLayout->addWidget(cswitchDelay[i], i+1, 6); cswitchDelay[i]->setVisible(false); } @@ -116,6 +116,27 @@ CustomSwitchesPanel::~CustomSwitchesPanel() { } +void CustomSwitchesPanel::durationEdited(double duration) +{ + int index = sender()->property("index").toInt(); + model.customSw[index].duration = (uint8_t)round(duration*2); + emit modified(); +} + +void CustomSwitchesPanel::delayEdited(double delay) +{ + int index = sender()->property("index").toInt(); + model.customSw[index].delay = (uint8_t)round(delay*2); + emit modified(); +} + +void CustomSwitchesPanel::andEdited(int value) +{ + int index = sender()->property("index").toInt(); + model.customSw[index].andsw = cswitchAnd[index]->itemData(value).toInt(); + emit modified(); +} + void CustomSwitchesPanel::edited() { if (!lock) { @@ -124,27 +145,25 @@ void CustomSwitchesPanel::edited() bool chAr; float value, step; int newval; - chAr = (getCSFunctionFamily(model.customSw[i].func) != getCSFunctionFamily(csw[i]->itemData(csw[i]->currentIndex()).toInt())); + chAr = (model.customSw[i].getFunctionFamily() != CustomSwData(csw[i]->itemData(csw[i]->currentIndex()).toInt()).getFunctionFamily()); model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt(); if(chAr) { - if (getCSFunctionFamily(model.customSw[i].func)==CS_FAMILY_TIMERS) { + if (model.customSw[i].getFunctionFamily() == CS_FAMILY_TIMER) { model.customSw[i].val1 = -119; model.customSw[i].val2 = -119; - } else { + } + else { model.customSw[i].val1 = 0; model.customSw[i].val2 = 0; } model.customSw[i].andsw = 0; setSwitchWidgetVisibility(i); } - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { - model.customSw[i].duration= (uint8_t)round(cswitchDuration[i]->value()*2); - model.customSw[i].delay= (uint8_t)round(cswitchDelay[i]->value()*2); - } + RawSource source; - switch (getCSFunctionFamily(model.customSw[i].func)) + switch (model.customSw[i].getFunctionFamily()) { - case (CS_FAMILY_VOFS): + case CS_FAMILY_VOFS: if (model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) { source = RawSource(model.customSw[i].val1, &model); model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); @@ -181,7 +200,8 @@ void CustomSwitchesPanel::edited() } } break; - case (CS_FAMILY_TIMERS): { + case CS_FAMILY_TIMER: + { value = cswitchOffset[i]->value(); newval=TimToVal(value); if (newval>model.customSw[i].val2) { @@ -194,7 +214,8 @@ void CustomSwitchesPanel::edited() } else { step=0.1; } - } else { + } + else { if (value <=2) { step=0.1; } else if (value<=60) { @@ -238,14 +259,14 @@ void CustomSwitchesPanel::edited() cswitchValue[i]->setValue(value); cswitchValue[i]->setSingleStep(step); break; - } - case (CS_FAMILY_VBOOL): - case (CS_FAMILY_VCOMP): + } + case CS_FAMILY_VBOOL: + case CS_FAMILY_VCOMP: + case CS_FAMILY_STICKY: model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt(); break; } - model.customSw[i].andsw = cswitchAnd[i]->itemData(cswitchAnd[i]->currentIndex()).toInt(); emit modified(); lock = false; } @@ -256,7 +277,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) RawSource source = RawSource(model.customSw[i].val1, &model); RawSourceRange range = source.getRange(); - switch (getCSFunctionFamily(model.customSw[i].func)) + switch (model.customSw[i].getFunctionFamily()) { case CS_FAMILY_VOFS: cswitchSource1[i]->setVisible(true); @@ -270,13 +291,15 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) cswitchOffset[i]->setMinimum(range.step*-127); cswitchOffset[i]->setMaximum(range.step*127); cswitchOffset[i]->setValue(range.step*model.customSw[i].val2); - } else { + } + else { cswitchOffset[i]->setMinimum(range.min); cswitchOffset[i]->setMaximum(range.max); cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset); } break; case CS_FAMILY_VBOOL: + case CS_FAMILY_STICKY: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(true); cswitchValue[i]->setVisible(false); @@ -292,7 +315,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); break; - case CS_FAMILY_TIMERS: + case CS_FAMILY_TIMER: cswitchSource1[i]->setVisible(false); cswitchSource2[i]->setVisible(false); cswitchValue[i]->setVisible(true); diff --git a/companion/src/modeledit/customswitches.h b/companion/src/modeledit/customswitches.h index c00ad60b6..219249aae 100644 --- a/companion/src/modeledit/customswitches.h +++ b/companion/src/modeledit/customswitches.h @@ -17,6 +17,9 @@ class CustomSwitchesPanel : public ModelPanel private slots: void edited(); + void durationEdited(double duration); + void delayEdited(double delay); + void andEdited(int value); void csw_customContextMenuRequested(QPoint pos); void cswDelete(); void cswCopy(); diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index 014def777..1b5fd285f 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -352,7 +352,7 @@ void TelemetryCustomScreen::updateBar(int line) RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model); RawSourceRange range = source.getRange(true); int max = round((range.max - range.min) / range.step); - if (255-screen.body.bars[line].barMax > max) + if (int(255-screen.body.bars[line].barMax) > max) screen.body.bars[line].barMax = 255 - max; minSB[line]->setEnabled(true); minSB[line]->setDecimals(range.decimals); diff --git a/companion/src/printdialog.cpp b/companion/src/printdialog.cpp index 5283dd614..be95c92be 100644 --- a/companion/src/printdialog.cpp +++ b/companion/src/printdialog.cpp @@ -650,7 +650,7 @@ void printDialog::printSwitches() } else { str.append(""); } - QString tstr = getCustomSwitchStr(&g_model->customSw[i], *g_model); + QString tstr = g_model->customSw[i].toString(*g_model); str.append(doTC(tstr,"green")); str.append(""); sc++; @@ -708,7 +708,7 @@ void printDialog::printFSwitches() if (g_model->funcSw[i].swtch.type!=SWITCH_TYPE_NONE) { str.append(""); str.append(doTC(g_model->funcSw[i].swtch.toString(),"green")); - str.append(doTC(getFuncName(g_model->funcSw[i].func),"green")); + str.append(doTC(g_model->funcSw[i].funcToString(),"green")); str.append(doTC(g_model->funcSw[i].paramToString(),"green")); int index=g_model->funcSw[i].func; if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 3655f1cb4..8901e27ed 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -335,9 +335,9 @@ #if defined(PCBTARANIS) #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "*1 " + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "*1 " + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW #endif #if defined(PCBSKY9X) diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index e8ac659c8..429781e15 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -335,9 +335,9 @@ #if defined(PCBTARANIS) #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "ONE" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "ONE" + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW #endif #if defined(PCBSKY9X) diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 0f7dd182e..070b76b03 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -340,9 +340,9 @@ #if defined(PCBTARANIS) #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "One" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "One" + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW #endif #if defined(PCBSKY9X) diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index d1c923ea7..952bc68fa 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -335,9 +335,9 @@ #if defined(PCBTARANIS) #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "Uno" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "ACE""DIR""ELE""ALE""GEA""TRN" TR_CUSTOMSW "Uno" + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "ACE""DIR""ELE""ALE""GEA""TRN" TR_CUSTOMSW #endif #if defined(PCBSKY9X) diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index e018ef0a5..8cf9b660f 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -335,9 +335,9 @@ #if defined(PCBTARANIS) #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "1*\0" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "1*\0" + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW #endif #if defined(PCBSKY9X) diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index fc59b9576..e767bc8f2 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -337,7 +337,7 @@ #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "1*\0" #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "One" + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW #endif #if defined(PCBSKY9X) diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 8f006b74b..58af6305d 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -335,9 +335,9 @@ #if defined(PCBTARANIS) #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS " * " + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "GAZ""SK ""LOT""SW ""GEA""TRN" TR_CUSTOMSW " * " + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "GAZ""SK ""LOT""SW ""GEA""TRN" TR_CUSTOMSW #endif #if defined(PCBSKY9X) diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 3a78386ed..1c722ed02 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -335,9 +335,9 @@ #if defined(PCBTARANIS) #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "1*\0" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "1*\0" + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW #endif #if defined(PCBSKY9X) diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 6a3b32bfc..c585a356b 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -335,9 +335,9 @@ #if defined(PCBTARANIS) #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "One" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "One" + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW #endif #if defined(PCBSKY9X) From 46fe25fd245057b4523541341393637484cd54a2 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 5 Feb 2014 22:32:54 +0100 Subject: [PATCH 09/28] Companion typos --- .../src/firmwares/opentx/opentxinterface.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index b70ef9d8a..62028c078 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -57,19 +57,19 @@ const char * Open9xInterface::getName() { switch (board) { case BOARD_STOCK: - return "openTx for 9X board"; + return "OpenTX for 9X board"; case BOARD_M128: - return "openTx for M128 / 9X board"; + return "OpenTX for M128 / 9X board"; case BOARD_GRUVIN9X: - return "openTx for Gruvin9x board / 9X"; + return "OpenTX for Gruvin9x board / 9X"; case BOARD_TARANIS: - return "openTx for FrSky Taranis"; + return "OpenTX for FrSky Taranis"; case BOARD_TARANIS_REV4a: - return "openTx for FrSky Taranis Rev4a"; + return "OpenTX for FrSky Taranis Rev4a"; case BOARD_SKY9X: - return "openTx for Sky9x board / 9X"; + return "OpenTX for Sky9x board / 9X"; default: - return "openTx for an unknown board"; + return "OpenTX for an unknown board"; } } @@ -1014,7 +1014,7 @@ void RegisterOpen9xFirmwares() Option extr_options[] = { { "frsky", QObject::tr("Support for frsky telemetry mod"), FRSKY_VARIANT }, { "jeti", QObject::tr("Support for jeti telemetry mod"), 0 }, { "ardupilot", QObject::tr("Support for receiving ardupilot data"), 0 }, { "nmea", QObject::tr("Support for receiving NMEA data"), 0 }, { "mavlink", QObject::tr("Support for MAVLINK devices"), MAVLINK_VARIANT }, { NULL } }; Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } }; /* 9x board */ - open9x = new Open9xFirmware("opentx-9x", QObject::tr("openTx for 9X board"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false); + open9x = new Open9xFirmware("opentx-9x", QObject::tr("OpenTX for 9X board"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false); open9x->addOptions(ext_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1051,7 +1051,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* 9x board with M128 chip */ - open9x = new Open9xFirmware("opentx-9x128", QObject::tr("openTx for M128 / 9X board"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); + open9x = new Open9xFirmware("opentx-9x128", QObject::tr("OpenTX for M128 / 9X board"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); open9x->addOptions(ext_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1083,7 +1083,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* 9XR board */ - open9x = new Open9xFirmware("opentx-9xr", QObject::tr("openTx for 9XR"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK),getrnurl(BOARD_STOCK), false); + open9x = new Open9xFirmware("opentx-9xr", QObject::tr("OpenTX for 9XR"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK),getrnurl(BOARD_STOCK), false); open9x->addOptions(extr_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1117,7 +1117,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* 9XR board with M128 chip */ - open9x = new Open9xFirmware("opentx-9xr128", QObject::tr("openTx for 9XR with M128 chip"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); + open9x = new Open9xFirmware("opentx-9xr128", QObject::tr("OpenTX for 9XR with M128 chip"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); open9x->addOptions(extr_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1147,7 +1147,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* Gruvin9x board */ - open9x = new Open9xFirmware("opentx-gruvin9x", QObject::tr("openTx for Gruvin9x board / 9X"), new Open9xInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false); + open9x = new Open9xFirmware("opentx-gruvin9x", QObject::tr("OpenTX for Gruvin9x board / 9X"), new Open9xInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false); open9x->setVariantBase(FRSKY_VARIANT); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1177,7 +1177,7 @@ void RegisterOpen9xFirmwares() #ifndef __APPLE__ /* SKY9X board */ - open9x = new Open9xFirmware("opentx-sky9x", QObject::tr("openTx for Sky9x board / 9X"), new Open9xInterface(BOARD_SKY9X), geturl(BOARD_SKY9X), getstamp(BOARD_SKY9X),getrnurl(BOARD_SKY9X), true); + open9x = new Open9xFirmware("opentx-sky9x", QObject::tr("OpenTX for Sky9x board / 9X"), new Open9xInterface(BOARD_SKY9X), geturl(BOARD_SKY9X), getstamp(BOARD_SKY9X),getrnurl(BOARD_SKY9X), true); open9x->setVariantBase(FRSKY_VARIANT); open9x->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1202,7 +1202,7 @@ void RegisterOpen9xFirmwares() #endif /* Taranis board */ - open9x = new Open9xFirmware("opentx-taranis", QObject::tr("openTx for FrSky Taranis"), new Open9xInterface(BOARD_TARANIS), geturl(BOARD_TARANIS), getstamp(BOARD_TARANIS),getrnurl(BOARD_TARANIS), true); + open9x = new Open9xFirmware("opentx-taranis", QObject::tr("OpenTX for FrSky Taranis"), new Open9xInterface(BOARD_TARANIS), geturl(BOARD_TARANIS), getstamp(BOARD_TARANIS),getrnurl(BOARD_TARANIS), true); open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("nogvars", QObject::tr("Disable Global variables")); @@ -1214,7 +1214,7 @@ void RegisterOpen9xFirmwares() QSettings settings; int rev4a = settings.value("rev4asupport",0).toInt(); if (rev4a) { - open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("openTx for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true); + open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("OpenTX for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true); open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("nogvars", QObject::tr("Disable Global variables")); From 4a20329b2b1509ce2d0762fc9722bec96797a33e Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 6 Feb 2014 12:45:53 +0100 Subject: [PATCH 10/28] Issue #192 - Trims and Rotary encoders buttons added to the switches list --- companion/src/eeprominterface.cpp | 6 + companion/src/eeprominterface.h | 1 + companion/src/helpers.cpp | 20 ++-- radio/src/eeprom_conversions.cpp | 11 +- radio/src/gui/menu_model.cpp | 2 +- radio/src/gui/menus.cpp | 13 ++- radio/src/gui/menus.h | 1 + radio/src/myeeprom.h | 42 +++++-- radio/src/opentx.cpp | 22 +++- radio/src/targets/gruvin9x/board_gruvin9x.cpp | 21 ++-- radio/src/targets/gruvin9x/board_gruvin9x.h | 108 ++++++++++-------- radio/src/targets/sky9x/board_sky9x.h | 4 +- radio/src/targets/sky9x/keys_driver.cpp | 4 +- radio/src/translations/en.h | 31 ++--- 14 files changed, 178 insertions(+), 108 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index cd6843d5a..be2c6d429 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -268,6 +268,10 @@ QString RawSwitch::toString() QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26") }; + static const QString rotaryEncoders[] = { + QObject::tr("REa"), QObject::tr("REb") + }; + switch(type) { case SWITCH_TYPE_SWITCH: if (IS_TARANIS(GetEepromInterface()->getBoard())) @@ -278,6 +282,8 @@ QString RawSwitch::toString() return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1) : QString("!") + CHECK_IN_ARRAY(virtualSwitches, -index-1); case SWITCH_TYPE_MULTIPOS_POT: return CHECK_IN_ARRAY(multiposPots, index); + case SWITCH_TYPE_ROTARY_ENCODER: + return CHECK_IN_ARRAY(rotaryEncoders, index); case SWITCH_TYPE_ON: return QObject::tr("ON"); case SWITCH_TYPE_OFF: diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 9525b47d6..e072a83c8 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -318,6 +318,7 @@ enum RawSwitchType { SWITCH_TYPE_SWITCH, SWITCH_TYPE_VIRTUAL, SWITCH_TYPE_MULTIPOS_POT, + SWITCH_TYPE_ROTARY_ENCODER, SWITCH_TYPE_ON, SWITCH_TYPE_OFF }; diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index c02045546..1522e44fa 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -506,18 +506,22 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, } } - for (int i=1; i<=GetEepromInterface()->getCapability(CustomSwitches); i++) { - item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); + for (int i=0; igetCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) { + item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); } - if (IS_TARANIS(GetEepromInterface()->getBoard())) { - for (int i=0; igetCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) { - item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i); - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } + for (int i=0; igetCapability(RotaryEncoders); i++) { + item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + } + + for (int i=1; i<=GetEepromInterface()->getCapability(CustomSwitches); i++) { + item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); } if (attr & POPULATE_ONOFF) { diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index f06e02e09..4bf4d38d8 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -196,15 +196,18 @@ void ConvertGeneralSettings_215_to_216(EEGeneral &settings) #if defined(PCBTARANIS) int ConvertSwitch_215_to_216(int swtch) { - if (swtch < SWSRC_ON) + if (swtch <= SWSRC_LAST_SWITCH) return swtch; else - return swtch + (2*6); // 2 * 6-pos pots added as switches + return swtch + 4 + (2*6); // 4 trims and 2 * 6-pos added as switches } #else inline int ConvertSwitch_215_to_216(int swtch) { - return swtch; + if (swtch <= SWSRC_LAST_SWITCH) + return swtch; + else + return swtch + 4 + 1; // 4 trims and REa added } #endif @@ -219,7 +222,7 @@ void ConvertModel_215_to_216(ModelData &model) // Custom Switches: better precision for x when A comes from telemetry // Main View: altitude in top bar // Mixes: GVARS in weight moved from 512 to 4096 and -512 to -4096, because GVARS may be used in limits [-1250:1250] - // Switches: two 6-pos pots added + // Switches: two 6-pos pots added, REa added to Sky9x TRACE("Model conversion from v215 to v216"); diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index cfd6474d1..7f54eb54e 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4483,7 +4483,7 @@ void menuModelCustomSwitches(uint8_t event) v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; INCDEC_SET_FLAG(INCDEC_SWITCH); - INCDEC_ENABLE_CHECK(NULL); + INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches); } else if (cstate == CS_VCOMP) { putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1); diff --git a/radio/src/gui/menus.cpp b/radio/src/gui/menus.cpp index 69916bc19..d45e91d61 100644 --- a/radio/src/gui/menus.cpp +++ b/radio/src/gui/menus.cpp @@ -1260,7 +1260,7 @@ bool isInputSourceAvailable(int16_t source) return false; } -bool isSwitchAvailable(int16_t swtch) +bool isSwitchAvailableInCustomSwitches(int16_t swtch) { if (swtch < 0) { if (swtch <= -SWSRC_ON) @@ -1286,6 +1286,15 @@ bool isSwitchAvailable(int16_t swtch) } #endif + return true; +} + +bool isSwitchAvailable(int16_t swtch) +{ + if (!isSwitchAvailableInCustomSwitches(swtch)) { + return false; + } + if (swtch >= SWSRC_FIRST_CSW && swtch <= SWSRC_LAST_CSW) { CustomSwData * cs = cswAddress(swtch-SWSRC_FIRST_CSW); return (cs->func != CS_OFF); @@ -1293,4 +1302,6 @@ bool isSwitchAvailable(int16_t swtch) return true; } + + #endif diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index 15080b7f2..3b4e44e59 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -191,6 +191,7 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); #if defined(CPUARM) bool isSwitchAvailable(int16_t swtch); + bool isSwitchAvailableInCustomSwitches(int16_t swtch); #define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER)) #define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \ var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH|NO_INCDEC_MARKS, isSwitchAvailable) diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index b95760e55..96dc9ffac 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -1165,6 +1165,7 @@ enum SwitchSources { SWSRC_SG2, SWSRC_SH0, SWSRC_SH2, + SWSRC_TRAINER = SWSRC_SH2, #else SWSRC_ID0 = SWSRC_FIRST_SWITCH, SWSRC_ID1, @@ -1180,11 +1181,39 @@ enum SwitchSources { SWSRC_AIL, SWSRC_GEA, SWSRC_TRN, + SWSRC_TRAINER = SWSRC_TRN, +#endif + + SWSRC_LAST_SWITCH = SWSRC_TRAINER, + +#if defined(PCBTARANIS) + SWSRC_P11, + SWSRC_P16 = SWSRC_P11+5, + SWSRC_P21, + SWSRC_P26 = SWSRC_P21+5, +#endif + +#if defined(CPUARM) + SWSRC_FIRST_TRIM, + SWSRC_TrimRudLeft = SWSRC_FIRST_TRIM, + SWSRC_TrimRudRight, + SWSRC_TrimEleDown, + SWSRC_TrimEleUp, + SWSRC_TrimThrDown, + SWSRC_TrimThrUp, + SWSRC_TrimAilLeft, + SWSRC_TrimAilRight, + SWSRC_LAST_TRIM = SWSRC_TrimAilRight, +#endif + +#if defined(PCBSKY9X) + SWSRC_REa, +#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) + SWSRC_REa, + SWSRC_REb, #endif SWSRC_FIRST_CSW, - SWSRC_LAST_SWITCH = SWSRC_FIRST_CSW-1, - SWSRC_SW1 = SWSRC_FIRST_CSW, SWSRC_SW2, SWSRC_SW3, @@ -1199,18 +1228,9 @@ enum SwitchSources { SWSRC_SWC, SWSRC_LAST_CSW = SWSRC_SW1+NUM_CSW-1, -#if defined(PCBTARANIS) - SWSRC_P11, - SWSRC_P16 = SWSRC_P11+5, - SWSRC_P21, - SWSRC_P26 = SWSRC_P21+5, -#endif - SWSRC_ON, SWSRC_OFF = -SWSRC_ON, - SWSRC_TRAINER = SWSRC_SW1-1, - SWSRC_FIRST = SWSRC_OFF, SWSRC_LAST = SWSRC_ON }; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 7d5514e2d..f48586a20 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1386,9 +1386,24 @@ bool getSwitch(int8_t swtch) result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH); } #if defined(PCBTARANIS) - else if (cs_idx >= SWSRC_P11 && cs_idx <= SWSRC_P26) { + else if (cs_idx <= SWSRC_P26) { result = POT_POSITION(cs_idx-SWSRC_P11); } +#endif +#if defined(CPUARM) + else if (cs_idx <= SWSRC_LAST_TRIM) { + result = readTrims() & (1 << (cs_idx-SWSRC_FIRST_TRIM)); + } +#endif +#if ROTARY_ENCODERS > 0 + else if (cs_idx == SWSRC_REa) { + result = REA_DOWN(); + } +#endif +#if ROTARY_ENCODERS > 1 + else if (cs_idx == SWSRC_REb) { + result = REB_DOWN(); + } #endif else { cs_idx -= SWSRC_FIRST_CSW; @@ -3072,8 +3087,9 @@ void evalFunctions() } #if defined(GVARS) - for (uint8_t i=0; i> 3; - for (int i=1; i<7; i++) - { + for (int i=1; i<7; i++) { //INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6 - keys[enuk].input(in & (1< 0 - #define rotencDown() (!(PIOB->PIO_PDSR & 0x40)) + #define REA_DOWN() (!(PIOB->PIO_PDSR & 0x40)) #else - #define rotencDown() 0 + #define REA_DOWN() (0) #endif // Debug driver diff --git a/radio/src/targets/sky9x/keys_driver.cpp b/radio/src/targets/sky9x/keys_driver.cpp index 604db4f8b..43e9ada11 100644 --- a/radio/src/targets/sky9x/keys_driver.cpp +++ b/radio/src/targets/sky9x/keys_driver.cpp @@ -115,7 +115,7 @@ uint32_t readTrims() uint8_t keyDown() { - return (~readKeys() & 0x7E) || rotencDown(); + return (~readKeys() & 0x7E) || REA_DOWN(); } void readKeysAndTrims() @@ -123,7 +123,7 @@ void readKeysAndTrims() register uint32_t i; #if ROTARY_ENCODERS > 0 - keys[BTN_REa].input(rotencDown(), BTN_REa); + keys[BTN_REa].input(REA_DOWN(), BTN_REa); #endif uint8_t enuk = KEY_MENU; diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 070b76b03..0676113ea 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -338,21 +338,26 @@ #define TR_CUSTOMSW "CS1""CS2""CS3""CS4""CS5""CS6""CS7""CS8""CS9""CSA""CSB""CSC" #endif -#if defined(PCBTARANIS) - #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS -#else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW -#endif +#define TR_TRIMS_SWITCHES "tRl""tRr""tEd""tEu""tTd""tTu""tAl""tAr" #if defined(PCBSKY9X) - #define TR_ROTARY_ENCODERS_VSRCRAW "REnc" -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " + #define TR_ROTARY_ENCODERS "REa\0" + #define TR_ROTENC_SWITCHES "REa" +#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) + #define TR_ROTARY_ENCODERS "REa\0""REb\0" + #define TR_ROTENC_SWITCHES "REa""REb" #else - #define TR_ROTARY_ENCODERS_VSRCRAW + #define TR_ROTARY_ENCODERS + #define TR_ROTENC_SWITCHES +#endif + +#if defined(PCBTARANIS) + #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#elif defined(CPUARM) + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#else + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_ROTENC_SWITCHES TR_CUSTOMSW #endif #if defined(HELI) @@ -361,7 +366,7 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif -#define TR_VSRCRAW "---\0""Rud\0""Ele\0""Thr\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX\0" TR_CYC_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" TR_SW_VSRCRAW +#define TR_VSRCRAW "---\0""Rud\0""Ele\0""Thr\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" TR_SW_VSRCRAW #define LEN_VTMRMODES "\003" #define TR_VTMRMODES "OFF""ABS""THs""TH%""THt" From cae4d1ecf6c9f327e1681454d82300b74e795a6b Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 6 Feb 2014 14:36:54 +0100 Subject: [PATCH 11/28] Issue #592 - All boards will have this feature available, it costs only 50bytes on stock board (I saved more in this same branch) --- radio/src/eeprom_conversions.cpp | 4 +- radio/src/gui/menu_model.cpp | 6 +- radio/src/myeeprom.h | 2 - radio/src/opentx.cpp | 4 +- radio/src/opentx.h | 1 + radio/src/targets/gruvin9x/board_gruvin9x.cpp | 58 ++++++++----------- radio/src/targets/sky9x/keys_driver.cpp | 5 ++ radio/src/targets/stock/board_stock.cpp | 45 +++++++------- radio/src/targets/taranis/keys_driver.cpp | 5 ++ radio/src/translations/en.h | 4 +- 10 files changed, 67 insertions(+), 67 deletions(-) diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index 4bf4d38d8..58c07b74f 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -199,7 +199,7 @@ int ConvertSwitch_215_to_216(int swtch) if (swtch <= SWSRC_LAST_SWITCH) return swtch; else - return swtch + 4 + (2*6); // 4 trims and 2 * 6-pos added as switches + return swtch + (2*4) + (2*6); // 4 trims and 2 * 6-pos added as switches } #else inline int ConvertSwitch_215_to_216(int swtch) @@ -207,7 +207,7 @@ inline int ConvertSwitch_215_to_216(int swtch) if (swtch <= SWSRC_LAST_SWITCH) return swtch; else - return swtch + 4 + 1; // 4 trims and REa added + return swtch + (2*4) + 1; // 4 trims and REa added } #endif diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 7f54eb54e..41ad48820 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4233,7 +4233,7 @@ void menuModelCustomSwitchOne(uint8_t event) { lcd_putsLeft(y, STR_V1); int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM; - if (cstate == CS_VBOOL) { + if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; } @@ -4253,7 +4253,7 @@ void menuModelCustomSwitchOne(uint8_t event) { lcd_putsLeft(y, STR_V2); int8_t v2_min=0, v2_max=MIXSRC_LAST_TELEM; - if (cstate == CS_VBOOL) { + if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr); v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; } @@ -4358,7 +4358,7 @@ void menuModelCustomSwitches(uint8_t event) // CSW params uint8_t cstate = cswFamily(cs->func); - if (cstate == CS_VBOOL) { + if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, 0); } diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 96dc9ffac..f4fbf7aa3 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -1193,7 +1193,6 @@ enum SwitchSources { SWSRC_P26 = SWSRC_P21+5, #endif -#if defined(CPUARM) SWSRC_FIRST_TRIM, SWSRC_TrimRudLeft = SWSRC_FIRST_TRIM, SWSRC_TrimRudRight, @@ -1204,7 +1203,6 @@ enum SwitchSources { SWSRC_TrimAilLeft, SWSRC_TrimAilRight, SWSRC_LAST_TRIM = SWSRC_TrimAilRight, -#endif #if defined(PCBSKY9X) SWSRC_REa, diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index f48586a20..cd04b387c 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1390,11 +1390,9 @@ bool getSwitch(int8_t swtch) result = POT_POSITION(cs_idx-SWSRC_P11); } #endif -#if defined(CPUARM) else if (cs_idx <= SWSRC_LAST_TRIM) { - result = readTrims() & (1 << (cs_idx-SWSRC_FIRST_TRIM)); + result = trimDown(cs_idx-SWSRC_FIRST_TRIM); } -#endif #if ROTARY_ENCODERS > 0 else if (cs_idx == SWSRC_REa) { result = REA_DOWN(); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index c243ae139..70116bbaa 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -806,6 +806,7 @@ enum PowerState { }; bool switchState(EnumKeys enuk); +uint8_t trimDown(uint8_t idx); void readKeysAndTrims(); uint16_t evalChkSum(); diff --git a/radio/src/targets/gruvin9x/board_gruvin9x.cpp b/radio/src/targets/gruvin9x/board_gruvin9x.cpp index adb5c4974..97ac9a5d9 100644 --- a/radio/src/targets/gruvin9x/board_gruvin9x.cpp +++ b/radio/src/targets/gruvin9x/board_gruvin9x.cpp @@ -255,58 +255,50 @@ bool switchState(EnumKeys enuk) return result; } +static const pm_uchar crossTrim[] PROGMEM = { + 1<> 3; - for (int i=1; i<7; i++) { - //INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6 + // INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6 keys[enuk].input(in & (1< Date: Thu, 6 Feb 2014 15:57:59 +0100 Subject: [PATCH 12/28] Issue #592 - 422bytes saved on 9x stock!!! --- companion/src/eeprominterface.cpp | 56 ++++++++++++++-------- companion/src/eeprominterface.h | 1 + companion/src/helpers.cpp | 78 +++++++++++++++++++++---------- companion/src/helpers.h | 2 +- radio/src/gui/menu_model.cpp | 12 +++-- radio/src/gui/menus.cpp | 14 +----- radio/src/gui/view_main.cpp | 8 ++-- radio/src/lcd.cpp | 21 +++------ radio/src/lcd.h | 3 +- radio/src/myeeprom.h | 2 +- radio/src/opentx.cpp | 27 ++++------- radio/src/opentx.h | 3 -- 12 files changed, 121 insertions(+), 106 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index be2c6d429..54a94fda7 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -268,31 +268,47 @@ QString RawSwitch::toString() QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26") }; + static const QString trimsSwitches[] = { + QObject::tr("RudTrim Left"), QObject::tr("RudTrim Right"), + QObject::tr("EleTrim Down"), QObject::tr("EleTrim Up"), + QObject::tr("ThrTrim Down"), QObject::tr("ThrTrim Up"), + QObject::tr("AilTrim Left"), QObject::tr("AilTrim Right") + }; + static const QString rotaryEncoders[] = { QObject::tr("REa"), QObject::tr("REb") }; - switch(type) { - case SWITCH_TYPE_SWITCH: - if (IS_TARANIS(GetEepromInterface()->getBoard())) - return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1) : QString("!") + CHECK_IN_ARRAY(switchesX9D, -index-1); - else - return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1) : QString("!") + CHECK_IN_ARRAY(switches9X, -index-1); - case SWITCH_TYPE_VIRTUAL: - return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1) : QString("!") + CHECK_IN_ARRAY(virtualSwitches, -index-1); - case SWITCH_TYPE_MULTIPOS_POT: - return CHECK_IN_ARRAY(multiposPots, index); - case SWITCH_TYPE_ROTARY_ENCODER: - return CHECK_IN_ARRAY(rotaryEncoders, index); - case SWITCH_TYPE_ON: - return QObject::tr("ON"); - case SWITCH_TYPE_OFF: - return QObject::tr("OFF"); - default: - break; + if (index == 0) { + return QObject::tr("----"); + } + else if (index < 0) { + return QString("!") + RawSwitch(type, -index).toString(); + } + else { + index = index - 1; + switch(type) { + case SWITCH_TYPE_SWITCH: + if (IS_TARANIS(GetEepromInterface()->getBoard())) + return CHECK_IN_ARRAY(switchesX9D, index); + else + return CHECK_IN_ARRAY(switches9X, index); + case SWITCH_TYPE_VIRTUAL: + return CHECK_IN_ARRAY(virtualSwitches, index); + case SWITCH_TYPE_MULTIPOS_POT: + return CHECK_IN_ARRAY(multiposPots, index); + case SWITCH_TYPE_TRIM: + return CHECK_IN_ARRAY(trimsSwitches, index); + case SWITCH_TYPE_ROTARY_ENCODER: + return CHECK_IN_ARRAY(rotaryEncoders, index); + case SWITCH_TYPE_ON: + return QObject::tr("ON"); + case SWITCH_TYPE_OFF: + return QObject::tr("OFF"); + default: + break; + } } - - return QObject::tr("----"); } QString CurveReference::toString() diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index e072a83c8..393c3e306 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -318,6 +318,7 @@ enum RawSwitchType { SWITCH_TYPE_SWITCH, SWITCH_TYPE_VIRTUAL, SWITCH_TYPE_MULTIPOS_POT, + SWITCH_TYPE_TRIM, SWITCH_TYPE_ROTARY_ENCODER, SWITCH_TYPE_ON, SWITCH_TYPE_OFF diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 1522e44fa..9f3359946 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -427,46 +427,52 @@ void populateBacklightCB(QComboBox *b, const uint8_t value) } } -void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context) +void populateAndSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context) { RawSwitch item; b->clear(); - if (attr & POPULATE_AND_SWITCHES) { - if (GetEepromInterface()->getCapability(HasNegAndSwitches)) { - for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) { - item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } - for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<=-1; i++) { - item = RawSwitch(SWITCH_TYPE_SWITCH, i); - if (GetEepromInterface()->isAvailable(item, context)) { - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } - } - } - item = RawSwitch(SWITCH_TYPE_NONE); - if (GetEepromInterface()->isAvailable(item, context)) { + if (GetEepromInterface()->getCapability(HasNegAndSwitches)) { + for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) { + item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); } - for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) { + for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<=-1; i++) { item = RawSwitch(SWITCH_TYPE_SWITCH, i); if (GetEepromInterface()->isAvailable(item, context)) { b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); } } - for (int i=1; i<=GetEepromInterface()->getCapability(CustomAndSwitches); i++) { - item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); + } + + item = RawSwitch(SWITCH_TYPE_NONE); + + if (GetEepromInterface()->isAvailable(item, context)) { + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + } + for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) { + item = RawSwitch(SWITCH_TYPE_SWITCH, i); + if (GetEepromInterface()->isAvailable(item, context)) { b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); } - return; } + for (int i=1; i<=GetEepromInterface()->getCapability(CustomAndSwitches); i++) { + item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + } +} + +void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context) +{ + RawSwitch item; + + b->clear(); if (attr & POPULATE_ONOFF) { item = RawSwitch(SWITCH_TYPE_OFF); @@ -484,6 +490,24 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, } } + for (int i=-GetEepromInterface()->getCapability(RotaryEncoders); i<0; i++) { + item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + } + + for (int i=-8; i<0; i++) { + item = RawSwitch(SWITCH_TYPE_TRIM, i); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + } + + for (int i=-GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i<0; i++) { + item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + } + for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) { item = RawSwitch(SWITCH_TYPE_SWITCH, i); if (GetEepromInterface()->isAvailable(item, context)) { @@ -506,13 +530,19 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, } } - for (int i=0; igetCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) { + for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) { item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); } - for (int i=0; igetCapability(RotaryEncoders); i++) { + for (int i=1; i<=8; i++) { + item = RawSwitch(SWITCH_TYPE_TRIM, i); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + } + + for (int i=1; i<=GetEepromInterface()->getCapability(RotaryEncoders); i++) { item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); diff --git a/companion/src/helpers.h b/companion/src/helpers.h index d3a7bc5ec..d8f5d4a73 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -80,7 +80,7 @@ class CurveGroup : public QObject { }; #define POPULATE_ONOFF 0x01 -#define POPULATE_AND_SWITCHES 0x02 +void populateAndSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext); void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext); void populatePhasesCB(QComboBox *b, int value); void populateTrimUseCB(QComboBox *b, unsigned int phase); diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 41ad48820..b47201ac7 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -1051,7 +1051,7 @@ void menuModelSetup(uint8_t event) } else { putsStrIdx(0*FW, y, STR_TIMER, k>=ITEM_MODEL_TIMER2 ? 2 : 1); - putsTmrMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, m_posHorz==0 ? attr : 0); + putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, m_posHorz==0 ? attr : 0); putsTime(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, m_posHorz==1 ? attr : 0, m_posHorz==2 ? attr : 0); #if defined(PCBTARANIS) if (attr && m_posHorz < 0) lcd_filled_rect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); @@ -1060,7 +1060,7 @@ void menuModelSetup(uint8_t event) div_t qr = div(timer->start, 60); switch (m_posHorz) { case 0: - CHECK_INCDEC_MODELVAR(event, timer->mode, -2*(NUM_PSWITCH+NUM_CSW), TMR_VAROFS-1+2*(NUM_PSWITCH+NUM_CSW)); + CHECK_INCDEC_MODELVAR(event, timer->mode, SWSRC_FIRST, TMR_VAROFS+SWSRC_LAST-1/*--- which is OFF*/); break; case 1: CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59); @@ -1840,7 +1840,7 @@ void menuModelFlightModesAll(uint8_t event) } else { putsSwitches((5+LEN_FP_NAME)*FW+FW/2, y, p->swtch, attr); - if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, -NUM_SWITCH, NUM_SWITCH); + if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, SWSRC_FIRST, SWSRC_LAST); } break; @@ -4298,7 +4298,7 @@ void menuModelCustomSwitchOne(uint8_t event) case CSW_FIELD_ANDSW: lcd_putsLeft(y, STR_AND_SWITCH); putsSwitches(CSWONE_2ND_COLUMN, y, cs->andsw, attr); - if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -NUM_SWITCH, NUM_SWITCH); + if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW); break; case CSW_FIELD_DURATION: lcd_putsLeft(y, STR_DURATION); @@ -4596,7 +4596,9 @@ void menuModelCustomSwitches(uint8_t event) break; case CSW_FIELD_ANDSW: #if defined(CPUARM) - CHECK_INCDEC_MODELSWITCH(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW); + INCDEC_SET_FLAG(INCDEC_SWITCH); + INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches); + cs->andsw = CHECK_INCDEC_PARAM(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW); #else CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_CSW_ANDSW); #endif diff --git a/radio/src/gui/menus.cpp b/radio/src/gui/menus.cpp index d45e91d61..455ac0a57 100644 --- a/radio/src/gui/menus.cpp +++ b/radio/src/gui/menus.cpp @@ -228,18 +228,6 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui #endif } } - - if (event == EVT_KEY_LONG(KEY_ENTER) && i_max > SWSRC_ON) { - s_editMode = !s_editMode; - if (newval > SWSRC_ON) - newval -= (NUM_SWITCH+1); - else if (newval > 0) - newval += (NUM_SWITCH+1); - else if (newval < SWSRC_OFF) - newval += (NUM_SWITCH+1); - else if (newval < 0) - newval -= (NUM_SWITCH+1); - } } #endif @@ -976,7 +964,7 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t { lcd_putsColumnLeft(x, y, STR_SWITCH); putsSwitches(x, y, value, attr); - if (attr) CHECK_INCDEC_MODELSWITCH(event, value, -NUM_SWITCH, NUM_SWITCH); + if (attr) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST, SWSRC_LAST); return value; } diff --git a/radio/src/gui/view_main.cpp b/radio/src/gui/view_main.cpp index d618414ec..a0ba1fbe8 100644 --- a/radio/src/gui/view_main.cpp +++ b/radio/src/gui/view_main.cpp @@ -343,7 +343,7 @@ void displayTimers() if (g_model.timers[0].mode) { TimerState & timerState = timersStates[0]; putsTime(TIMERS_X, TIMER1_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT); - putsTmrMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, STRCONDENSED|SMLSIZE); + putsTimerMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, SMLSIZE); if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE); if (timerState.val < 0) { if (BLINK_ON_PHASE) { @@ -356,7 +356,7 @@ void displayTimers() if (g_model.timers[1].mode) { TimerState & timerState = timersStates[1]; putsTime(TIMERS_X, TIMER2_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT); - putsTmrMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, STRCONDENSED|SMLSIZE); + putsTimerMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, SMLSIZE); if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE); if (timerState.val < 0) { if (BLINK_ON_PHASE) { @@ -373,7 +373,7 @@ void displayTimers() TimerState & timerState = timersStates[0]; uint8_t att = DBLSIZE | (timerState.val<0 ? BLINK|INVERS : 0); putsTime(12*FW+2+10*FWNUM-4, FH*2, timerState.val, att, att); - putsTmrMode(timerState.val >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode, STRCONDENSED); + putsTimerMode(timerState.val >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode); } } #endif @@ -818,7 +818,7 @@ void menuMainView(uint8_t event) } else { // timer2 putsTime(33+FW+2+10*FWNUM-4, FH*5, timersStates[1].val, DBLSIZE, DBLSIZE); - putsTmrMode(timersStates[1].val >= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode, STRCONDENSED); + putsTimerMode(timersStates[1].val >= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode); // lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s } #endif // PCBTARANIS diff --git a/radio/src/lcd.cpp b/radio/src/lcd.cpp index d1724b6d7..ac2507381 100644 --- a/radio/src/lcd.cpp +++ b/radio/src/lcd.cpp @@ -1106,22 +1106,15 @@ void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) } #endif -void putsTmrMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att) +void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att) { - if (mode < 0) { - mode = TMR_VAROFS - mode - 1; - lcd_putcAtt(x-1*FW, y, '!', att); + if (mode >= 0) { + if (mode < TMR_VAROFS) + return lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att); + else + mode -= (TMR_VAROFS-1); } - else if (mode < TMR_VAROFS) { - lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att); - return; - } - - if (mode >= TMR_VAROFS+NUM_PSWITCH+NUM_CSW) { - mode++; - } - - putsSwitches(x, y, mode-(TMR_VAROFS-1), att); + putsSwitches(x, y, mode, att); } void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att) diff --git a/radio/src/lcd.h b/radio/src/lcd.h index 223901be7..5becc5c57 100644 --- a/radio/src/lcd.h +++ b/radio/src/lcd.h @@ -83,7 +83,6 @@ /* no 0x80 here because of "GV"1 which is aligned LEFT */ /* no 0x10 here because of "MODEL"01 which uses LEADING0 */ #define BSS 0x20 -#define STRCONDENSED 0x80 /* means that THRm will be displayed as THR */ #define ZCHAR 0x80 /* lcd outdez flags */ @@ -174,7 +173,7 @@ void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att); #endif void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); -void putsTmrMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att); +void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att=0); void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); #if defined(ROTARY_ENCODERS) void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index f4fbf7aa3..7fd0183d8 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -671,7 +671,7 @@ PACK( union u_int8int16_t { #if defined(CPUARM) #define MAX_CSW_DURATION 120 /*60s*/ #define MAX_CSW_DELAY 120 /*60s*/ -#define MAX_CSW_ANDSW NUM_SWITCH +#define MAX_CSW_ANDSW SWSRC_LAST typedef int16_t csw_telemetry_value_t; PACK(typedef struct t_CustomSwData { // Custom Switches data int16_t v1; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index cd04b387c..87d3d1f55 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -3885,34 +3885,25 @@ void doMixerCalculations() timerState->sum = 0; } - uint8_t atm = (tm >= 0 ? tm : TMR_VAROFS-tm-1); - // value for time described in timer->mode // OFFABSTHsTH%THt - if (atm == TMRMODE_THR_REL) { + if (tm == TMRMODE_THR_REL) { timerState->cnt++; timerState->sum+=val; } - if (atm>=(TMR_VAROFS+NUM_SWITCH)){ // toggeled switch - if(!(timerState->toggled | timerState->sum | timerState->cnt | timerState->lastPos)) { timerState->lastPos = tm < 0; timerState->sum = 1; } // if initializing then init the lastPos - uint8_t swPos = getSwitch(tm>0 ? tm-(TMR_VAROFS+NUM_SWITCH-1) : tm+NUM_SWITCH); - if (swPos && !timerState->lastPos) timerState->toggled = !timerState->toggled; // if switch is flipped first time -> change counter state - timerState->lastPos = swPos; - } - if ((timerState->val_10ms += tick10ms) >= 100) { timerState->val_10ms -= 100 ; int16_t newTimerVal = timerState->val; if (tv) newTimerVal = tv - newTimerVal; - if (atm==TMRMODE_ABS) { + if (tm == TMRMODE_ABS) { newTimerVal++; } - else if (atm==TMRMODE_THR) { + else if (tm == TMRMODE_THR) { if (val) newTimerVal++; } - else if (atm==TMRMODE_THR_REL) { + else if (tm == TMRMODE_THR_REL) { // @@@ open.20.fsguruh: why so complicated? we have already a s_sum field; use it for the half seconds (not showable) as well // check for s_cnt[i]==0 is not needed because we are shure it is at least 1 #if defined(ACCURAT_THROTTLE_TIMER) @@ -3928,19 +3919,17 @@ void doMixerCalculations() #endif timerState->cnt=0; } - else if (atm==TMRMODE_THR_TRG) { + else if (tm == TMRMODE_THR_TRG) { if (val || newTimerVal > 0) newTimerVal++; } else { - if (atm<(TMR_VAROFS+NUM_SWITCH)) - timerState->toggled = tm>0 ? getSwitch(tm-(TMR_VAROFS-1)) : !getSwitch(-tm); // normal switch - if (timerState->toggled) + if (tm > 0) tm -= (TMR_VAROFS-1); + if (getSwitch(tm)) newTimerVal++; } - switch(timerState->state) - { + switch (timerState->state) { case TMR_RUNNING: if (tv && newTimerVal>=(int16_t)tv) { AUDIO_TIMER_00(g_model.timers[i].countdownBeep); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 70116bbaa..765a56c2d 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -397,7 +397,6 @@ enum EnumKeys { #define NUM_PSWITCH (SWSRC_LAST_SWITCH-SWSRC_FIRST_SWITCH+1) #define NUM_POTSSW (NUM_XPOTS*6) -#define NUM_SWITCH (NUM_PSWITCH+NUM_CSW+NUM_POTSSW) #if defined(PCBTARANIS) #define KEY_RIGHT KEY_PLUS @@ -946,10 +945,8 @@ extern uint16_t s_timeCumThr; extern uint16_t s_timeCum16ThrP; struct TimerState { - uint8_t lastPos; uint16_t cnt; uint16_t sum; - uint8_t toggled; uint8_t state; int16_t val; uint8_t val_10ms; From 01242e2b7862023f98b819c3afe321f85035c93d Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 6 Feb 2014 16:23:48 +0100 Subject: [PATCH 13/28] Issue #592 - AND switch bug on 9x stock --- radio/src/gui/menu_model.cpp | 10 +++++++++- radio/src/opentx.cpp | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index b47201ac7..4e1b0a7f8 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4550,8 +4550,16 @@ void menuModelCustomSwitches(uint8_t event) #endif } - // CSW and switch + // CSW AND switch +#if defined(CPUARM) putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==3 ? attr : 0); +#else + uint8_t andsw = cs->andsw; + if (andsw > SWSRC_LAST_SWITCH) { + andsw += SWSRC_SW1-SWSRC_LAST_SWITCH-1; + } + putsSwitches(CSW_4TH_COLUMN, y, andsw, horz==3 ? attr : 0); +#endif #if defined(CPUARM) // CSW duration diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 87d3d1f55..ffa1ee96c 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1414,7 +1414,14 @@ bool getSwitch(int8_t swtch) s_last_switch_used |= mask; CustomSwData * cs = cswAddress(cs_idx); +#if defined(CPUARM) + int8_t s = cs->andsw; +#else uint8_t s = cs->andsw; + if (s > SWSRC_LAST_SWITCH) { + s += SWSRC_SW1-SWSRC_LAST_SWITCH-1; + } +#endif if (cs->func == CS_OFF || (s && !getSwitch(s))) { csLastValue[cs_idx] = CS_LAST_VALUE_INIT; result = false; From eb80d75ee18e52be34bda6fd9a504267c775f4c8 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 6 Feb 2014 22:44:11 +0100 Subject: [PATCH 14/28] Timer modes support in Companion --- companion/src/eeprominterface.cpp | 37 +++-- companion/src/eeprominterface.h | 25 +--- companion/src/firmwares/er9x/er9xeeprom.cpp | 5 +- .../src/firmwares/ersky9x/ersky9xeeprom.cpp | 8 +- .../src/firmwares/ersky9x/ersky9xeeprom.h | 3 +- .../src/firmwares/gruvin9x/gruvin9xeeprom.cpp | 2 +- .../firmwares/opentx/open9xSky9xeeprom.cpp | 4 +- .../firmwares/opentx/open9xStockeeprom.cpp | 6 +- .../src/firmwares/opentx/opentxeeprom.cpp | 139 ++++++++---------- companion/src/firmwares/th9x/th9xeeprom.cpp | 16 +- companion/src/helpers.cpp | 131 +++++------------ companion/src/helpers.h | 8 +- companion/src/modeledit/customswitches.cpp | 116 ++++++++------- companion/src/modeledit/customswitches.h | 5 +- companion/src/modeledit/setup.cpp | 12 +- 15 files changed, 225 insertions(+), 292 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 54a94fda7..f6bea20af 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -279,34 +279,39 @@ QString RawSwitch::toString() QObject::tr("REa"), QObject::tr("REb") }; - if (index == 0) { - return QObject::tr("----"); - } - else if (index < 0) { + static const QString timerModes[] = { + QObject::tr("OFF"), QObject::tr("ABS"), + QObject::tr("THs"), QObject::tr("TH%"), QObject::tr("THt") + }; + + if (index < 0) { return QString("!") + RawSwitch(type, -index).toString(); } else { - index = index - 1; switch(type) { case SWITCH_TYPE_SWITCH: if (IS_TARANIS(GetEepromInterface()->getBoard())) - return CHECK_IN_ARRAY(switchesX9D, index); + return CHECK_IN_ARRAY(switchesX9D, index-1); else - return CHECK_IN_ARRAY(switches9X, index); + return CHECK_IN_ARRAY(switches9X, index-1); case SWITCH_TYPE_VIRTUAL: - return CHECK_IN_ARRAY(virtualSwitches, index); + return CHECK_IN_ARRAY(virtualSwitches, index-1); case SWITCH_TYPE_MULTIPOS_POT: - return CHECK_IN_ARRAY(multiposPots, index); + return CHECK_IN_ARRAY(multiposPots, index-1); case SWITCH_TYPE_TRIM: - return CHECK_IN_ARRAY(trimsSwitches, index); + return CHECK_IN_ARRAY(trimsSwitches, index-1); case SWITCH_TYPE_ROTARY_ENCODER: - return CHECK_IN_ARRAY(rotaryEncoders, index); + return CHECK_IN_ARRAY(rotaryEncoders, index-1); case SWITCH_TYPE_ON: return QObject::tr("ON"); case SWITCH_TYPE_OFF: return QObject::tr("OFF"); + case SWITCH_TYPE_NONE: + return QObject::tr("----"); + case SWITCH_TYPE_TIMER_MODE: + return CHECK_IN_ARRAY(timerModes, index); default: - break; + return QObject::tr("???"); } } } @@ -859,7 +864,8 @@ void ModelData::clear() if (IS_TARANIS(board)) { moduleData[0].protocol=PXX_XJT_X16; moduleData[1].protocol=OFF; - } else { + } + else { moduleData[0].protocol=PPM; moduleData[1].protocol=OFF; } @@ -878,9 +884,10 @@ void ModelData::clear() expoData[i].clear(); for (int i=0; i off, abs, THs, TH%, THt, sw/!sw, !m_sw/!m_sw + RawSwitch mode; bool minuteBeep; unsigned int countdownBeep; bool dir; // 0=>Count Down, 1=>Count Up unsigned int val; bool persistent; int pvalue; - void clear() { memset(this, 0, sizeof(TimerData)); } + void clear() { memset(this, 0, sizeof(TimerData)); mode = RawSwitch(SWITCH_TYPE_TIMER_MODE, 0); } }; enum Protocol { @@ -1085,10 +1074,6 @@ class EEPROMInterface virtual int isAvailable(Protocol proto, int port=0) = 0; - virtual bool isAvailable(const RawSwitch & swtch, UseContext context) { return true; } - - virtual bool isAvailable(const RawSource & source, UseContext context) { return true; } - virtual SimulatorInterface * getSimulator() = 0; virtual const int getEEpromSize() = 0; diff --git a/companion/src/firmwares/er9x/er9xeeprom.cpp b/companion/src/firmwares/er9x/er9xeeprom.cpp index c095a1789..2a74458d1 100644 --- a/companion/src/firmwares/er9x/er9xeeprom.cpp +++ b/companion/src/firmwares/er9x/er9xeeprom.cpp @@ -335,8 +335,9 @@ t_Er9xFrSkyData::operator FrSkyData () return c9x; } -TimerMode getEr9xTimerMode(int mode) +RawSwitch getEr9xTimerMode(int mode) { + /* if (mode <= -33) return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+33)); else if (mode <= -1) @@ -347,6 +348,8 @@ TimerMode getEr9xTimerMode(int mode) return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16)); else return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16-21)); + */ + return RawSwitch(); } t_Er9xModelData::operator ModelData () diff --git a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp index 677607f0c..62508515e 100644 --- a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp @@ -5,14 +5,12 @@ extern RawSwitch er9xToSwitch(int8_t sw); -TimerMode getErSky9xTimerMode(int mode) +RawSwitch getErSky9xTimerMode(int mode) { if (mode<4) - return TimerMode(mode); - else if (mode < 20) - return TimerMode(TMRMODE_FIRST_CHPERC+(mode-4)); + return RawSwitch(SWITCH_TYPE_TIMER_MODE, mode); else - return TimerMode(0); + return RawSwitch(); } RawSwitch ersky9xToSwitch(int8_t sw) diff --git a/companion/src/firmwares/ersky9x/ersky9xeeprom.h b/companion/src/firmwares/ersky9x/ersky9xeeprom.h index 38e88cec3..e92a48983 100644 --- a/companion/src/firmwares/ersky9x/ersky9xeeprom.h +++ b/companion/src/firmwares/ersky9x/ersky9xeeprom.h @@ -19,8 +19,7 @@ #include #include "eeprominterface.h" -extern TimerMode getEr9xTimerMode(int mode); -extern int setEr9xTimerMode(TimerMode mode); +extern RawSwitch getEr9xTimerMode(int mode); //eeprom data #define ERSKY9X_MAX_MIXERS_V10 32 diff --git a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp index 5930dea02..41724c5e0 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp +++ b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp @@ -373,7 +373,7 @@ t_Gruvin9xPhaseData_v106::operator PhaseData () return c9x; } -extern TimerMode getEr9xTimerMode(int mode); +extern RawSwitch getEr9xTimerMode(int mode); t_Gruvin9xTimerData::operator TimerData () { diff --git a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp index b33711902..393833cc4 100644 --- a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp @@ -124,7 +124,7 @@ RawSource open9xArm210ToSource(int8_t value) t_Open9xArmTimerData_v202::operator TimerData () { TimerData c9x; - +/* if (mode <= -42) c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22)); else if (mode <= -1) @@ -135,7 +135,7 @@ t_Open9xArmTimerData_v202::operator TimerData () c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5)); else c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21)); - +*/ c9x.val = val; c9x.persistent = false; c9x.dir = (val == 0); diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.cpp b/companion/src/firmwares/opentx/open9xStockeeprom.cpp index 1791d78cd..0e6e010b6 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xStockeeprom.cpp @@ -701,7 +701,7 @@ t_Open9xPhaseData_v201::operator PhaseData () t_Open9xTimerData_v201::operator TimerData () { TimerData c9x; - c9x.mode = TMRMODE_OFF; + // c9x.mode = TMRMODE_OFF; c9x.val = val; c9x.persistent = persistent; c9x.dir = dir; @@ -711,7 +711,7 @@ t_Open9xTimerData_v201::operator TimerData () t_Open9xTimerData_v202::operator TimerData () { TimerData c9x; - +/* if (mode <= -22) c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22)); else if (mode <= -1) @@ -722,7 +722,7 @@ t_Open9xTimerData_v202::operator TimerData () c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5)); else c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21)); - +*/ c9x.val = val; c9x.persistent = false; c9x.dir = (val == 0); diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index b0d2cab59..9b7154a9d 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -42,29 +42,50 @@ class SwitchesConversionTable: public ConversionTable { SwitchesConversionTable(BoardEnum board, unsigned int version, unsigned long flags=0) { int val=0; - - addConversion(RawSwitch(SWITCH_TYPE_NONE), val++); + int offset=0; + if (flags & POPULATE_TIMER_MODES) { + offset = 4; + for (int i=0; i<5; i++) { + addConversion(RawSwitch(SWITCH_TYPE_TIMER_MODE, i), val++); + } + } + else { + addConversion(RawSwitch(SWITCH_TYPE_NONE), val++); + } for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) { int s = switchIndex(i, board, version); - addConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val); + addConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val+offset); addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val++); } - for (int i=1; i<=MAX_CUSTOM_SWITCHES(board, version); i++) { - addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, -i), -val); - addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, i), val++); - } - - if (IS_TARANIS(board) && version >= 216) { - for (int i=0; i<2; i++) { - for (int j=0; j<6; j++) { - addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i*6+j), val++); - } + if (version >= 216) { + for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) { + addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i), -val+offset); + addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i), val++); } } - addConversion(RawSwitch(SWITCH_TYPE_OFF), -val); + if (version >= 216) { + for (int i=1; i<=8; i++) { + addConversion(RawSwitch(SWITCH_TYPE_TRIM, -i), -val+offset); + addConversion(RawSwitch(SWITCH_TYPE_TRIM, i), val++); + } + } + + if (version >= 216) { + for (int i=1; i<=MAX_ROTARY_ENCODERS(board); i++) { + addConversion(RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, -i), -val+offset); + addConversion(RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i), val++); + } + } + + for (int i=1; i<=MAX_CUSTOM_SWITCHES(board, version); i++) { + addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, -i), -val+offset); + addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, i), val++); + } + + addConversion(RawSwitch(SWITCH_TYPE_OFF), -val+offset); addConversion(RawSwitch(SWITCH_TYPE_ON), val++); if (version < 216) { @@ -261,59 +282,6 @@ class SourcesConversionTable: public ConversionTable { } }; -class TimerModeConversionTable: public ConversionTable { - - public: - TimerModeConversionTable(BoardEnum board, unsigned int version, unsigned long flags=0) - { - int val=0; - - addConversion(TMRMODE_OFF, val++); - addConversion(TMRMODE_ABS, val++); - addConversion(TMRMODE_THs, val++); - addConversion(TMRMODE_THp, val++); - addConversion(TMRMODE_THt, val++); - - int swCount = MAX_SWITCHES_POSITION(board) + MAX_CUSTOM_SWITCHES(board, version); - - for (int i=0; i > { - public: - TimerModeField(TimerMode & mode, BoardEnum board, unsigned int version, unsigned long flags=0): - ConversionField< SignedField<8> >(_mode, &conversionTable, "TimerMode"), - conversionTable(board, version, flags), - mode(mode), - _mode(0) - { - } - - virtual void beforeExport() - { - _mode = mode; - ConversionField< SignedField<8> >::beforeExport(); - } - - virtual void afterImport() - { - ConversionField< SignedField<8> >::afterImport(); - mode = (TimerMode)_mode; - } - - protected: - TimerModeConversionTable conversionTable; - TimerMode & mode; - int _mode; -}; - template class SwitchField: public ConversionField< SignedField > { public: @@ -1086,10 +1054,10 @@ class CustomSwitchesFunctionsTable: public ConversionTable { } }; -class CustomSwitchesAndSwitchesConversionTable: public ConversionTable { +class AndSwitchesConversionTable: public ConversionTable { public: - CustomSwitchesAndSwitchesConversionTable(BoardEnum board, unsigned int version) + AndSwitchesConversionTable(BoardEnum board, unsigned int version) { int val=0; addConversion(RawSwitch(SWITCH_TYPE_NONE), val++); @@ -1127,6 +1095,29 @@ class CustomSwitchesAndSwitchesConversionTable: public ConversionTable { } } + static ConversionTable * getInstance(BoardEnum board, unsigned int version) + { + if (IS_ARM(board) && version >= 216) + return new SwitchesConversionTable(board, version); + else + return new AndSwitchesConversionTable(board, version); + +#if 0 + static std::list internalCache; + + for (std::list::iterator it=internalCache.begin(); it!=internalCache.end(); it++) { + Cache element = *it; + if (element.board == board && element.version == version && element.flags == flags) + return element.table; + } + + Cache element(board, version, flags, new SwitchesConversionTable(board, version, flags)); + internalCache.push_back(element); + return element.table; +#endif + } + + protected: void addConversion(const RawSwitch & sw, const int b) @@ -1147,7 +1138,7 @@ class CustomSwitchField: public TransformedField { functionsConversionTable(board, version), sourcesConversionTable(SourcesConversionTable::getInstance(board, version, variant, (version >= 214 || (!IS_ARM(board) && version >= 213)) ? 0 : FLAG_NOSWITCHES)), switchesConversionTable(SwitchesConversionTable::getInstance(board, version)), - andswitchesConversionTable(board, version) + andswitchesConversionTable(AndSwitchesConversionTable::getInstance(board, version)) { if (IS_ARM(board) && version >= 215) { internalField.Append(new SignedField<16>(v1)); @@ -1163,13 +1154,13 @@ class CustomSwitchField: public TransformedField { internalField.Append(new UnsignedField<8>(csw.delay)); internalField.Append(new UnsignedField<8>(csw.duration)); if (version >= 214) { - internalField.Append(new ConversionField< SignedField<8> >((int &)csw.andsw, &andswitchesConversionTable, "AND switch")); + internalField.Append(new ConversionField< SignedField<8> >((int &)csw.andsw, andswitchesConversionTable, "AND switch")); } } else { if (version >= 213) { internalField.Append(new ConversionField< UnsignedField<4> >(csw.func, &functionsConversionTable, "Function")); - internalField.Append(new ConversionField< UnsignedField<4> >(csw.andsw, &andswitchesConversionTable, "AND switch")); + internalField.Append(new ConversionField< UnsignedField<4> >((unsigned int &)csw.andsw, andswitchesConversionTable, "AND switch")); } else { internalField.Append(new ConversionField< UnsignedField<8> >(csw.func, &functionsConversionTable, "Function")); @@ -1224,7 +1215,7 @@ class CustomSwitchField: public TransformedField { CustomSwitchesFunctionsTable functionsConversionTable; SourcesConversionTable * sourcesConversionTable; SwitchesConversionTable * switchesConversionTable; - CustomSwitchesAndSwitchesConversionTable andswitchesConversionTable; + ConversionTable * andswitchesConversionTable; int v1; int v2; }; @@ -1977,7 +1968,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u } for (int i=0; i(modelData.timers[i].mode, board, version, POPULATE_TIMER_MODES)); if ((IS_ARM(board) || IS_2560(board)) && version >= 216) { internalField.Append(new UnsignedField<16>(modelData.timers[i].val)); internalField.Append(new UnsignedField<2>(modelData.timers[i].countdownBeep)); diff --git a/companion/src/firmwares/th9x/th9xeeprom.cpp b/companion/src/firmwares/th9x/th9xeeprom.cpp index 8df98e04b..e8cb72353 100644 --- a/companion/src/firmwares/th9x/th9xeeprom.cpp +++ b/companion/src/firmwares/th9x/th9xeeprom.cpp @@ -2,18 +2,6 @@ #include "helpers.h" #include "th9xeeprom.h" -int8_t th9xFromSwitch(const RawSwitch & sw) -{ - switch (sw.type) { - case SWITCH_TYPE_SWITCH: - return sw.index; - case SWITCH_TYPE_VIRTUAL: - return sw.index > 0 ? (9 + sw.index) : (-9 -sw.index); - default: - return 0; - } -} - RawSwitch th9xToSwitch(int8_t sw) { if (sw == 0) @@ -266,7 +254,7 @@ t_Th9xModelData::operator ModelData () ModelData c9x; c9x.used = true; getEEPROMString(c9x.name, name, sizeof(name)); - switch(tmrMode) { + /*switch(tmrMode) { case 1: c9x.timers[0].mode = TMRMODE_ABS; break; @@ -279,7 +267,7 @@ t_Th9xModelData::operator ModelData () default: c9x.timers[0].mode = TMRMODE_OFF; break; - } + }*/ // c9x.timers[0].dir = tmrDir; c9x.timers[0].val = tmrVal; /*c9x.protocol = (Protocol)protocol; diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 9f3359946..7864dc100 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -368,53 +368,6 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase) } } -void populateTimerSwitchCB(QComboBox *b, int value) -{ - b->clear(); - uint8_t count=0; - for (int i=-128; i<128; i++) { - QString timerMode = getTimerMode(i); - if (!timerMode.isEmpty()) { - b->addItem(getTimerMode(i), i); - if (i==value) - b->setCurrentIndex(b->count()-1); - count++; - } - } - b->setMaxVisibleItems(10); -} - -QString getTimerMode(int tm) { - - QString stt = "OFFABSTHsTH%THt"; - - QString s; - - if (tm >= 0 && tm <= TMRMODE_THt) { - return stt.mid(abs(tm)*3, 3); - } - - int tma = abs(tm); - - if (tma >= TMRMODE_FIRST_SWITCH && tma < TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions)) { - s = RawSwitch(SWITCH_TYPE_SWITCH, tma - TMRMODE_FIRST_SWITCH + 1).toString(); - if (tm < 0) s.prepend("!"); - return s; - } - - if (tma >= TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) && tma < TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) + GetEepromInterface()->getCapability(CustomSwitches)) { - s = RawSwitch(SWITCH_TYPE_VIRTUAL, tma - TMRMODE_FIRST_SWITCH - GetEepromInterface()->getCapability(SwitchesPositions) + 1).toString(); - if (tm < 0) s.prepend("!"); - return s; - } - - if (tma >=TMRMODE_FIRST_CHPERC && tma getBoard())) { + populateSwitchCB(b, value); + } + else { + RawSwitch item; - b->clear(); + b->clear(); - if (GetEepromInterface()->getCapability(HasNegAndSwitches)) { - for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) { + item = RawSwitch(SWITCH_TYPE_NONE); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + + for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) { + item = RawSwitch(SWITCH_TYPE_SWITCH, i); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + } + + for (int i=1; i<=6; i++) { item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); } - for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<=-1; i++) { - item = RawSwitch(SWITCH_TYPE_SWITCH, i); - if (GetEepromInterface()->isAvailable(item, context)) { - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } - } - } - - item = RawSwitch(SWITCH_TYPE_NONE); - - if (GetEepromInterface()->isAvailable(item, context)) { - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } - for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) { - item = RawSwitch(SWITCH_TYPE_SWITCH, i); - if (GetEepromInterface()->isAvailable(item, context)) { - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } - } - for (int i=1; i<=GetEepromInterface()->getCapability(CustomAndSwitches); i++) { - item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); } } -void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context) +void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr) { RawSwitch item; @@ -476,18 +416,14 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, if (attr & POPULATE_ONOFF) { item = RawSwitch(SWITCH_TYPE_OFF); - if (GetEepromInterface()->isAvailable(item, context)) { - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); } for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) { item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); - if (GetEepromInterface()->isAvailable(item, context)) { - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); } for (int i=-GetEepromInterface()->getCapability(RotaryEncoders); i<0; i++) { @@ -510,24 +446,27 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) { item = RawSwitch(SWITCH_TYPE_SWITCH, i); - if (GetEepromInterface()->isAvailable(item, context)) { + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + } + + if (attr & POPULATE_TIMER_MODES) { + for (int i=0; i<5; i++) { + item = RawSwitch(SWITCH_TYPE_TIMER_MODE, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); } } - - item = RawSwitch(SWITCH_TYPE_NONE); - if (GetEepromInterface()->isAvailable(item, context)) { + else { + item = RawSwitch(SWITCH_TYPE_NONE); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); } for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) { item = RawSwitch(SWITCH_TYPE_SWITCH, i); - if (GetEepromInterface()->isAvailable(item, context)) { - b->addItem(item.toString(), item.toValue()); - if (item == value) b->setCurrentIndex(b->count()-1); - } + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); } for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) { @@ -927,7 +866,7 @@ QString getTrimInc(ModelData * g_model) QString getTimerStr(TimerData & timer) { QString str = ", " + (timer.dir ? QObject::tr("Count Up") : QObject::tr("Count Down")); - return QObject::tr("%1:%2, ").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0')) + getTimerMode(timer.mode) + str; + return QObject::tr("%1:%2, ").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0')) + timer.mode.toString() + str; } QString getProtocol(ModelData * g_model) diff --git a/companion/src/helpers.h b/companion/src/helpers.h index d8f5d4a73..4e0ab1a35 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -80,13 +80,14 @@ class CurveGroup : public QObject { }; #define POPULATE_ONOFF 0x01 -void populateAndSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext); -void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext); +#define POPULATE_TIMER_MODES 0x02 +void populateAndSwitchCB(QComboBox *b, const RawSwitch & value); +void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0); + void populatePhasesCB(QComboBox *b, int value); void populateTrimUseCB(QComboBox *b, unsigned int phase); void populateGvarUseCB(QComboBox *b, unsigned int phase); void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto); -void populateTimerSwitchCB(QComboBox *b, int value); QString getProtocolStr(const int proto); QString getPhasesStr(unsigned int phases, ModelData & model); @@ -105,7 +106,6 @@ QString getPhasesStr(unsigned int phases, ModelData & model); void populateGVCB(QComboBox *b, int value); void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags); void populateCSWCB(QComboBox *b, int value); -QString getTimerMode(int tm); QString getPhaseName(int val, char * phasename=NULL); QString getInputStr(ModelData & model, int index); QString getSignedStr(int value); diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp index db3f69311..aea3dd602 100644 --- a/companion/src/modeledit/customswitches.cpp +++ b/companion/src/modeledit/customswitches.cpp @@ -46,7 +46,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): // V1 cswitchSource1[i] = new QComboBox(this); cswitchSource1[i]->setProperty("index",i); - connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int))); gridLayout->addWidget(cswitchSource1[i], i+1, 2); cswitchSource1[i]->setVisible(false); cswitchValue[i] = new QDoubleSpinBox(this); @@ -62,7 +62,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): // V2 cswitchSource2[i] = new QComboBox(this); cswitchSource2[i]->setProperty("index", i); - connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int))); gridLayout->addWidget(cswitchSource2[i], i+1, 3); cswitchSource2[i]->setVisible(false); cswitchOffset[i] = new QDoubleSpinBox(this); @@ -80,7 +80,6 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): cswitchAnd[i]->setProperty("index", i); connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int))); gridLayout->addWidget(cswitchAnd[i], i+1, 4); - cswitchAnd[i]->setVisible(false); if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { // Duration @@ -93,7 +92,6 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): cswitchDuration[i]->setDecimals(1); connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double))); gridLayout->addWidget(cswitchDuration[i], i+1, 5); - cswitchDuration[i]->setVisible(false); // Delay cswitchDelay[i] = new QDoubleSpinBox(this); @@ -105,7 +103,6 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): cswitchDelay[i]->setDecimals(1); connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double))); gridLayout->addWidget(cswitchDelay[i], i+1, 6); - cswitchDelay[i]->setVisible(false); } } @@ -116,6 +113,54 @@ CustomSwitchesPanel::~CustomSwitchesPanel() { } +void CustomSwitchesPanel::v1Edited(int value) +{ + if (!lock) { + int i = sender()->property("index").toInt(); + model.customSw[i].val1 = cswitchSource1[i]->itemData(value).toInt(); + if (model.customSw[i].getFunctionFamily() == CS_FAMILY_VOFS) { + RawSource source = RawSource(model.customSw[i].val1, &model); + if (source.type == SOURCE_TYPE_TELEMETRY) { + if (model.customSw[i].func > CS_FN_ELESS && model.customSw[i].func < CS_FN_VEQUAL) { + model.customSw[i].val2 = 0; + } + else { + model.customSw[i].val2 = -128; + } + } + else { + RawSourceRange range = source.getRange(); + if (model.customSw[i].func > CS_FN_ELESS && model.customSw[i].func < CS_FN_VEQUAL) { + model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step); + } + else { + model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/; + } + } + setSwitchWidgetVisibility(i); + } + emit modified(); + } +} + +void CustomSwitchesPanel::v2Edited(int value) +{ + if (!lock) { + int i = sender()->property("index").toInt(); + model.customSw[i].val2 = cswitchSource2[i]->itemData(value).toInt(); + emit modified(); + } +} + +void CustomSwitchesPanel::andEdited(int value) +{ + if (!lock) { + int index = sender()->property("index").toInt(); + model.customSw[index].andsw = cswitchAnd[index]->itemData(value).toInt(); + emit modified(); + } +} + void CustomSwitchesPanel::durationEdited(double duration) { int index = sender()->property("index").toInt(); @@ -130,13 +175,6 @@ void CustomSwitchesPanel::delayEdited(double delay) emit modified(); } -void CustomSwitchesPanel::andEdited(int value) -{ - int index = sender()->property("index").toInt(); - model.customSw[index].andsw = cswitchAnd[index]->itemData(value).toInt(); - emit modified(); -} - void CustomSwitchesPanel::edited() { if (!lock) { @@ -164,30 +202,7 @@ void CustomSwitchesPanel::edited() switch (model.customSw[i].getFunctionFamily()) { case CS_FAMILY_VOFS: - if (model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) { - source = RawSource(model.customSw[i].val1, &model); - model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); - RawSource newSource = RawSource(model.customSw[i].val1, &model); - if (newSource.type == SOURCE_TYPE_TELEMETRY) { - if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcCS_FN_ELESS && model.customSw[i].funcvalue() / range.step); - } - else { - model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/; - } - } - setSwitchWidgetVisibility(i); - } - else { + { source = RawSource(model.customSw[i].val1, &model); RawSourceRange range = source.getRange(); if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcsetSingleStep(step); break; } - case CS_FAMILY_VBOOL: - case CS_FAMILY_VCOMP: - case CS_FAMILY_STICKY: - model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); - model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt(); + default: break; } emit modified(); @@ -274,6 +285,8 @@ void CustomSwitchesPanel::edited() void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) { + lock = true; + RawSource source = RawSource(model.customSw[i].val1, &model); RawSourceRange range = source.getRange(); @@ -345,24 +358,25 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) cswitchValue[i]->setValue(value); break; } - cswitchAnd[i]->setVisible(true); - populateSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw), POPULATE_AND_SWITCHES); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { - cswitchDuration[i]->setVisible(true); - cswitchDuration[i]->setValue(model.customSw[i].duration/2.0); - cswitchDelay[i]->setVisible(true); - cswitchDelay[i]->setValue(model.customSw[i].delay/2.0); - } + + lock = false; } void CustomSwitchesPanel::update() { - lock = true; for (int i=0; igetCapability(CustomSwitches); i++) { + lock = true; populateCSWCB(csw[i], model.customSw[i].func); + lock = false; setSwitchWidgetVisibility(i); + lock = true; + populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw)); + if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + cswitchDuration[i]->setValue(model.customSw[i].duration/2.0); + cswitchDelay[i]->setValue(model.customSw[i].delay/2.0); + } + lock = false; } - lock = false; } void CustomSwitchesPanel::cswPaste() diff --git a/companion/src/modeledit/customswitches.h b/companion/src/modeledit/customswitches.h index 219249aae..f4354bcb9 100644 --- a/companion/src/modeledit/customswitches.h +++ b/companion/src/modeledit/customswitches.h @@ -17,9 +17,11 @@ class CustomSwitchesPanel : public ModelPanel private slots: void edited(); + void v1Edited(int value); + void v2Edited(int value); + void andEdited(int value); void durationEdited(double duration); void delayEdited(double delay); - void andEdited(int value); void csw_customContextMenuRequested(QPoint pos); void cswDelete(); void cswCopy(); @@ -39,6 +41,7 @@ class CustomSwitchesPanel : public ModelPanel int selectedSwitch; void updateSelectedSwitch(); + void updateV2(int index); }; diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 4d0b24efa..a3ee674a1 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -11,8 +11,10 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer): { ui->setupUi(this); + lock = true; + // Mode - populateTimerSwitchCB(ui->mode, timer.mode); + populateSwitchCB(ui->mode, timer.mode, POPULATE_TIMER_MODES); if (!GetEepromInterface()->getCapability(PermTimers)) { ui->persistent->hide(); @@ -23,6 +25,8 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer): ui->countdownBeep->addItem(tr("Beeps")); if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard())) ui->countdownBeep->addItem(tr("Countdown")); + + lock = false; } TimerPanel::~TimerPanel() @@ -63,8 +67,10 @@ void TimerPanel::on_value_editingFinished() void TimerPanel::on_mode_currentIndexChanged(int index) { - timer.mode = TimerMode(ui->mode->itemData(index).toInt()); - emit modified(); + if (!lock) { + timer.mode = RawSwitch(ui->mode->itemData(index).toInt()); + emit modified(); + } } void TimerPanel::on_persistent_toggled(bool checked) From 10064967952185ba701ebccc06164f1e796ba431 Mon Sep 17 00:00:00 2001 From: mhotar Date: Thu, 6 Feb 2014 23:58:01 +0100 Subject: [PATCH 15/28] CFN-param alignments --- radio/src/gui/menu_model.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 4e1b0a7f8..01ee2766d 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4761,20 +4761,20 @@ void menuModelCustomFunctions(uint8_t event) { int8_t maxParam = NUM_CHNOUT-1; if (func == FUNC_SAFETY_CHANNEL) { - putsChn(MODEL_CUSTOM_FUNC_2ND_COLUMN+6*FW, y, CFN_CH_NUMBER(sd)+1, attr); + putsChn(lcdNextPos, y, CFN_CH_NUMBER(sd)+1, attr); } else if (func == FUNC_TRAINER) { maxParam = 4; #if defined(CPUARM) - putsMixerSource(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, CFN_CH_NUMBER(sd)==0 ? 0 : MIXSRC_Rud+CFN_CH_NUMBER(sd)-1, attr); + putsMixerSource(lcdNextPos, y, CFN_CH_NUMBER(sd)==0 ? 0 : MIXSRC_Rud+CFN_CH_NUMBER(sd)-1, attr); #else - putsMixerSource(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, MIXSRC_Rud+CFN_CH_NUMBER(sd)-1, attr); + putsMixerSource(lcdNextPos, y, MIXSRC_Rud+CFN_CH_NUMBER(sd)-1, attr); #endif } #if defined(GVARS) else if (func == FUNC_ADJUST_GVAR) { maxParam = MAX_GVARS-1; - putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, STR_GV, CFN_GVAR_NUMBER(sd)+1, attr); + putsStrIdx(lcdNextPos, y, STR_GV, CFN_GVAR_NUMBER(sd)+1, attr); if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_GVAR_NUMBER(sd), maxParam); break; } From 86bd251f7441de3789cac4eba2f4d90b439c33f6 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 7 Feb 2014 07:34:40 +0100 Subject: [PATCH 16/28] Simulator always asked for calibration --- .../src/firmwares/opentx/opentxeeprom.cpp | 22 +++++++++++++++---- companion/src/firmwares/opentx/opentxeeprom.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 9b7154a9d..60996f68f 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2167,6 +2167,7 @@ Open9xGeneralDataNew::Open9xGeneralDataNew(GeneralSettings & generalData, BoardE internalField("General Settings"), generalData(generalData), board(board), + version(version), inputsCount(IS_TARANIS(board) ? 8 : 7) { generalData.version = version; @@ -2296,10 +2297,23 @@ Open9xGeneralDataNew::Open9xGeneralDataNew(GeneralSettings & generalData, BoardE void Open9xGeneralDataNew::beforeExport() { uint16_t sum = 0; - for (int i=0; i= 216) { + int count = 0; + for (int i=0; i Date: Fri, 7 Feb 2014 17:50:29 +0100 Subject: [PATCH 17/28] Issue #592 - Stay logical switches function added. Range also prepared to avoid another EEPROM change in a future release. --- companion/src/eeprominterface.cpp | 15 +- companion/src/eeprominterface.h | 10 +- .../src/firmwares/opentx/opentxeeprom.cpp | 22 ++- radio/src/eeprom_conversions.cpp | 8 +- radio/src/gui/menu_model.cpp | 141 ++++++++++++++---- radio/src/gui/menus.cpp | 5 + radio/src/gui/menus.h | 1 + radio/src/myeeprom.h | 30 +++- radio/src/opentx.cpp | 87 ++++++++--- radio/src/opentx.h | 45 ++---- radio/src/simu.cpp | 4 +- radio/src/translations/en.h | 13 +- 12 files changed, 279 insertions(+), 102 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index f6bea20af..e313a6057 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -390,6 +390,8 @@ QString CustomSwData::funcToString() return QObject::tr("Timer"); case CS_FN_STICKY: return QObject::tr("Sticky"); + case CS_FN_STAY: + return QObject::tr("Stay"); default: return QObject::tr("Unknown"); } @@ -406,11 +408,14 @@ QString CustomSwData::toString(const ModelData & model) result +="( "; } switch (getFunctionFamily()) { + case CS_FAMILY_STAY: + result = QObject::tr("STAY(%1, [%2:%3])").arg(RawSwitch(val1).toString()).arg(ValToTim(val2)).arg(ValToTim(val2+val3)); + break; case CS_FAMILY_STICKY: - result = QObject::tr("STICKY(%1 , %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString()); + result = QObject::tr("STICKY(%1, %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString()); break; case CS_FAMILY_TIMER: - result = QObject::tr("TIMER(%1 , %2)").arg(ValToTim(val1)).arg(ValToTim(val2)); + result = QObject::tr("TIMER(%1, %2)").arg(ValToTim(val1)).arg(ValToTim(val2)); break; case CS_FAMILY_VOFS: { RawSource source = RawSource(val1, &model); @@ -873,11 +878,7 @@ void ModelData::clear() phaseData[i].clear(); clearInputs(); clearMixes(); - for(int i=0; i<4; i++){ - mixData[i].destCh = i+1; - mixData[i].srcRaw = RawSource(SOURCE_TYPE_STICK, i); - mixData[i].weight = 100; - } + for (int i=0; ifunc = func; } unsigned int func; - int val1; - int val2; + int val1; + int val2; + int val3; unsigned int delay; unsigned int duration; int andsw; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 60996f68f..779012861 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1140,7 +1140,12 @@ class CustomSwitchField: public TransformedField { switchesConversionTable(SwitchesConversionTable::getInstance(board, version)), andswitchesConversionTable(AndSwitchesConversionTable::getInstance(board, version)) { - if (IS_ARM(board) && version >= 215) { + if (IS_ARM(board) && version >= 216) { + internalField.Append(new SignedField<8>(v1)); + internalField.Append(new SignedField<16>(v2)); + internalField.Append(new SignedField<16>(v3)); + } + else if (IS_ARM(board) && version >= 215) { internalField.Append(new SignedField<16>(v1)); internalField.Append(new SignedField<16>(v2)); } @@ -1170,7 +1175,12 @@ class CustomSwitchField: public TransformedField { virtual void beforeExport() { - if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { + if (csw.func == CS_FN_STAY) { + switchesConversionTable->exportValue(csw.val1, v1); + v2 = csw.val2; + v3 = csw.val3; + } + else if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { switchesConversionTable->exportValue(csw.val1, v1); switchesConversionTable->exportValue(csw.val2, v2); } @@ -1189,7 +1199,12 @@ class CustomSwitchField: public TransformedField { virtual void afterImport() { - if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { + if (csw.func == CS_FN_STAY) { + switchesConversionTable->importValue(v1, csw.val1); + csw.val2 = v2; + csw.val3 = v3; + } + else if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { switchesConversionTable->importValue(v1, csw.val1); switchesConversionTable->importValue(v2, csw.val2); } @@ -1218,6 +1233,7 @@ class CustomSwitchField: public TransformedField { ConversionTable * andswitchesConversionTable; int v1; int v2; + int v3; }; class CustomFunctionsConversionTable: public ConversionTable { diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index 58c07b74f..9bbf8fe55 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -381,13 +381,13 @@ void ConvertModel_215_to_216(ModelData &model) #if defined(PCBTARANIS) CustomSwData * cs = &g_model.customSw[i]; uint8_t cstate = cswFamily(cs->func); - if (cstate == CS_VOFS || cstate == CS_VCOMP || cstate == CS_VDIFF) { + if (cstate == CS_FAMILY_OFS || cstate == CS_FAMILY_COMP || cstate == CS_FAMILY_DIFF) { if (cs->v1 > 0) cs->v1 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; if (cs->v1 > MIXSRC_GVAR1+4) cs->v1 += 4; } - if (cstate == CS_VOFS || cstate == CS_VDIFF) { + if (cstate == CS_FAMILY_OFS || cstate == CS_FAMILY_DIFF) { if (cs->v1 >= MIXSRC_FIRST_TELEM) { - switch (cs->v1) { + switch ((uint8_t)cs->v1) { case MIXSRC_FIRST_TELEM + TELEM_TM1-1: case MIXSRC_FIRST_TELEM + TELEM_TM2-1: cs->v2 = (cs->v2+128) * 3; @@ -429,7 +429,7 @@ void ConvertModel_215_to_216(ModelData &model) } } } - if (cstate == CS_VCOMP) { + if (cstate == CS_FAMILY_COMP) { if (cs->v2 > 0) cs->v2 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; if (cs->v2 > MIXSRC_GVAR1+4) cs->v2 += 4; } diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 01ee2766d..f310407cb 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4174,6 +4174,9 @@ enum CustomSwitchFields { CSW_FIELD_FUNCTION, CSW_FIELD_V1, CSW_FIELD_V2, +#if defined(PCBTARANIS) + CSW_FIELD_V3, +#endif CSW_FIELD_ANDSW, #if defined(CPUARM) CSW_FIELD_DURATION, @@ -4208,7 +4211,8 @@ void menuModelCustomSwitchOne(uint8_t event) CustomSwData * cs = cswAddress(s_currIdx); uint8_t sw = SWSRC_SW1+s_currIdx; putsSwitches(14*FW, 0, sw, (getSwitch(sw) ? BOLD : 0)); - SIMPLE_SUBMENU_NOTITLE(CSW_FIELD_COUNT); + + SUBMENU_NOTITLE(CSW_FIELD_COUNT, {0, 0, 1, 0 /*, 0...*/}); int8_t sub = m_posVert; @@ -4222,10 +4226,18 @@ void menuModelCustomSwitchOne(uint8_t event) lcd_putsLeft(y, STR_FUNC); lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_VCSWFUNC, cs->func, attr); if (attr) { - CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, CS_MAXF); - if (cstate != cswFamily(cs->func)) { - cs->v1 = 0; - cs->v2 = 0; + cs->func = checkIncDec(event, cs->func, 0, CS_MAXF, EE_MODEL, isFunctionAvailable); + uint8_t new_cstate = cswFamily(cs->func); + if (cstate != new_cstate) { + if (new_cstate == CS_FAMILY_TIMER) { + cs->v1 = cs->v2 = -119; + } + else if (new_cstate == CS_FAMILY_STAY) { + cs->v1 = 0; cs->v2 = -129; cs->v3 = 0; + } + else { + cs->v1 = cs->v2 = 0; + } } } break; @@ -4233,11 +4245,11 @@ void menuModelCustomSwitchOne(uint8_t event) { lcd_putsLeft(y, STR_V1); int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM; - if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { + if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY || cstate == CS_FAMILY_STAY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; } - else if (cstate == CS_VTIMER) { + else if (cstate == CS_FAMILY_TIMER) { lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v1+1, LEFT|attr); v1_max = 99; } @@ -4252,16 +4264,32 @@ void menuModelCustomSwitchOne(uint8_t event) case CSW_FIELD_V2: { lcd_putsLeft(y, STR_V2); - int8_t v2_min=0, v2_max=MIXSRC_LAST_TELEM; - if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { + int16_t v2_min=0, v2_max=MIXSRC_LAST_TELEM; + if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr); v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; } - else if (cstate == CS_VTIMER) { + else if (cstate == CS_FAMILY_TIMER) { lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2+1, LEFT|attr); v2_max = 99; } - else if (cstate == CS_VCOMP) { + else if (cstate == CS_FAMILY_STAY) { + lcd_putc(CSWONE_2ND_COLUMN-4, y, '['); + lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|(m_posHorz==0 ? attr : 0)); + lcd_putc(lcdLastPos, y, ':'); + if (cs->v3 == 0) + lcd_putsAtt(lcdLastPos+3, y, "--", (m_posHorz==1 ? attr : 0)); + else + lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(m_posHorz==1 ? attr : 0)); + lcd_putc(lcdLastPos, y, ']'); + if (s_editMode <= 0) continue; + if (attr && m_posHorz==1) { + CHECK_INCDEC_MODELVAR(event, cs->v3, 0, 222 - cs->v2); + break; + } + v2_min=-129; v2_max = 122; + } + else if (cstate == CS_FAMILY_COMP) { putsMixerSource(CSWONE_2ND_COLUMN, y, cs->v2, attr); } else { @@ -4269,7 +4297,7 @@ void menuModelCustomSwitchOne(uint8_t event) if (cs->v1 >= MIXSRC_FIRST_TELEM) { putsTelemetryChannel(CSWONE_2ND_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), attr|LEFT); v2_max = maxTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1); - if (cstate == CS_VOFS) { + if (cstate == CS_FAMILY_OFS) { v2_min = -128; v2_max -= 128; } @@ -4358,15 +4386,26 @@ void menuModelCustomSwitches(uint8_t event) // CSW params uint8_t cstate = cswFamily(cs->func); - if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { + if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, 0); } - else if (cstate == CS_VCOMP) { + else if (cstate == CS_FAMILY_COMP) { putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, 0); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, 0); } - else if (cstate == CS_VTIMER) { + else if (cstate == CS_FAMILY_STAY) { + putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); + lcd_putc(CSW_3RD_COLUMN-4, y, '['); + lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1); + lcd_putc(lcdLastPos, y, ':'); + if (cs->v3 == 0) + lcd_puts(lcdLastPos+3, y, "--"); + else + lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1); + lcd_putc(lcdLastPos-1, y, ']'); + } + else if (cstate == CS_FAMILY_TIMER) { lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT); lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2+1, LEFT); } @@ -4473,11 +4512,12 @@ void menuModelCustomSwitches(uint8_t event) uint8_t cstate = cswFamily(cs->func); #if defined(CPUARM) int16_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; + int16_t v3_min=0, v3_max=100; #else int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; #endif - if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { + if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; @@ -4485,13 +4525,31 @@ void menuModelCustomSwitches(uint8_t event) INCDEC_SET_FLAG(INCDEC_SWITCH); INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches); } - else if (cstate == CS_VCOMP) { +#if defined(CPUARM) + else if (cstate == CS_FAMILY_STAY) { + putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); + lcd_putc(CSW_3RD_COLUMN-4, y, '['); + lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2); + lcd_putc(lcdLastPos, y, ':'); + if (cs->v3 == 0) + lcd_putsAtt(lcdLastPos+3, y, "--", (horz==CSW_FIELD_V3 ? attr : 0)); + else + lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==CSW_FIELD_V3 ? attr : 0)); + lcd_putc(lcdLastPos, y, ']'); + v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; + v2_min=-129; v2_max = 122; + v3_max = 222 - cs->v2; + INCDEC_SET_FLAG(0); + INCDEC_ENABLE_CHECK(NULL); + } +#endif + else if (cstate == CS_FAMILY_COMP) { putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, attr2); INCDEC_SET_FLAG(INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); } - else if (cstate == CS_VTIMER) { + else if (cstate == CS_FAMILY_TIMER) { lcd_outdezAtt(CSW_2ND_COLUMN, y, cswTimerValue(cs->v1), LEFT|PREC1|attr1); lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2); v1_min = v2_min = -128; @@ -4520,7 +4578,7 @@ void menuModelCustomSwitches(uint8_t event) eeDirty(EE_MODEL); } #else - if (cstate == CS_VOFS) { + if (cstate == CS_FAMILY_OFS) { v2_min = -128; v2_max -= 128; } @@ -4552,37 +4610,59 @@ void menuModelCustomSwitches(uint8_t event) // CSW AND switch #if defined(CPUARM) - putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==3 ? attr : 0); + putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==CSW_FIELD_ANDSW ? attr : 0); #else uint8_t andsw = cs->andsw; if (andsw > SWSRC_LAST_SWITCH) { andsw += SWSRC_SW1-SWSRC_LAST_SWITCH-1; } - putsSwitches(CSW_4TH_COLUMN, y, andsw, horz==3 ? attr : 0); + putsSwitches(CSW_4TH_COLUMN, y, andsw, horz==CSW_FIELD_ANDSW ? attr : 0); #endif #if defined(CPUARM) // CSW duration if (cs->duration > 0) - lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==4 ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==CSW_FIELD_DURATION ? attr : 0)|PREC1|LEFT); else - lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==4 ? attr : 0); + lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DURATION ? attr : 0); // CSW delay if (cs->delay > 0) - lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==5 ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==CSW_FIELD_DELAY ? attr : 0)|PREC1|LEFT); else - lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==5 ? attr : 0); + lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DELAY ? attr : 0); + + if (attr && horz == CSW_FIELD_V3 && cstate != CS_FAMILY_STAY) { + REPEAT_LAST_CURSOR_MOVE(); + } #endif + if ((s_editMode>0 || p1valdiff) && attr) { switch (horz) { case CSW_FIELD_FUNCTION: { +#if defined(CPUARM) + cs->func = checkIncDec(event, cs->func, 0, CS_MAXF, EE_MODEL, isFunctionAvailable); +#else CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, CS_MAXF); +#endif uint8_t new_cstate = cswFamily(cs->func); - if (cstate != new_cstate) - cs->v1 = cs->v2 = (new_cstate==CS_VTIMER ? -119/*1.0*/ : 0); + if (cstate != new_cstate) { +#if defined(CPUARM) + if (new_cstate == CS_FAMILY_TIMER) { + cs->v1 = cs->v2 = -119; + } + else if (new_cstate == CS_FAMILY_STAY) { + cs->v1 = 0; cs->v2 = -129; cs->v3 = 0; + } + else { + cs->v1 = cs->v2 = 0; + } +#else + cs->v1 = cs->v2 = (new_cstate==CS_FAMILY_TIMER ? -119/*1.0*/ : 0); +#endif + } break; } case CSW_FIELD_V1: @@ -4591,7 +4671,7 @@ void menuModelCustomSwitches(uint8_t event) case CSW_FIELD_V2: cs->v2 = CHECK_INCDEC_PARAM(event, cs->v2, v2_min, v2_max); #if defined(PCBTARANIS) - if (cstate==CS_VOFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { + if (cstate==CS_FAMILY_OFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { killEvents(event); getvalue_t x = getValue(cs->v1); if (cs->v1 < MIXSRC_GVAR1) @@ -4602,6 +4682,11 @@ void menuModelCustomSwitches(uint8_t event) } #endif break; +#if defined(CPUARM) + case CSW_FIELD_V3: + cs->v3 = CHECK_INCDEC_PARAM(event, cs->v3, v3_min, v3_max); + break; +#endif case CSW_FIELD_ANDSW: #if defined(CPUARM) INCDEC_SET_FLAG(INCDEC_SWITCH); diff --git a/radio/src/gui/menus.cpp b/radio/src/gui/menus.cpp index 455ac0a57..e6cbfccee 100644 --- a/radio/src/gui/menus.cpp +++ b/radio/src/gui/menus.cpp @@ -1291,5 +1291,10 @@ bool isSwitchAvailable(int16_t swtch) return true; } +// Not available yet, will be needed if we implement the Range function later... +bool isFunctionAvailable(int16_t function) +{ + return function != CS_RANGE; +} #endif diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index 3b4e44e59..eed58fd97 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -190,6 +190,7 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); var = checkIncDecModelZero(event,var,max) #if defined(CPUARM) + bool isFunctionAvailable(int16_t function); bool isSwitchAvailable(int16_t swtch); bool isSwitchAvailableInCustomSwitches(int16_t swtch); #define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER)) diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 7fd0183d8..c74a12f76 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -668,14 +668,42 @@ PACK( union u_int8int16_t { #endif +enum CswFunctions { + CS_OFF, + CS_VEQUAL, // v==offset + CS_VPOS, // v>offset + CS_VNEG, // voffset + CS_ANEG, // |v|srcRaw = i+1; - if (!isSourceAvailable(mix->srcRaw)) { - mix->srcRaw = MIXSRC_Rud - 1 + stick_index; - } #else mix->srcRaw = MIXSRC_Rud - 1 + channel_order(i+1); #endif @@ -573,9 +583,9 @@ void modelDefault(uint8_t id) g_model.frsky.channels[0].ratio = 132; #endif -#ifdef MAVLINK - g_model.mavlink.rc_rssi_scale = 15; - g_model.mavlink.pc_rssi_en = 1; +#if defined(MAVLINK) + g_model.mavlink.rc_rssi_scale = 15; + g_model.mavlink.pc_rssi_en = 1; #endif } @@ -1426,7 +1436,7 @@ bool getSwitch(int8_t swtch) csLastValue[cs_idx] = CS_LAST_VALUE_INIT; result = false; } - else if ((s=cswFamily(cs->func)) == CS_VBOOL) { + else if ((s=cswFamily(cs->func)) == CS_FAMILY_BOOL) { bool res1 = getSwitch(cs->v1); bool res2 = getSwitch(cs->v2); switch (cs->func) { @@ -1442,16 +1452,21 @@ bool getSwitch(int8_t swtch) break; } } - else if (s == CS_VTIMER) { + else if (s == CS_FAMILY_TIMER) { result = (csLastValue[cs_idx] <= 0); } - else if (s == CS_VSTICKY) { + else if (s == CS_FAMILY_STICKY) { result = (csLastValue[cs_idx] & (1<<0)); } +#if defined(CPUARM) + else if (s == CS_FAMILY_STAY) { + result = (csLastValue[cs_idx] & (1<<0)); + } +#endif else { getvalue_t x = getValue(cs->v1); getvalue_t y; - if (s == CS_VCOMP) { + if (s == CS_FAMILY_COMP) { y = getValue(cs->v2); switch (cs->func) { @@ -1476,7 +1491,7 @@ bool getSwitch(int8_t swtch) y = convertCswTelemValue(cs); #if defined(FRSKY_HUB) && defined(GAUGES) - if (s == CS_VOFS) { + if (s == CS_FAMILY_OFS) { uint8_t idx = cs->v1-MIXSRC_FIRST_TELEM+1-TELEM_ALT; if (idx < THLD_MAX) { // Fill the threshold array @@ -1563,6 +1578,9 @@ bool getSwitch(int8_t swtch) if (cswDurations[cs_idx] > get_tmr10ms()) { result = true; } + else if (s == CS_FAMILY_STICKY) { + csLastValue[cs_idx] &= ~(1<<0); + } } #endif @@ -1980,7 +1998,7 @@ getvalue_t convertCswTelemValue(CustomSwData * cs) #if defined(CPUARM) val = convert16bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, cs->v2); #else - if (cswFamily(cs->func)==CS_VOFS) + if (cswFamily(cs->func)==CS_FAMILY_OFS) val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2); else val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2) - convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128); @@ -3995,27 +4013,54 @@ void doMixerCalculations() } } else if (cs->func == CS_STICKY) { - uint16_t & lastValue = (uint16_t &)csLastValue[i]; - bool before = (lastValue & (1<<15)); - if (lastValue & (1<<0)) { + PACK(typedef struct { + bool state; + bool last; + }) cs_sticky_struct; + cs_sticky_struct & lastValue = (cs_sticky_struct &)csLastValue[i]; + bool before = lastValue.last & 0x01; + if (lastValue.state) { bool now = getSwitch(cs->v2); if (now != before) { - lastValue ^= (1<<15); + lastValue.last ^= true; if (!before) { - lastValue &= ~(1<<0); + lastValue.state = false; } } } else { bool now = getSwitch(cs->v1); if (before != now) { - lastValue ^= (1<<15); + lastValue.last ^= true; if (!before) { - lastValue |= (1<<0); + lastValue.state = true; } } } } +#if defined(CPUARM) + else if (cs->func == CS_STAY) { + PACK(typedef struct { + uint8_t state:1; + uint16_t duration:15; + }) cs_stay_struct; + + cs_stay_struct & lastValue = (cs_stay_struct &)csLastValue[i]; + lastValue.state = false; + bool state = getSwitch(cs->v1); + if (state) { + if (cs->v3 == 0 && lastValue.duration == cswTimerValue(cs->v2)) + lastValue.state = true; + if (lastValue.duration < 1000) + lastValue.duration++; + } + else { + if (lastValue.duration > cswTimerValue(cs->v2) && lastValue.duration <= cswTimerValue(cs->v2+cs->v3)) + lastValue.state = true; + lastValue.duration = 0; + } + } +#endif } if (s_cnt_1s >= 10) { // 1sec diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 765a56c2d..82f8aca72 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -622,37 +622,6 @@ enum BaseCurves { #define SWASH_TYPE_90 4 #define SWASH_TYPE_NUM 4 -enum CswFunctions { - CS_OFF, - CS_VEQUAL, // v==offset - CS_VPOS, // v>offset - CS_VNEG, // voffset - CS_ANEG, // |v|x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a Date: Fri, 7 Feb 2014 18:24:25 +0100 Subject: [PATCH 18/28] Stay function added in Companion --- companion/src/eeprominterface.cpp | 4 +- .../src/firmwares/opentx/opentxeeprom.cpp | 2 + companion/src/helpers.cpp | 2 + companion/src/modeledit/customswitches.cpp | 131 ++++++------------ companion/src/modeledit/customswitches.h | 1 + 5 files changed, 50 insertions(+), 90 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index e313a6057..3705559ce 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -337,7 +337,9 @@ QString CurveReference::toString() CSFunctionFamily CustomSwData::getFunctionFamily() { - if (func == CS_FN_TIMER) + if (func == CS_FN_STAY) + return CS_FAMILY_STAY; + else if (func == CS_FN_TIMER) return CS_FAMILY_TIMER; else if (func == CS_FN_STICKY) return CS_FAMILY_STICKY; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 779012861..9dc1fe4e6 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1032,11 +1032,13 @@ class CustomSwitchesFunctionsTable: public ConversionTable { addConversion(CS_FN_VEQUAL, val++); addConversion(CS_FN_VPOS, val++); addConversion(CS_FN_VNEG, val++); + if (IS_ARM(board) && version >= 216) val++; // later RANGE addConversion(CS_FN_APOS, val++); addConversion(CS_FN_ANEG, val++); addConversion(CS_FN_AND, val++); addConversion(CS_FN_OR, val++); addConversion(CS_FN_XOR, val++); + if (IS_ARM(board) && version >= 216) addConversion(CS_FN_STAY, val++); addConversion(CS_FN_EQUAL, val++); if (!release21March2013) addConversion(CS_FN_NEQUAL, val++); diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 7864dc100..ed845e371 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -673,11 +673,13 @@ void populateCSWCB(QComboBox *b, int value) CS_FN_VEQUAL, // added at the end to avoid everything renumbered CS_FN_VPOS, CS_FN_VNEG, + // CS_FN_RANGE, CS_FN_APOS, CS_FN_ANEG, CS_FN_AND, CS_FN_OR, CS_FN_XOR, + CS_FN_STAY, CS_FN_EQUAL, CS_FN_NEQUAL, CS_FN_GREATER, diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp index aea3dd602..72c9404f0 100644 --- a/companion/src/modeledit/customswitches.cpp +++ b/companion/src/modeledit/customswitches.cpp @@ -180,16 +180,19 @@ void CustomSwitchesPanel::edited() if (!lock) { lock = true; int i = sender()->property("index").toInt(); - bool chAr; - float value, step; - int newval; - chAr = (model.customSw[i].getFunctionFamily() != CustomSwData(csw[i]->itemData(csw[i]->currentIndex()).toInt()).getFunctionFamily()); - model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt(); - if(chAr) { + int newFunc = csw[i]->itemData(csw[i]->currentIndex()).toInt(); + bool chAr = (model.customSw[i].getFunctionFamily() != CustomSwData(newFunc).getFunctionFamily()); + model.customSw[i].func = newFunc; + if (chAr) { if (model.customSw[i].getFunctionFamily() == CS_FAMILY_TIMER) { model.customSw[i].val1 = -119; model.customSw[i].val2 = -119; } + else if (model.customSw[i].getFunctionFamily() == CS_FAMILY_STAY) { + model.customSw[i].val1 = 0; + model.customSw[i].val2 = -129; + model.customSw[i].val3 = 0; + } else { model.customSw[i].val1 = 0; model.customSw[i].val2 = 0; @@ -216,65 +219,15 @@ void CustomSwitchesPanel::edited() } break; case CS_FAMILY_TIMER: - { - value = cswitchOffset[i]->value(); - newval=TimToVal(value); - if (newval>model.customSw[i].val2) { - if (value >=60) { - value=round(value); - step=1; - } else if (value>=2) { - value=(round(value*2.0)/2); - step=0.5; - } else { - step=0.1; - } - } - else { - if (value <=2) { - step=0.1; - } else if (value<=60) { - value=(round(value*2.0)/2); - step=0.5; - } else { - value=round(value); - step=1; - } - } - model.customSw[i].val2=TimToVal(value); - value=ValToTim(model.customSw[i].val2); - cswitchOffset[i]->setValue(value); - cswitchOffset[i]->setSingleStep(step); - - value=cswitchValue[i]->value(); - newval=TimToVal(value); - if (newval>model.customSw[i].val1) { - if (value >=60) { - value=round(value); - step=1; - } else if (value>=2) { - value=(round(value*2.0)/2); - step=0.5; - } else { - step=0.1; - } - } else { - if (value <=2) { - step=0.1; - } else if (value<=60) { - value=(round(value*2.0)/2); - step=0.5; - } else { - value=round(value); - step=1; - } - } - model.customSw[i].val1=TimToVal(value); - value=ValToTim(model.customSw[i].val1); - cswitchValue[i]->setValue(value); - cswitchValue[i]->setSingleStep(step); + model.customSw[i].val1 = TimToVal(cswitchValue[i]->value()); + model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value()); + updateTimerParam(cswitchValue[i], model.customSw[i].val1); + updateTimerParam(cswitchOffset[i], model.customSw[i].val2); + break; + case CS_FAMILY_STAY: + model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value()); + updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true); break; - } default: break; } @@ -283,6 +236,22 @@ void CustomSwitchesPanel::edited() } } +void CustomSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero) +{ + sb->setVisible(true); + sb->setDecimals(1); + sb->setMinimum(allowZero ? 0.0 : 0.1); + sb->setMaximum(175); + float value = ValToTim(timer); + if (value>60) + sb->setSingleStep(1); + else if (value>2) + sb->setSingleStep(0.5); + else + sb->setSingleStep(0.1); + sb->setValue(value); +} + void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) { lock = true; @@ -320,6 +289,13 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1)); populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2)); break; + case CS_FAMILY_STAY: + cswitchSource1[i]->setVisible(true); + cswitchSource2[i]->setVisible(false); + cswitchValue[i]->setVisible(false); + populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1)); + updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true); + break; case CS_FAMILY_VCOMP: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(true); @@ -331,31 +307,8 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) case CS_FAMILY_TIMER: cswitchSource1[i]->setVisible(false); cswitchSource2[i]->setVisible(false); - cswitchValue[i]->setVisible(true); - cswitchOffset[i]->setVisible(true); - cswitchOffset[i]->setDecimals(1); - cswitchOffset[i]->setMinimum(0.1); - cswitchOffset[i]->setMaximum(175); - float value=ValToTim(model.customSw[i].val2); - cswitchOffset[i]->setSingleStep(0.1); - if (value>60) { - cswitchOffset[i]->setSingleStep(1); - } else if (value>2) { - cswitchOffset[i]->setSingleStep(0.5); - } - cswitchOffset[i]->setValue(value); - - cswitchValue[i]->setDecimals(1); - cswitchValue[i]->setMinimum(0.1); - cswitchValue[i]->setMaximum(175); - value=ValToTim(model.customSw[i].val1); - cswitchValue[i]->setSingleStep(0.1); - if (value>60) { - cswitchValue[i]->setSingleStep(1); - } else if (value>2) { - cswitchValue[i]->setSingleStep(0.5); - } - cswitchValue[i]->setValue(value); + updateTimerParam(cswitchValue[i], model.customSw[i].val1); + updateTimerParam(cswitchOffset[i], model.customSw[i].val2); break; } diff --git a/companion/src/modeledit/customswitches.h b/companion/src/modeledit/customswitches.h index f4354bcb9..0ff1973d6 100644 --- a/companion/src/modeledit/customswitches.h +++ b/companion/src/modeledit/customswitches.h @@ -42,6 +42,7 @@ class CustomSwitchesPanel : public ModelPanel void updateSelectedSwitch(); void updateV2(int index); + void updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero=false); }; From 8f0a318cc30aae49ce6e4831a2d764b715a20bd0 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 7 Feb 2014 21:52:30 +0100 Subject: [PATCH 19/28] Issue #662 fixed - Companion copy/paste bug --- companion/src/modeledit/customfunctions.cpp | 60 ++++++++++++++++----- companion/src/modeledit/customfunctions.h | 6 ++- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 98c331f5d..d2468bc19 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -36,6 +36,16 @@ void RepeatComboBox::onIndexChanged(int index) emit modified(); } +void RepeatComboBox::update() +{ + unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10; + int value = repeatParam/step; + if (step == 1) { + value++; + } + setCurrentIndex(value); +} + CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings): ModelPanel(parent, model), generalSettings(generalSettings), @@ -52,7 +62,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, lock = true; int num_fsw = GetEepromInterface()->getCapability(CustomFunctions); - QStringList paramarmList; if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) { for (int i=0; isetContextMenuPolicy(Qt::CustomContextMenu); + label->setMouseTracking(true); + label->setProperty("index", i); + label->setText(tr("CF%1").arg(i+1)); + gridLayout->addWidget(label, i+1, 0); + connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint))); + // The switch fswtchSwtch[i] = new QComboBox(this); fswtchSwtch[i]->setProperty("index", i); @@ -135,7 +153,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, fswtchParamArmT[i] = new QComboBox(this); fswtchParamArmT[i]->setProperty("index", i); - populateFuncParamArmTCB(fswtchParamArmT[i],&model, model.funcSw[i].paramarm, paramarmList); + populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList); fswtchParamArmT[i]->setEditable(true); paramLayout->addWidget(fswtchParamArmT[i]); @@ -337,6 +355,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) { widgetsMask |= CUSTOM_FUNCTION_REPEAT; + fswtchRepeat[i]->update(); } if (index==FuncPlayValue) { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); @@ -381,14 +400,20 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); - int vml=GetEepromInterface()->getCapability(VoicesMaxLength); + int vml = GetEepromInterface()->getCapability(VoicesMaxLength); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; - for (int j=0; jcurrentText().length(),vml); j++) { + for (int j=0; jcurrentText().length(), vml); j++) { model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); } } } + else { + populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList); + if (fswtchParamArmT[i]->currentText() != "----") { + widgetsMask |= CUSTOM_FUNCTION_PLAY; + } + } } } else if (index==FuncBackgroundMusic) { @@ -453,13 +478,13 @@ void CustomFunctionsPanel::fswPaste() const QMimeData *mimeData = clipboard->mimeData(); if (mimeData->hasFormat("application/x-companion-fsw")) { QByteArray fswData = mimeData->data("application/x-companion-fsw"); - FuncSwData *fsw = &model.funcSw[selectedFunction]; memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData)); - // TODO update switch and func + lock = true; populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF); populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func); refreshCustomFunction(selectedFunction); + lock = false; emit modified(); } } @@ -476,17 +501,17 @@ void CustomFunctionsPanel::fswDelete() void CustomFunctionsPanel::fswCopy() { - QByteArray fswData; - fswData.append((char*)&model.funcSw[selectedFunction],sizeof(FuncSwData)); - QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-companion-fsw", fswData); - QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); + QByteArray fswData; + fswData.append((char*)&model.funcSw[selectedFunction], sizeof(FuncSwData)); + QMimeData *mimeData = new QMimeData; + mimeData->setData("application/x-companion-fsw", fswData); + QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); } void CustomFunctionsPanel::fswCut() { - fswCopy(); - fswDelete(); + fswCopy(); + fswDelete(); } void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos) @@ -551,18 +576,25 @@ void CustomFunctionsPanel::populateGVmodeCB(QComboBox *b, unsigned int value) b->setCurrentIndex(value); } -void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList) +void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList) { b->clear(); b->addItem("----"); + bool added = false; QString currentvalue(value); foreach ( QString entry, paramsList ) { b->addItem(entry); if (entry==currentvalue) { b->setCurrentIndex(b->count()-1); + added = true; } } + + if (!added && strlen(value)) { + b->addItem(value); + b->setCurrentIndex(b->count()-1); + } } void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode) diff --git a/companion/src/modeledit/customfunctions.h b/companion/src/modeledit/customfunctions.h index bb109d9e1..0730e46c6 100644 --- a/companion/src/modeledit/customfunctions.h +++ b/companion/src/modeledit/customfunctions.h @@ -19,6 +19,7 @@ class RepeatComboBox: public QComboBox public: RepeatComboBox(QWidget *parent, int & repeatParam); + void update(); signals: void modified(); @@ -58,9 +59,10 @@ class CustomFunctionsPanel : public ModelPanel void populateFuncCB(QComboBox *b, unsigned int value); void populateGVmodeCB(QComboBox *b, unsigned int value); void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0); - void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList); + void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList); GeneralSettings & generalSettings; + QStringList paramarmList; bool phononLock; QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS]; @@ -70,7 +72,7 @@ class CustomFunctionsPanel : public ModelPanel QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS]; QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS]; + RepeatComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS]; #ifdef PHONON Phonon::MediaObject *clickObject; From 2e35e095c6c943256cce5c8224ba96ed3a5be473 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 7 Feb 2014 22:10:06 +0100 Subject: [PATCH 20/28] AUTOSWITCH enabled with Stay function --- radio/src/gui/menu_model.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index f310407cb..9786693cf 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4539,8 +4539,14 @@ void menuModelCustomSwitches(uint8_t event) v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; v2_min=-129; v2_max = 122; v3_max = 222 - cs->v2; - INCDEC_SET_FLAG(0); - INCDEC_ENABLE_CHECK(NULL); + if (horz == 1) { + INCDEC_SET_FLAG(INCDEC_SWITCH); + INCDEC_ENABLE_CHECK(isSwitchAvailable); + } + else { + INCDEC_SET_FLAG(0); + INCDEC_ENABLE_CHECK(NULL); + } } #endif else if (cstate == CS_FAMILY_COMP) { From f686934430b9cb47ece783a4e6e6beb788cb3061 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 7 Feb 2014 22:17:32 +0100 Subject: [PATCH 21/28] Delay not applicable on Stay logical switches --- radio/src/gui/menu_model.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 9786693cf..41c1c7b41 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4633,10 +4633,18 @@ void menuModelCustomSwitches(uint8_t event) lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DURATION ? attr : 0); // CSW delay - if (cs->delay > 0) + if (cstate == CS_FAMILY_STAY) { + lcd_puts(CSW_6TH_COLUMN, y, "N/A"); + if (attr && horz == CSW_FIELD_DELAY) { + REPEAT_LAST_CURSOR_MOVE(); + } + } + else if (cs->delay > 0) { lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==CSW_FIELD_DELAY ? attr : 0)|PREC1|LEFT); - else + } + else { lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DELAY ? attr : 0); + } if (attr && horz == CSW_FIELD_V3 && cstate != CS_FAMILY_STAY) { REPEAT_LAST_CURSOR_MOVE(); From 4c5ac47507061cc57d80c645ae782d8a4b3c8c05 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 7 Feb 2014 22:58:12 +0100 Subject: [PATCH 22/28] Problem with AdjustGVAR modes on ARM boards (mode has > 2bits, allowing more modes if needed later) --- radio/src/gui/menu_model.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 41c1c7b41..5bcbf4da8 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -5019,6 +5019,9 @@ void menuModelCustomFunctions(uint8_t event) s_editMode = !s_editMode; active = true; CFN_GVAR_MODE(sd) += 1; +#if defined(CPUARM) + CFN_GVAR_MODE(sd) &= 0x03; +#endif val_displayed = 0; } } From ca9d53dbdd111a901209a9ab1587e46f855c95f8 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Sat, 8 Feb 2014 00:30:35 +0100 Subject: [PATCH 23/28] CS->LS --- radio/src/translations/en.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index ec0e9258d..c81367c07 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -340,11 +340,11 @@ #endif #if defined(CPUARM) - #define TR_CUSTOMSW "CS1""CS2""CS3""CS4""CS5""CS6""CS7""CS8""CS9""CSA""CSB""CSC""CSD""CSE""CSF""CSG""CSH""CSI""CSJ""CSK""CSL""CSM""CSN""CSO""CSP""CSQ""CSR""CSS""CST""CSU""CSV""CSW" + #define TR_CUSTOMSW "LS1""LS2""LS3""LS4""LS5""LS6""LS7""LS8""LS9""LSA""LSB""LSC""LSD""LSE""LSF""LSG""LSH""LSI""LSJ""LSK""LSL""LSM""LSN""LSO""LSP""LSQ""LSR""LSS""LST""LSU""LSV""LSW" #elif defined(PCBGRUVIN9X) || defined(CPUM2561) || defined(CPUM128) - #define TR_CUSTOMSW "CS1""CS2""CS3""CS4""CS5""CS6""CS7""CS8""CS9""CSA""CSB""CSC""CSD""CSE""CSF" + #define TR_CUSTOMSW "LS1""LS2""LS3""LS4""LS5""LS6""LS7""LS8""LS9""LSA""LSB""LSC""LSD""LSE""LSF" #else - #define TR_CUSTOMSW "CS1""CS2""CS3""CS4""CS5""CS6""CS7""CS8""CS9""CSA""CSB""CSC" + #define TR_CUSTOMSW "LS1""LS2""LS3""LS4""LS5""LS6""LS7""LS8""LS9""LSA""LSB""LSC" #endif #define TR_TRIMS_SWITCHES "tRl""tRr""tEd""tEu""tTd""tTu""tAl""tAr" From 1ce67a62c2cfec1e5c9beed384fc8854ebbf023e Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Sat, 8 Feb 2014 00:50:03 +0100 Subject: [PATCH 24/28] Sync translations --- radio/src/translations/cz.h.txt | 69 +++++++++++++++++++----------- radio/src/translations/de.h.txt | 69 +++++++++++++++++++----------- radio/src/translations/en.h | 2 +- radio/src/translations/es.h.txt | 71 +++++++++++++++++++------------ radio/src/translations/fr.h.txt | 75 +++++++++++++++++++++------------ radio/src/translations/it.h.txt | 69 +++++++++++++++++++----------- radio/src/translations/pl.h.txt | 67 ++++++++++++++++++----------- radio/src/translations/pt.h.txt | 69 +++++++++++++++++++----------- radio/src/translations/se.h.txt | 67 ++++++++++++++++++----------- 9 files changed, 355 insertions(+), 203 deletions(-) diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 8901e27ed..9718e7357 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -150,8 +150,25 @@ #define LEN_VMIXTRIMS "\004" #define TR_VMIXTRIMS "VYP\0""ZAP\0""Směr""Výšk""Plyn""Křid" +#if defined(PCBTARANIS) + #define TR_CSWTIMER "Timer" + #define TR_CSWSTICKY "Stcky" + #define TR_CSWRANGE "Range" + #define TR_CSWSTAY "Stay\0" +#else + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Glue\0" + #if defined(CPUARM) + #define TR_CSWRANGE "Rnge\0" + #define TR_CSWSTAY "Stay\0" + #else + #define TR_CSWRANGE + #define TR_CSWSTAY + #endif +#endif + #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " + #define TR_ROTARY_ENCODERS "REa\0" + #define TR_ROTENC_SWITCHES "REa" +#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) + #define TR_ROTARY_ENCODERS "REa\0""REb\0" + #define TR_ROTENC_SWITCHES "REa""REb" #else - #define TR_ROTARY_ENCODERS_VSRCRAW + #define TR_ROTARY_ENCODERS + #define TR_ROTENC_SWITCHES +#endif + +#if defined(PCBTARANIS) + #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#elif defined(CPUARM) + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#else + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW #endif #if defined(HELI) @@ -356,7 +375,7 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif -#define TR_VSRCRAW "---\0""Směr""Výšk""Plyn""Křid" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX\0" TR_CYC_VSRCRAW "TrmS" "TrmV" "TrmP" "TrmK" TR_SW_VSRCRAW +#define TR_VSRCRAW "---\0""Směr""Výšk""Plyn""Křid" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmS" "TrmV" "TrmP" "TrmK" TR_SW_VSRCRAW #define LEN_VTMRMODES "\003" #define TR_VTMRMODES "VYP""ABS""THs""TH%""THt" @@ -713,7 +732,7 @@ // Taranis column headers #define TR_PHASES_HEADERS { " Jméno ", " Spínač ", " Trimy ", " Přechod Zap ", " Přechod Vyp " } #define TR_LIMITS_HEADERS { " Jméno ", " Subtrim ", " Min ", " Max ", " Směr ", " Křivka ", " Střed PPM ", " Symetrické " } -#define TR_CSW_HEADERS { " Funkce ", " Hodnota 1 ", " Hodnota 2 ", " AND Spínač ", " Trvání ", " Zpoždění " } +#define TR_CSW_HEADERS { " Funkce ", " Hodnota 1 ", " Hodnota 2 ", " Hodnota 2 ", " AND Spínač ", " Trvání ", " Zpoždění " } //Taranis About screen #define TR_ABOUTUS TR(" O nás ", "O nás") @@ -766,7 +785,7 @@ #define TR_CHR_LONG 'l' #define TR_CHR_TOGGLE 't' #define TR_CHR_HOUR 'h' -#define TR_CHR_INPUT 'I' // Values between A-I will work +#define TR_CHR_INPUT 'I' // Values between A-I will work #define TR_BEEP_VOLUME "Pípání" #define TR_WAV_VOLUME "Zvuky WAV" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index 429781e15..65d9d91b7 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -150,8 +150,25 @@ #define LEN_VMIXTRIMS "\003" #define TR_VMIXTRIMS "AUS""EIN""Sei""H\203e""Gas""Que" //Mixer Trim Werte +#if defined(PCBTARANIS) + #define TR_CSWTIMER "Timer" + #define TR_CSWSTICKY "Stcky" + #define TR_CSWRANGE "Range" + #define TR_CSWSTAY "Stay\0" +#else + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Glue\0" + #if defined(CPUARM) + #define TR_CSWRANGE "Rnge\0" + #define TR_CSWSTAY "Stay\0" + #else + #define TR_CSWRANGE + #define TR_CSWSTAY + #endif +#endif + #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "DGa ""DGb ""DGc ""DGd " -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "DGa ""DGb " + #define TR_ROTARY_ENCODERS "DGa\0" + #define TR_ROTENC_SWITCHES "DGa" +#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) + #define TR_ROTARY_ENCODERS "DGa\0""DGb\0" + #define TR_ROTENC_SWITCHES "DGa""DGb" #else - #define TR_ROTARY_ENCODERS_VSRCRAW + #define TR_ROTARY_ENCODERS + #define TR_ROTENC_SWITCHES +#endif + +#if defined(PCBTARANIS) + #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#elif defined(CPUARM) + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#else + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW #endif #if defined(HELI) @@ -356,7 +375,7 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif -#define TR_VSRCRAW "---\0""Sei\0""H\203h\0""Gas\0""Que\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX\0" TR_CYC_VSRCRAW "TrmS" "TrmH" "TrmG" "TrmQ" TR_SW_VSRCRAW +#define TR_VSRCRAW "---\0""Sei\0""H\203h\0""Gas\0""Que\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmS" "TrmH" "TrmG" "TrmQ" TR_SW_VSRCRAW #define LEN_VTMRMODES "\003" #define TR_VTMRMODES "AUS""ABS""GSs""GS%""GSt" @@ -713,7 +732,7 @@ // Taranis column headers #define TR_PHASES_HEADERS { " Name ", " Schalter ", " Trimmung ", " Fade In ", " Fade Out " } #define TR_LIMITS_HEADERS { " Name ", " Subtrim ", " Min ", " Max ", " Richtung ", " Kurve ", " PPM Mitte ", " Subtrim Mode " } -#define TR_CSW_HEADERS { " Funktion ", " Var1 ", " Var2 ", " UND Schalter ", " Dauer ", " Delay " } +#define TR_CSW_HEADERS { " Funktion ", " Var1 ", " Var2 ", " Var2 ", " UND Schalter ", " Dauer ", " Delay " } //Taranis About screen #define TR_ABOUTUS "Über OpenTx" @@ -766,7 +785,7 @@ #define TR_CHR_LONG 'l' //Taste long #define TR_CHR_TOGGLE 't' //Taste als togglefunktion = Ein Aus Ein #define TR_CHR_HOUR 'h' //Stunden -#define TR_CHR_INPUT 'I' // Values between A-I will work +#define TR_CHR_INPUT 'I' // Values between A-I will work #define TR_BEEP_VOLUME "Beep Lautst" #define TR_WAV_VOLUME "Wav Lautst" diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index c81367c07..a82ca8b45 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -785,7 +785,7 @@ #define TR_CHR_LONG 'l' #define TR_CHR_TOGGLE 't' #define TR_CHR_HOUR 'h' -#define TR_CHR_INPUT 'I' // Values between A-I will work +#define TR_CHR_INPUT 'I' // Values between A-I will work #define TR_BEEP_VOLUME "Beep Volume" #define TR_WAV_VOLUME "Wav Volume" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index 952bc68fa..d7a0ff189 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -150,8 +150,25 @@ #define LEN_VMIXTRIMS "\003" #define TR_VMIXTRIMS "OFF""ON\0""Dir""Ele""Ace""Ale" +#if defined(PCBTARANIS) + #define TR_CSWTIMER "Timer" + #define TR_CSWSTICKY "Stcky" + #define TR_CSWRANGE "Range" + #define TR_CSWSTAY "Stay\0" +#else + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Glue\0" + #if defined(CPUARM) + #define TR_CSWRANGE "Rnge\0" + #define TR_CSWSTAY "Stay\0" + #else + #define TR_CSWRANGE + #define TR_CSWSTAY + #endif +#endif + #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " + #define TR_ROTARY_ENCODERS "REa\0" + #define TR_ROTENC_SWITCHES "REa" +#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) + #define TR_ROTARY_ENCODERS "REa\0""REb\0" + #define TR_ROTENC_SWITCHES "REa""REb" #else - #define TR_ROTARY_ENCODERS_VSRCRAW + #define TR_ROTARY_ENCODERS + #define TR_ROTENC_SWITCHES +#endif + +#if defined(PCBTARANIS) + #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#elif defined(CPUARM) + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#else + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW #endif #if defined(HELI) @@ -356,7 +375,7 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif -#define TR_VSRCRAW "---\0""Dir\0""Ele\0""Thr\0""Ale\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX\0" TR_CYC_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" TR_SW_VSRCRAW +#define TR_VSRCRAW "---\0""Dir\0""Ele\0""Thr\0""Ale\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" TR_SW_VSRCRAW #define LEN_VTMRMODES "\003" #define TR_VTMRMODES "OFF""ABS""THs""TH%""THt" @@ -713,7 +732,7 @@ // Taranis column headers #define TR_PHASES_HEADERS { " Nombre ", " Interrup.", " Trims ", " Aparecer ", " Desparecer " } #define TR_LIMITS_HEADERS { " Nombre ", " Compensacion", " Min ", " Max ", " Direccion ", " Curve ", " Centrado PPM ", " Simetrica " } -#define TR_CSW_HEADERS { " Funcion ", " V1 ", " V2 ", " AND Interrup. ", " Duracion ", " Retardo " } +#define TR_CSW_HEADERS { " Funcion ", " V1 ", " V2 ", " V2 ", " AND Interrup. ", " Duracion ", " Retardo " } //Taranis About screen #define TR_ABOUTUS "Nosotros" @@ -766,7 +785,7 @@ #define TR_CHR_LONG 'l' #define TR_CHR_TOGGLE 't' #define TR_CHR_HOUR 'h' -#define TR_CHR_INPUT 'I' // Values between A-I will work +#define TR_CHR_INPUT 'I' // Values between A-I will work #define TR_BEEP_VOLUME "Volumen Beep" #define TR_WAV_VOLUME "Volumen Wav" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 8cf9b660f..7c6e770c8 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -150,8 +150,25 @@ #define LEN_VMIXTRIMS "\003" #define TR_VMIXTRIMS "OFF""ON\0""Dir""Prf""Gaz""Ail" +#if defined(PCBTARANIS) + #define TR_CSWTIMER "Timer" + #define TR_CSWSTICKY "Stcky" + #define TR_CSWRANGE "Range" + #define TR_CSWSTAY "Stay\0" +#else + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Glue\0" + #if defined(CPUARM) + #define TR_CSWRANGE "Rnge\0" + #define TR_CSWSTAY "Stay\0" + #else + #define TR_CSWRANGE + #define TR_CSWSTAY + #endif +#endif + #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " -#else - #define TR_ROTARY_ENCODERS_VSRCRAW + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW #endif #if defined(HELI) @@ -356,7 +375,7 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif -#define TR_VSRCRAW "---\0""Dir\0""Prf\0""Gaz\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX\0" TR_CYC_VSRCRAW "TrmD" "TrmP" "TrmG" "TrmA" TR_SW_VSRCRAW +#define TR_VSRCRAW "---\0""Dir\0""Prf\0""Gaz\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODER "MAX\0" TR_CYC_VSRCRAW "TrmD" "TrmP" "TrmG" "TrmA" TR_SW_VSRCRAW #define LEN_VTMRMODES "\003" #define TR_VTMRMODES "OFF""ABS""GZs""GZ%""GZt" @@ -713,7 +732,7 @@ // Taranis column headers #define TR_PHASES_HEADERS { " Nom ", " Inter ", " Trims ", " Fondu ON ", " Fondu OFF " } #define TR_LIMITS_HEADERS { " Nom ", " Subtrim ", " Min ", " Max ", " Direction ", " Curve ", " Neutre PPM ", " Mode subtrim " } -#define TR_CSW_HEADERS { " Fonction ", " V1 ", " V2 ", " ET suppl. ", " Durée ", " Délai " } +#define TR_CSW_HEADERS { " Fonction ", " V1 ", " V2 ", " V2 ", " ET suppl. ", " Durée ", " Délai " } //Taranis About screen #define TR_ABOUTUS TR(" A PROPOS ","A PROPOS") @@ -766,7 +785,7 @@ #define TR_CHR_LONG 'l' #define TR_CHR_TOGGLE 't' #define TR_CHR_HOUR 'h' -#define TR_CHR_INPUT 'I' // Values between A-I will work +#define TR_CHR_INPUT 'E' // Values between A-I will work #define TR_BEEP_VOLUME "Beep Volume" #define TR_WAV_VOLUME "Wav Volume" diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index e767bc8f2..88a530fdd 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -150,8 +150,25 @@ #define LEN_VMIXTRIMS "\003" #define TR_VMIXTRIMS "OFF""ON ""Rud""Ele""Thr""Ail" +#if defined(PCBTARANIS) + #define TR_CSWTIMER "Timer" + #define TR_CSWSTICKY "Stcky" + #define TR_CSWRANGE "Range" + #define TR_CSWSTAY "Stay\0" +#else + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Glue\0" + #if defined(CPUARM) + #define TR_CSWRANGE "Rnge\0" + #define TR_CSWSTAY "Stay\0" + #else + #define TR_CSWRANGE + #define TR_CSWSTAY + #endif +#endif + #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a 2 -#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 -#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " + #define TR_ROTARY_ENCODERS "REa\0" + #define TR_ROTENC_SWITCHES "REa" +#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) + #define TR_ROTARY_ENCODERS "REa\0""REb\0" + #define TR_ROTENC_SWITCHES "REa""REb" #else -#define TR_ROTARY_ENCODERS_VSRCRAW + #define TR_ROTARY_ENCODERS + #define TR_ROTENC_SWITCHES +#endif + +#if defined(PCBTARANIS) + #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#elif defined(CPUARM) + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#else + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW #endif #if defined(HELI) @@ -356,7 +375,7 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif -#define TR_VSRCRAW "---\0""Rud\0""Ele\0""Thr\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX\0" TR_CYC_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" TR_SW_VSRCRAW +#define TR_VSRCRAW "---\0""Rud\0""Ele\0""Thr\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" TR_SW_VSRCRAW #define LEN_VTMRMODES "\003" #define TR_VTMRMODES "OFF""ABS""THs""TH%""THt" @@ -713,7 +732,7 @@ // Taranis column headers #define TR_PHASES_HEADERS { " Nome ", " Switch ", " Trims ", " Fade In ", " Fade Out " } #define TR_LIMITS_HEADERS { " Nome ", " Offset ", " Min ", " Max ", " Direzione ", " Curve ", " Centro PPM ", " Simmetria " } -#define TR_CSW_HEADERS { " Funzione ", " V1 ", " V2 ", " AND Switch ", " Durata ", " Ritardo " } +#define TR_CSW_HEADERS { " Funzione ", " V1 ", " V2 ", " V2 ", " AND Switch ", " Durata ", " Ritardo " } //Taranis About screen #define TR_ABOUTUS "Info su" @@ -766,7 +785,7 @@ #define TR_CHR_LONG 'l' #define TR_CHR_TOGGLE 't' #define TR_CHR_HOUR 'h' -#define TR_CHR_INPUT 'I' // Values between A-I will work +#define TR_CHR_INPUT 'I' // Values between A-I will work #define TR_BEEP_VOLUME "Beep Volume" #define TR_WAV_VOLUME "Wav Volume" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 677cdf107..e824ab65f 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -150,8 +150,25 @@ #define LEN_VMIXTRIMS "\004" #define TR_VMIXTRIMS "WYł\0""ZAŁ\0""SK\0 ""SW\0 ""GAZ\0""Lotk" +#if defined(PCBTARANIS) + #define TR_CSWTIMER "Timer" + #define TR_CSWSTICKY "Stcky" + #define TR_CSWRANGE "Range" + #define TR_CSWSTAY "Stay\0" +#else + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Glue\0" + #if defined(CPUARM) + #define TR_CSWRANGE "Rnge\0" + #define TR_CSWSTAY "Stay\0" + #else + #define TR_CSWRANGE + #define TR_CSWSTAY + #endif +#endif + #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " + #define TR_ROTARY_ENCODERS "REa\0" + #define TR_ROTENC_SWITCHES "REa" +#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) + #define TR_ROTARY_ENCODERS "REa\0""REb\0" + #define TR_ROTENC_SWITCHES "REa""REb" #else - #define TR_ROTARY_ENCODERS_VSRCRAW + #define TR_ROTARY_ENCODERS + #define TR_ROTENC_SWITCHES +#endif + +#if defined(PCBTARANIS) + #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#elif defined(CPUARM) + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#else + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW #endif #if defined(HELI) @@ -356,7 +375,7 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif -#define TR_VSRCRAW "---\0""SK\0 ""SW\0 ""Gaz\0""Lotk" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX\0" TR_CYC_VSRCRAW "TrmK" "TrmW" "TrmG" "TrmL" TR_SW_VSRCRAW +#define TR_VSRCRAW "---\0""SK\0 ""SW\0 ""Gaz\0""Lotk" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmK" "TrmW" "TrmG" "TrmL" TR_SW_VSRCRAW #define LEN_VTMRMODES "\003" #define TR_VTMRMODES "WYŁ""ABS""THs""TH%""THt" @@ -713,7 +732,7 @@ // Taranis column headers #define TR_PHASES_HEADERS { " Nazwa ", " Przełącznik ", " Trymery ", " Pojawianie się ", " Zanikanie " } #define TR_LIMITS_HEADERS { " Nazwa ", " Subtrim ", " Min ", " Max ", " Kierunek ", " Krzywa ", " Środek PPM ", " Tryb subtrim " } -#define TR_CSW_HEADERS { " Funkcja ", " Param. 1 ", " Param 2 ", " AND Przełącznik ", " Czas trwania ", " Opóźnienie " } +#define TR_CSW_HEADERS { " Funkcja ", " Param. 1 ", " Param 2 ", " Param 2 ", " AND Przełącznik ", " Czas trwania ", " Opóźnienie " } //Taranis About screen #define TR_ABOUTUS TR(" O ", " O") @@ -766,7 +785,7 @@ #define TR_CHR_LONG 'l' #define TR_CHR_TOGGLE 't' #define TR_CHR_HOUR 'h' -#define TR_CHR_INPUT 'I' // Values between A-I will work +#define TR_CHR_INPUT 'I' // Values between A-I will work #define TR_BEEP_VOLUME "Głośność pikania" #define TR_WAV_VOLUME "Głośność wav" diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 1c722ed02..f2d01b33c 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -150,8 +150,25 @@ #define LEN_VMIXTRIMS "\003" #define TR_VMIXTRIMS "OFF""ON\0""Lem""Pfd""Mot""Ail" +#if defined(PCBTARANIS) + #define TR_CSWTIMER "Timer" + #define TR_CSWSTICKY "Stcky" + #define TR_CSWRANGE "Range" + #define TR_CSWSTAY "Stay\0" +#else + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Glue\0" + #if defined(CPUARM) + #define TR_CSWRANGE "Rnge\0" + #define TR_CSWSTAY "Stay\0" + #else + #define TR_CSWRANGE + #define TR_CSWSTAY + #endif +#endif + #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " + #define TR_ROTARY_ENCODERS "REa\0" + #define TR_ROTENC_SWITCHES "REa" +#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) + #define TR_ROTARY_ENCODERS "REa\0""REb\0" + #define TR_ROTENC_SWITCHES "REa""REb" #else - #define TR_ROTARY_ENCODERS_VSRCRAW + #define TR_ROTARY_ENCODERS + #define TR_ROTENC_SWITCHES +#endif + +#if defined(PCBTARANIS) + #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#elif defined(CPUARM) + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#else + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW #endif #if defined(HELI) @@ -356,7 +375,7 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif -#define TR_VSRCRAW "---\0""Lem\0""Pfd\0""Mot\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX\0" TR_CYC_VSRCRAW "TrmL" "TrmP" "TrmM" "TrmA" TR_SW_VSRCRAW +#define TR_VSRCRAW "---\0""Lem\0""Pfd\0""Mot\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmL" "TrmP" "TrmM" "TrmA" TR_SW_VSRCRAW #define LEN_VTMRMODES "\003" #define TR_VTMRMODES "OFF""ABS""MTs""MT%""MTt" @@ -713,7 +732,7 @@ // Taranis column headers #define TR_PHASES_HEADERS { " Name ", " Switch ", " Trims ", " Fade In ", " Fade Out " } #define TR_LIMITS_HEADERS { " Name ", " Offset ", " Min ", " Max ", " Direction ", " Curve ", " PPM Center ", " Symmetrical " } -#define TR_CSW_HEADERS { " Function ", " V1 ", " V2 ", " AND Switch ", " Duration ", " Delay " } +#define TR_CSW_HEADERS { " Function ", " V1 ", " V2 ", " V2 ", " AND Switch ", " Duration ", " Delay " } //Taranis About screen #define TR_ABOUTUS "ABOUT US" @@ -766,7 +785,7 @@ #define TR_CHR_LONG 'l' #define TR_CHR_TOGGLE 't' #define TR_CHR_HOUR 'h' -#define TR_CHR_INPUT 'I' // Values between A-I will work +#define TR_CHR_INPUT 'I' // Values between A-I will work #define TR_BEEP_VOLUME "Beep Volume" #define TR_WAV_VOLUME "Wav Volume" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index c585a356b..57bf057bd 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -150,8 +150,25 @@ #define LEN_VMIXTRIMS "\003" #define TR_VMIXTRIMS "Av\0""På\0""Rod""Hjd""Gas""Ske" +#if defined(PCBTARANIS) + #define TR_CSWTIMER "Timer" + #define TR_CSWSTICKY "Stcky" + #define TR_CSWRANGE "Range" + #define TR_CSWSTAY "Stay\0" +#else + #define TR_CSWTIMER "Tim\0 " + #define TR_CSWSTICKY "Glue\0" + #if defined(CPUARM) + #define TR_CSWRANGE "Rnge\0" + #define TR_CSWSTAY "Stay\0" + #else + #define TR_CSWRANGE + #define TR_CSWSTAY + #endif +#endif + #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " -#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 - #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " + #define TR_ROTARY_ENCODERS "REa\0" + #define TR_ROTENC_SWITCHES "REa" +#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560) + #define TR_ROTARY_ENCODERS "REa\0""REb\0" + #define TR_ROTENC_SWITCHES "REa""REb" #else - #define TR_ROTARY_ENCODERS_VSRCRAW + #define TR_ROTARY_ENCODERS + #define TR_ROTENC_SWITCHES +#endif + +#if defined(PCBTARANIS) + #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" + #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#elif defined(CPUARM) + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW +#else + #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW #endif #if defined(HELI) @@ -356,7 +375,7 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif -#define TR_VSRCRAW "---\0""Rod\0""Höj\0""Gas\0""Ske\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX " TR_CYC_VSRCRAW "TrmR" "TrmH" "TrmG" "TrmS" TR_SW_VSRCRAW +#define TR_VSRCRAW "---\0""Rod\0""Höj\0""Gas\0""Ske\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODER "MAX " TR_CYC_VSRCRAW "TrmR" "TrmH" "TrmG" "TrmS" TR_SW_VSRCRAW #define LEN_VTMRMODES "\003" #define TR_VTMRMODES "Av\0""ABS""GAs""GA%""GAt" @@ -713,7 +732,7 @@ // Taranis column headers #define TR_PHASES_HEADERS { " Namn ", " Brytare ", " Trimmar ", " Tona Upp ", " Tona Ned " } #define TR_LIMITS_HEADERS { " Namn ", " Offset ", " Min ", " Max ", " Riktning ", " PPM-centrum ", " Symmetriskt " } -#define TR_CSW_HEADERS { " Funktion ", " V1 ", " V2 ", " AND Brytare ", " Tidslängd ", " Fördröj " } +#define TR_CSW_HEADERS { " Funktion ", " V1 ", " V2 ", " V2 ", " AND Brytare ", " Tidslängd ", " Fördröj " } // About screen #define TR_ABOUTUS "Om Oss" From 5f75e5851e2f16831ff8a0ebf5e94f21f6180e89 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Sat, 8 Feb 2014 01:05:54 +0100 Subject: [PATCH 25/28] Rename "Stay" to "Edge" --- radio/src/translations/cz.h.txt | 4 ++-- radio/src/translations/de.h.txt | 4 ++-- radio/src/translations/en.h | 4 ++-- radio/src/translations/es.h.txt | 4 ++-- radio/src/translations/it.h.txt | 4 ++-- radio/src/translations/pl.h.txt | 4 ++-- radio/src/translations/pt.h.txt | 4 ++-- radio/src/translations/se.h.txt | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 9718e7357..2dab10773 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -154,13 +154,13 @@ #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #define TR_CSWRANGE "Range" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWTIMER "Tim\0 " #define TR_CSWSTICKY "Glue\0" #if defined(CPUARM) #define TR_CSWRANGE "Rnge\0" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWRANGE #define TR_CSWSTAY diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index 65d9d91b7..e6097fcaa 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -154,13 +154,13 @@ #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #define TR_CSWRANGE "Range" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWTIMER "Tim\0 " #define TR_CSWSTICKY "Glue\0" #if defined(CPUARM) #define TR_CSWRANGE "Rnge\0" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWRANGE #define TR_CSWSTAY diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index a82ca8b45..6f2777606 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -154,13 +154,13 @@ #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #define TR_CSWRANGE "Range" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWTIMER "Tim\0 " #define TR_CSWSTICKY "Glue\0" #if defined(CPUARM) #define TR_CSWRANGE "Rnge\0" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWRANGE #define TR_CSWSTAY diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index d7a0ff189..b8d954dfb 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -154,13 +154,13 @@ #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #define TR_CSWRANGE "Range" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWTIMER "Tim\0 " #define TR_CSWSTICKY "Glue\0" #if defined(CPUARM) #define TR_CSWRANGE "Rnge\0" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWRANGE #define TR_CSWSTAY diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index 88a530fdd..ec58310d9 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -154,13 +154,13 @@ #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #define TR_CSWRANGE "Range" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWTIMER "Tim\0 " #define TR_CSWSTICKY "Glue\0" #if defined(CPUARM) #define TR_CSWRANGE "Rnge\0" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWRANGE #define TR_CSWSTAY diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index e824ab65f..0a40f2733 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -154,13 +154,13 @@ #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #define TR_CSWRANGE "Range" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWTIMER "Tim\0 " #define TR_CSWSTICKY "Glue\0" #if defined(CPUARM) #define TR_CSWRANGE "Rnge\0" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWRANGE #define TR_CSWSTAY diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index f2d01b33c..f38725a5b 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -154,13 +154,13 @@ #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #define TR_CSWRANGE "Range" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWTIMER "Tim\0 " #define TR_CSWSTICKY "Glue\0" #if defined(CPUARM) #define TR_CSWRANGE "Rnge\0" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWRANGE #define TR_CSWSTAY diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 57bf057bd..3fc70ed7d 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -154,13 +154,13 @@ #define TR_CSWTIMER "Timer" #define TR_CSWSTICKY "Stcky" #define TR_CSWRANGE "Range" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWTIMER "Tim\0 " #define TR_CSWSTICKY "Glue\0" #if defined(CPUARM) #define TR_CSWRANGE "Rnge\0" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWSTAY "Edge\0" #else #define TR_CSWRANGE #define TR_CSWSTAY From 2f437ccad59810b9640c1da975cb4cc3186e7d85 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Sat, 8 Feb 2014 01:06:07 +0100 Subject: [PATCH 26/28] French translations --- radio/src/translations/fr.h.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 7c6e770c8..57a7a9c22 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -151,16 +151,16 @@ #define TR_VMIXTRIMS "OFF""ON\0""Dir""Prf""Gaz""Ail" #if defined(PCBTARANIS) - #define TR_CSWTIMER "Timer" - #define TR_CSWSTICKY "Stcky" - #define TR_CSWRANGE "Range" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWTIMER "Tempo" + #define TR_CSWSTICKY "Bist." + #define TR_CSWRANGE "Plage" + #define TR_CSWSTAY "Flanc" #else - #define TR_CSWTIMER "Tim\0 " - #define TR_CSWSTICKY "Glue\0" + #define TR_CSWTIMER "Temp\0" + #define TR_CSWSTICKY "Bist\0" #if defined(CPUARM) - #define TR_CSWRANGE "Rnge\0" - #define TR_CSWSTAY "Stay\0" + #define TR_CSWRANGE "Zone\0" + #define TR_CSWSTAY "Flnc\0" #else #define TR_CSWRANGE #define TR_CSWSTAY From 08a37b77e71f4f48a71f40958d8a30c04349a5e0 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sat, 8 Feb 2014 08:38:06 +0100 Subject: [PATCH 27/28] Renaming started ... who wants to continue? --- companion/src/comparedialog.cpp | 2 +- companion/src/eeprominterface.cpp | 110 +++++------ companion/src/eeprominterface.h | 72 ++++---- companion/src/firmwares/er9x/er9xeeprom.cpp | 10 +- companion/src/firmwares/er9x/er9xeeprom.h | 10 +- .../src/firmwares/er9x/er9xinterface.cpp | 8 +- .../src/firmwares/ersky9x/ersky9xeeprom.cpp | 20 +- .../src/firmwares/ersky9x/ersky9xeeprom.h | 20 +- .../firmwares/ersky9x/ersky9xinterface.cpp | 14 +- .../src/firmwares/gruvin9x/gruvin9xeeprom.cpp | 10 +- .../src/firmwares/gruvin9x/gruvin9xeeprom.h | 16 +- .../firmwares/gruvin9x/gruvin9xinterface.cpp | 2 +- .../firmwares/opentx/open9xGruvin9xeeprom.cpp | 20 +- .../firmwares/opentx/open9xGruvin9xeeprom.h | 26 +-- .../firmwares/opentx/open9xSky9xeeprom.cpp | 30 +-- .../src/firmwares/opentx/open9xSky9xeeprom.h | 34 ++-- .../firmwares/opentx/open9xStockeeprom.cpp | 20 +- .../src/firmwares/opentx/open9xStockeeprom.h | 36 ++-- .../src/firmwares/opentx/opentxeeprom.cpp | 72 ++++---- .../src/firmwares/opentx/opentxinterface.cpp | 6 +- companion/src/firmwares/th9x/th9xeeprom.cpp | 14 +- companion/src/firmwares/th9x/th9xeeprom.h | 10 +- .../src/firmwares/th9x/th9xinterface.cpp | 2 +- companion/src/helpers.cpp | 52 +++--- companion/src/helpers.h | 2 +- companion/src/modeledit/customswitches.cpp | 84 ++++----- companion/src/modeledit/customswitches.h | 6 +- companion/src/modeledit/modeledit.cpp | 2 +- companion/src/modeledit/templates.cpp | 10 +- companion/src/printdialog.cpp | 2 +- companion/src/simulatordialog.cpp | 2 +- radio/src/eeprom_conversions.cpp | 10 +- radio/src/gtests.cpp | 8 +- radio/src/gui/menu_model.cpp | 174 +++++++++--------- radio/src/gui/menus.cpp | 29 ++- radio/src/gui/menus.h | 5 +- radio/src/myeeprom.h | 64 +++---- radio/src/opentx.cpp | 88 ++++----- radio/src/opentx.h | 30 +-- radio/src/templates.cpp | 8 +- 40 files changed, 577 insertions(+), 563 deletions(-) diff --git a/companion/src/comparedialog.cpp b/companion/src/comparedialog.cpp index 9a50f283c..1309857c4 100644 --- a/companion/src/comparedialog.cpp +++ b/companion/src/comparedialog.cpp @@ -1039,7 +1039,7 @@ void compareDialog::printSwitches() QString str = "
"+tr("LS")+('A'+(i-9))+"
"; str.append(""); str.append("

"+tr("Logical Switches")+"

"); - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { QString sw1 = g_model1->customSw[i].toString(*g_model1); QString sw2 = g_model2->customSw[i].toString(*g_model2); if (!(sw1.isEmpty() && sw2.isEmpty())) { diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 7e838e19f..18379d773 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -335,71 +335,71 @@ QString CurveReference::toString() } } -CSFunctionFamily CustomSwData::getFunctionFamily() +CSFunctionFamily LogicalSwitchData::getFunctionFamily() { - if (func == CS_FN_STAY) - return CS_FAMILY_STAY; - else if (func == CS_FN_TIMER) - return CS_FAMILY_TIMER; - else if (func == CS_FN_STICKY) - return CS_FAMILY_STICKY; - else if (func < CS_FN_AND || func > CS_FN_ELESS) - return CS_FAMILY_VOFS; - else if (func < CS_FN_EQUAL) - return CS_FAMILY_VBOOL; + if (func == LS_FN_STAY) + return LS_FAMILY_STAY; + else if (func == LS_FN_TIMER) + return LS_FAMILY_TIMER; + else if (func == LS_FN_STICKY) + return LS_FAMILY_STICKY; + else if (func < LS_FN_AND || func > LS_FN_ELESS) + return LS_FAMILY_VOFS; + else if (func < LS_FN_EQUAL) + return LS_FAMILY_VBOOL; else - return CS_FAMILY_VCOMP; + return LS_FAMILY_VCOMP; } -QString CustomSwData::funcToString() +QString LogicalSwitchData::funcToString() { switch (func) { - case CS_FN_OFF: + case LS_FN_OFF: return QObject::tr("---"); - case CS_FN_VPOS: + case LS_FN_VPOS: return QObject::tr("a>x"); - case CS_FN_VNEG: + case LS_FN_VNEG: return QObject::tr("ax"); - case CS_FN_ANEG: + case LS_FN_ANEG: return QObject::tr("|a|b"); - case CS_FN_LESS: + case LS_FN_LESS: return QObject::tr("a=b"); - case CS_FN_ELESS: + case LS_FN_ELESS: return QObject::tr("a<=b"); - case CS_FN_DPOS: + case LS_FN_DPOS: return QObject::tr("d>=x"); - case CS_FN_DAPOS: + case LS_FN_DAPOS: return QObject::tr("|d|>=x"); - case CS_FN_VEQUAL: + case LS_FN_VEQUAL: return QObject::tr("a~x"); - case CS_FN_TIMER: + case LS_FN_TIMER: return QObject::tr("Timer"); - case CS_FN_STICKY: + case LS_FN_STICKY: return QObject::tr("Sticky"); - case CS_FN_STAY: + case LS_FN_STAY: return QObject::tr("Stay"); default: return QObject::tr("Unknown"); } } -QString CustomSwData::toString(const ModelData & model) +QString LogicalSwitchData::toString(const ModelData & model) { QString result = ""; @@ -410,16 +410,16 @@ QString CustomSwData::toString(const ModelData & model) result +="( "; } switch (getFunctionFamily()) { - case CS_FAMILY_STAY: + case LS_FAMILY_STAY: result = QObject::tr("STAY(%1, [%2:%3])").arg(RawSwitch(val1).toString()).arg(ValToTim(val2)).arg(ValToTim(val2+val3)); break; - case CS_FAMILY_STICKY: + case LS_FAMILY_STICKY: result = QObject::tr("STICKY(%1, %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString()); break; - case CS_FAMILY_TIMER: + case LS_FAMILY_TIMER: result = QObject::tr("TIMER(%1, %2)").arg(ValToTim(val1)).arg(ValToTim(val2)); break; - case CS_FAMILY_VOFS: { + case LS_FAMILY_VOFS: { RawSource source = RawSource(val1, &model); RawSourceRange range = source.getRange(); if (val1) @@ -427,28 +427,28 @@ QString CustomSwData::toString(const ModelData & model) else result += "0"; result.remove(" "); - if (func == CS_FN_APOS || func == CS_FN_ANEG) + if (func == LS_FN_APOS || func == LS_FN_ANEG) result = "|" + result + "|"; - else if (func == CS_FN_DAPOS) + else if (func == LS_FN_DAPOS) result = "|d(" + result + ")|"; - else if (func == CS_FN_DPOS) result = "d(" + result + ")"; - if (func == CS_FN_APOS || func == CS_FN_VPOS || func == CS_FN_DAPOS || func == CS_FN_DPOS) + else if (func == LS_FN_DPOS) result = "d(" + result + ")"; + if (func == LS_FN_APOS || func == LS_FN_VPOS || func == LS_FN_DAPOS || func == LS_FN_DPOS) result += " > "; - else if (func == CS_FN_ANEG || func == CS_FN_VNEG) + else if (func == LS_FN_ANEG || func == LS_FN_VNEG) result += " < "; result += QString::number(range.step * (val2 /*TODO+ source.getRawOffset(model)*/) + range.offset); break; } - case CS_FAMILY_VBOOL: + case LS_FAMILY_VBOOL: result = RawSwitch(val1).toString(); switch (func) { - case CS_FN_AND: + case LS_FN_AND: result += " AND "; break; - case CS_FN_OR: + case LS_FN_OR: result += " OR "; break; - case CS_FN_XOR: + case LS_FN_XOR: result += " XOR "; break; default: @@ -457,28 +457,28 @@ QString CustomSwData::toString(const ModelData & model) result += RawSwitch(val2).toString(); break; - case CS_FAMILY_VCOMP: + case LS_FAMILY_VCOMP: if (val1) result += RawSource(val1).toString(); else result += "0"; switch (func) { - case CS_FN_EQUAL: + case LS_FN_EQUAL: result += " = "; break; - case CS_FN_NEQUAL: + case LS_FN_NEQUAL: result += " != "; break; - case CS_FN_GREATER: + case LS_FN_GREATER: result += " > "; break; - case CS_FN_LESS: + case LS_FN_LESS: result += " < "; break; - case CS_FN_EGREATER: + case LS_FN_EGREATER: result += " >= "; break; - case CS_FN_ELESS: + case LS_FN_ELESS: result += " <= "; break; default: @@ -496,7 +496,7 @@ QString CustomSwData::toString(const ModelData & model) result += RawSwitch(andsw).toString(); } - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { if (delay) result += QObject::tr(" Delay %1 sec").arg(delay/2.0); if (duration) diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 3f650e6bd..8f78c2d71 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -577,42 +577,42 @@ class MixData { }; enum CSFunction { - CS_FN_OFF, - CS_FN_VPOS, - CS_FN_VNEG, - CS_FN_APOS, - CS_FN_ANEG, - CS_FN_AND, - CS_FN_OR, - CS_FN_XOR, - CS_FN_EQUAL, - CS_FN_NEQUAL, - CS_FN_GREATER, - CS_FN_LESS, - CS_FN_EGREATER, - CS_FN_ELESS, - CS_FN_DPOS, - CS_FN_DAPOS, - CS_FN_VEQUAL, // added at the end to avoid everything renumbered - CS_FN_TIMER, - CS_FN_STICKY, - CS_FN_STAY, - // later ... CS_FN_RANGE, - CS_FN_MAX + LS_FN_OFF, + LS_FN_VPOS, + LS_FN_VNEG, + LS_FN_APOS, + LS_FN_ANEG, + LS_FN_AND, + LS_FN_OR, + LS_FN_XOR, + LS_FN_EQUAL, + LS_FN_NEQUAL, + LS_FN_GREATER, + LS_FN_LESS, + LS_FN_EGREATER, + LS_FN_ELESS, + LS_FN_DPOS, + LS_FN_DAPOS, + LS_FN_VEQUAL, // added at the end to avoid everything renumbered + LS_FN_TIMER, + LS_FN_STICKY, + LS_FN_STAY, + // later ... LS_FN_RANGE, + LS_FN_MAX }; enum CSFunctionFamily { - CS_FAMILY_VOFS, - CS_FAMILY_VBOOL, - CS_FAMILY_VCOMP, - CS_FAMILY_TIMER, - CS_FAMILY_STICKY, - CS_FAMILY_STAY, + LS_FAMILY_VOFS, + LS_FAMILY_VBOOL, + LS_FAMILY_VCOMP, + LS_FAMILY_TIMER, + LS_FAMILY_STICKY, + LS_FAMILY_STAY, }; -class CustomSwData { // Custom Switches data +class LogicalSwitchData { // Custom Switches data public: - CustomSwData(unsigned int func=0) + LogicalSwitchData(unsigned int func=0) { clear(); this->func = func; @@ -624,7 +624,7 @@ class CustomSwData { // Custom Switches data unsigned int delay; unsigned int duration; int andsw; - void clear() { memset(this, 0, sizeof(CustomSwData)); } + void clear() { memset(this, 0, sizeof(LogicalSwitchData)); } CSFunctionFamily getFunctionFamily(); QString funcToString(); QString toString(const ModelData & model); @@ -876,7 +876,7 @@ class ModelData { ExpoData expoData[C9X_MAX_EXPOS]; CurveData curves[C9X_MAX_CURVES]; - CustomSwData customSw[C9X_NUM_CSW]; + LogicalSwitchData customSw[C9X_NUM_CSW]; FuncSwData funcSw[C9X_MAX_CUSTOM_FUNCTIONS]; SwashRingData swashRingData; unsigned int thrTraceSrc; @@ -942,10 +942,10 @@ enum Capability { Pots, Switches, SwitchesPositions, - CustomSwitches, + LogicalSwitches, CustomAndSwitches, HasNegAndSwitches, - CustomSwitchesExt, + LogicalSwitchesExt, RotaryEncoders, Outputs, ChannelsName, @@ -1161,13 +1161,13 @@ inline void applyStickModeToModel(ModelData &model, unsigned int mode) for (int i=0; i= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = er9xToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = er9xToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = er9xToSwitch(v1).toValue(); c9x.val2 = er9xToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/er9x/er9xeeprom.h b/companion/src/firmwares/er9x/er9xeeprom.h index 863f861c8..b43dbe44e 100644 --- a/companion/src/firmwares/er9x/er9xeeprom.h +++ b/companion/src/firmwares/er9x/er9xeeprom.h @@ -154,15 +154,15 @@ PACK(typedef struct t_Er9xMixData { }) Er9xMixData; -PACK(typedef struct t_Er9xCustomSwData { // Custom Switches data +PACK(typedef struct t_Er9xLogicalSwitchData { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func:4; uint8_t andsw:4; - operator CustomSwData(); - t_Er9xCustomSwData() { memset(this, 0, sizeof(t_Er9xCustomSwData)); } -}) Er9xCustomSwData; + operator LogicalSwitchData(); + t_Er9xLogicalSwitchData() { memset(this, 0, sizeof(t_Er9xLogicalSwitchData)); } +}) Er9xLogicalSwitchData; PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data int8_t swtch; @@ -241,7 +241,7 @@ PACK(typedef struct t_Er9xModelData { int8_t trim[4]; int8_t curves5[ER9X_MAX_CURVE5][5]; int8_t curves9[ER9X_MAX_CURVE9][9]; - Er9xCustomSwData customSw[ER9X_NUM_CSW]; + Er9xLogicalSwitchData customSw[ER9X_NUM_CSW]; uint8_t frSkyVoltThreshold ; int8_t tmrModeB; uint8_t numVoice; diff --git a/companion/src/firmwares/er9x/er9xinterface.cpp b/companion/src/firmwares/er9x/er9xinterface.cpp index e2ea68868..d28b472b2 100644 --- a/companion/src/firmwares/er9x/er9xinterface.cpp +++ b/companion/src/firmwares/er9x/er9xinterface.cpp @@ -75,11 +75,11 @@ inline void applyStickModeToModel(Er9xModelData & model, unsigned int mode) for (int i=0; i= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = ersky9xToSource_v10(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = ersky9xToSource_v10(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = er9xToSwitch(v1).toValue(); c9x.val2 = er9xToSwitch(v2).toValue(); } @@ -376,22 +376,22 @@ Ersky9xCustomSwData_v10::operator CustomSwData () return c9x; } -Ersky9xCustomSwData_v11::operator CustomSwData () +Ersky9xLogicalSwitchData_v11::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = ersky9xToSource_v11(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = ersky9xToSource_v11(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = er9xToSwitch(v1).toValue(); c9x.val2 = er9xToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/ersky9x/ersky9xeeprom.h b/companion/src/firmwares/ersky9x/ersky9xeeprom.h index e92a48983..cf7a3d0f2 100644 --- a/companion/src/firmwares/ersky9x/ersky9xeeprom.h +++ b/companion/src/firmwares/ersky9x/ersky9xeeprom.h @@ -185,25 +185,25 @@ PACK(typedef struct t_Ersky9xMixData_v11 { t_Ersky9xMixData_v11(); }) Ersky9xMixData_v11; -PACK(typedef struct t_Ersky9xCustomSwData_v10 { // Custom Switches data +PACK(typedef struct t_Ersky9xLogicalSwitchData_v10 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Ersky9xCustomSwData_v10() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v10)); } -}) Ersky9xCustomSwData_v10; + operator LogicalSwitchData(); + t_Ersky9xLogicalSwitchData_v10() { memset(this, 0, sizeof(t_Ersky9xLogicalSwitchData_v10)); } +}) Ersky9xLogicalSwitchData_v10; -PACK(typedef struct t_Ersky9xCustomSwData_v11 { // Custom Switches data +PACK(typedef struct t_Ersky9xLogicalSwitchData_v11 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; uint8_t andsw; uint8_t res ; - operator CustomSwData(); - t_Ersky9xCustomSwData_v11() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v11)); } -}) Ersky9xCustomSwData_v11; + operator LogicalSwitchData(); + t_Ersky9xLogicalSwitchData_v11() { memset(this, 0, sizeof(t_Ersky9xLogicalSwitchData_v11)); } +}) Ersky9xLogicalSwitchData_v11; PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data int8_t swtch; @@ -360,7 +360,7 @@ PACK(typedef struct t_Ersky9xModelData_v10 { int8_t trim[4]; int8_t curves5[ERSKY9X_MAX_CURVE5][5]; int8_t curves9[ERSKY9X_MAX_CURVE9][9]; - Ersky9xCustomSwData_v10 customSw[ERSKY9X_NUM_CSW_V10]; + Ersky9xLogicalSwitchData_v10 customSw[ERSKY9X_NUM_CSW_V10]; uint8_t frSkyVoltThreshold ; uint8_t res3[2]; Ersky9xSafetySwData_v10 safetySw[ERSKY9X_NUM_CHNOUT_V10]; @@ -409,7 +409,7 @@ PACK(typedef struct t_Ersky9xModelData_v11 { int8_t curves5[ERSKY9X_MAX_CURVE5][5]; int8_t curves9[ERSKY9X_MAX_CURVE9][9]; int8_t curvexy[18]; - Ersky9xCustomSwData_v11 customSw[ERSKY9X_NUM_CSW_V11]; + Ersky9xLogicalSwitchData_v11 customSw[ERSKY9X_NUM_CSW_V11]; uint8_t frSkyVoltThreshold ; uint8_t bt_telemetry; uint8_t numVoice; // 0-16, rest are Safety switches diff --git a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp index 28d97d068..dd65c0c92 100644 --- a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp @@ -74,11 +74,11 @@ inline void applyStickModeToModel(Ersky9xModelData_v10 & model, unsigned int mod for (int i=0; i= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = gruvin9xToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = gruvin9xToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = gruvin9xToSwitch(v1).toValue(); c9x.val2 = gruvin9xToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.h b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.h index 3fd51268e..8886c83d1 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.h +++ b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.h @@ -186,14 +186,14 @@ PACK(typedef struct t_Gruvin9xMixData { t_Gruvin9xMixData(); }) Gruvin9xMixData; -PACK(typedef struct t_Gruvin9xCustomSwData { // Custom Switches data +PACK(typedef struct t_Gruvin9xLogicalSwitchData { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Gruvin9xCustomSwData() { memset(this, 0, sizeof(t_Gruvin9xCustomSwData)); } -}) Gruvin9xCustomSwData; + operator LogicalSwitchData(); + t_Gruvin9xLogicalSwitchData() { memset(this, 0, sizeof(t_Gruvin9xLogicalSwitchData)); } +}) Gruvin9xLogicalSwitchData; PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data int8_t swtch; @@ -309,7 +309,7 @@ PACK(typedef struct t_Gruvin9xModelData_v102 { Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves9[G9X_MAX_CURVE9][9]; - Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; + Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xSwashRingData swashR; Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES]; @@ -341,7 +341,7 @@ PACK(typedef struct t_Gruvin9xModelData_v103 { Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves9[G9X_MAX_CURVE9][9]; - Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; + Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xSwashRingData swashR; Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES]; @@ -373,7 +373,7 @@ PACK(typedef struct t_Gruvin9xModelData_v105 { Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves9[G9X_MAX_CURVE9][9]; - Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; + Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xFuncSwData funcSw[G9X_NUM_FSW]; Gruvin9xSwashRingData swashR; @@ -405,7 +405,7 @@ PACK(typedef struct t_Gruvin9xModelData_v106 { Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves9[G9X_MAX_CURVE9][9]; - Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; + Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xFuncSwData funcSw[G9X_NUM_FSW]; Gruvin9xSwashRingData swashR; diff --git a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp index 3e60d61be..c3d52923f 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp +++ b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp @@ -237,7 +237,7 @@ int Gruvin9xInterface::getCapability(const Capability capability) return 9; case CustomFunctions: return 12; - case CustomSwitches: + case LogicalSwitches: return 12; case CSFunc: return 13; diff --git a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp index 20bd50453..6ec5f402d 100644 --- a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp @@ -293,22 +293,22 @@ RawSource open9xV4209ToSource(int8_t value) } } -Open9xGruvin9xCustomSwData_v207::operator CustomSwData () +Open9xGruvin9xLogicalSwitchData_v207::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xV4207ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = open9xV4207ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } @@ -316,22 +316,22 @@ Open9xGruvin9xCustomSwData_v207::operator CustomSwData () return c9x; } -Open9xGruvin9xCustomSwData_v209::operator CustomSwData () +Open9xGruvin9xLogicalSwitchData_v209::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xV4209ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) { + if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) { c9x.val2 = open9xV4209ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.h b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.h index c95dc6742..214e2ef6d 100644 --- a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.h +++ b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.h @@ -110,27 +110,27 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v211 { t_Open9xGruvin9xMixData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v211)); } }) Open9xGruvin9xMixData_v211; -PACK(typedef struct t_Open9xGruvin9xCustomSwData_v207 { // Custom Switches data +PACK(typedef struct t_Open9xGruvin9xLogicalSwitchData_v207 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xGruvin9xCustomSwData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v207)); } + operator LogicalSwitchData(); + t_Open9xGruvin9xLogicalSwitchData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xLogicalSwitchData_v207)); } int8_t fromSource(RawSource source); RawSource toSource(int8_t value); -}) Open9xGruvin9xCustomSwData_v207; +}) Open9xGruvin9xLogicalSwitchData_v207; -PACK(typedef struct t_Open9xGruvin9xCustomSwData_v209 { // Custom Switches data +PACK(typedef struct t_Open9xGruvin9xLogicalSwitchData_v209 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xGruvin9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v209)); } + operator LogicalSwitchData(); + t_Open9xGruvin9xLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xLogicalSwitchData_v209)); } int8_t fromSource(RawSource source); RawSource toSource(int8_t value); -}) Open9xGruvin9xCustomSwData_v209; +}) Open9xGruvin9xLogicalSwitchData_v209; PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data int8_t swtch; // input @@ -194,7 +194,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v207 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v207 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v208 swashR; Open9xGruvin9xPhaseData_v207 phaseData[O9X_MAX_PHASES]; @@ -228,7 +228,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v208 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v207 customSw[O9X_NUM_CSW]; Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v208 swashR; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; @@ -267,7 +267,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v209 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v209 swashR; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; @@ -307,7 +307,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v210 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves[O9X_MAX_CURVES]; int8_t points[O9X_NUM_POINTS]; - Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v209 swashR; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; @@ -345,7 +345,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v211 { Open9xExpoData_v211 expoData[O9X_MAX_EXPOS]; int8_t curves[O9X_MAX_CURVES]; int8_t points[O9X_NUM_POINTS]; - Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v209 swashR; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; diff --git a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp index 393833cc4..01a7a01b2 100644 --- a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp @@ -501,22 +501,22 @@ t_Open9xArmMixData_v212::operator MixData () return c9x; } -t_Open9xArmCustomSwData_v208::operator CustomSwData () +t_Open9xArmLogicalSwitchData_v208::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xArm208ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = open9xArm208ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xArmToSwitch(v1).toValue(); c9x.val2 = open9xArmToSwitch(v2).toValue(); } @@ -524,22 +524,22 @@ t_Open9xArmCustomSwData_v208::operator CustomSwData () return c9x; } -t_Open9xArmCustomSwData_v209::operator CustomSwData () +t_Open9xArmLogicalSwitchData_v209::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xArm209ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = open9xArm209ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xArmToSwitch(v1).toValue(); c9x.val2 = open9xArmToSwitch(v2).toValue(); } @@ -547,24 +547,24 @@ t_Open9xArmCustomSwData_v209::operator CustomSwData () return c9x; } -t_Open9xArmCustomSwData_v210::operator CustomSwData () +t_Open9xArmLogicalSwitchData_v210::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; c9x.delay = delay; c9x.duration = duration; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xArm210ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) { + if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) { c9x.val2 = open9xArm210ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xArmToSwitch(v1).toValue(); c9x.val2 = open9xArmToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/opentx/open9xSky9xeeprom.h b/companion/src/firmwares/opentx/open9xSky9xeeprom.h index b313169b8..fdb3974ee 100644 --- a/companion/src/firmwares/opentx/open9xSky9xeeprom.h +++ b/companion/src/firmwares/opentx/open9xSky9xeeprom.h @@ -190,34 +190,34 @@ PACK(typedef struct t_Open9xArmPhaseData_v212 { t_Open9xArmPhaseData_v212() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v212)); } }) Open9xArmPhaseData_v212; -PACK(typedef struct t_Open9xArmCustomSwData_v208 { // Custom Switches data +PACK(typedef struct t_Open9xArmLogicalSwitchData_v208 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xArmCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v208)); } -}) Open9xArmCustomSwData_v208; + operator LogicalSwitchData(); + t_Open9xArmLogicalSwitchData_v208() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v208)); } +}) Open9xArmLogicalSwitchData_v208; -PACK(typedef struct t_Open9xArmCustomSwData_v209 { // Custom Switches data +PACK(typedef struct t_Open9xArmLogicalSwitchData_v209 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xArmCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v209)); } -}) Open9xArmCustomSwData_v209; + operator LogicalSwitchData(); + t_Open9xArmLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v209)); } +}) Open9xArmLogicalSwitchData_v209; -PACK(typedef struct t_Open9xArmCustomSwData_v210 { // Custom Switches data +PACK(typedef struct t_Open9xArmLogicalSwitchData_v210 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; uint8_t delay; uint8_t duration; - operator CustomSwData(); - t_Open9xArmCustomSwData_v210() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v210)); } -}) Open9xArmCustomSwData_v210; + operator LogicalSwitchData(); + t_Open9xArmLogicalSwitchData_v210() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v210)); } +}) Open9xArmLogicalSwitchData_v210; PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data int8_t swtch; // input @@ -343,7 +343,7 @@ PACK(typedef struct t_Open9xArmModelData_v208 { Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xArmCustomSwData_v208 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v208 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v208 swashR; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; @@ -382,7 +382,7 @@ PACK(typedef struct t_Open9xArmModelData_v209 { Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xArmCustomSwData_v209 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v209 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v209 swashR; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; @@ -422,7 +422,7 @@ PACK(typedef struct t_Open9xArmModelData_v210 { Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v210 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v209 swashR; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; @@ -461,7 +461,7 @@ PACK(typedef struct t_Open9xArmModelData_v211 { Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS]; int16_t curves[O9X_ARM_MAX_CURVES]; int8_t points[O9X_ARM_NUM_POINTS]; - Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v209 swashR; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; @@ -499,7 +499,7 @@ PACK(typedef struct t_Open9xArmModelData_v212 { Open9xArmExpoData_v212 expoData[O9X_ARM_MAX_EXPOS]; int16_t curves[O9X_ARM_MAX_CURVES]; int8_t points[O9X_ARM_NUM_POINTS]; - Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v210 swashR; Open9xArmPhaseData_v212 phaseData[O9X_ARM_MAX_PHASES]; diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.cpp b/companion/src/firmwares/opentx/open9xStockeeprom.cpp index 0e6e010b6..73cb22164 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xStockeeprom.cpp @@ -518,22 +518,22 @@ RawSource open9xStock209ToSource(int8_t value) } } -Open9xCustomSwData_v208::operator CustomSwData () +Open9xLogicalSwitchData_v208::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9x208ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = open9x208ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } @@ -541,22 +541,22 @@ Open9xCustomSwData_v208::operator CustomSwData () return c9x; } -Open9xCustomSwData_v209::operator CustomSwData () +Open9xLogicalSwitchData_v209::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xStock209ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) { + if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) { c9x.val2 = open9xStock209ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.h b/companion/src/firmwares/opentx/open9xStockeeprom.h index 972467308..8f121441e 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.h +++ b/companion/src/firmwares/opentx/open9xStockeeprom.h @@ -221,24 +221,24 @@ PACK(typedef struct t_Open9xMixData_v211 { t_Open9xMixData_v211() { memset(this, 0, sizeof(t_Open9xMixData_v211)); } }) Open9xMixData_v211; -PACK(typedef struct t_Open9xCustomSwData_v208 { // Custom Switches data +PACK(typedef struct t_Open9xLogicalSwitchData_v208 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xCustomSwData_v208)); } - t_Open9xCustomSwData_v208(CustomSwData&); -}) Open9xCustomSwData_v208; + operator LogicalSwitchData(); + t_Open9xLogicalSwitchData_v208() { memset(this, 0, sizeof(t_Open9xLogicalSwitchData_v208)); } + t_Open9xLogicalSwitchData_v208(LogicalSwitchData&); +}) Open9xLogicalSwitchData_v208; -PACK(typedef struct t_Open9xCustomSwData_v209 { // Custom Switches data +PACK(typedef struct t_Open9xLogicalSwitchData_v209 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xCustomSwData_v209)); } -}) Open9xCustomSwData_v209; + operator LogicalSwitchData(); + t_Open9xLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xLogicalSwitchData_v209)); } +}) Open9xLogicalSwitchData_v209; PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data int8_t swtch; @@ -516,7 +516,7 @@ PACK(typedef struct t_Open9xModelData_v201 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xSafetySwData safetySw[O9X_NUM_CHNOUT]; Open9xFuncSwData_v201 funcSw[12]; Open9xSwashRingData_v208 swashR; @@ -547,7 +547,7 @@ PACK(typedef struct t_Open9xModelData_v202 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xSafetySwData safetySw[O9X_NUM_CHNOUT]; Open9xFuncSwData_v201 funcSw[12]; Open9xSwashRingData_v208 swashR; @@ -581,7 +581,7 @@ PACK(typedef struct t_Open9xModelData_v203 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v208 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -614,7 +614,7 @@ PACK(typedef struct t_Open9xModelData_v204 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v208 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -647,7 +647,7 @@ PACK(typedef struct t_Open9xModelData_v205 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v208 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -682,7 +682,7 @@ PACK(typedef struct t_Open9xModelData_v208 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v208 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -721,7 +721,7 @@ PACK(typedef struct t_Open9xModelData_v209 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v209 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -761,7 +761,7 @@ PACK(typedef struct t_Open9xModelData_v210 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves[O9X_MAX_CURVES]; int8_t points[O9X_NUM_POINTS]; - Open9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v209 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -799,7 +799,7 @@ PACK(typedef struct t_Open9xModelData_v211 { Open9xExpoData_v211 expoData[O9X_MAX_EXPOS]; int8_t curves[O9X_MAX_CURVES]; int8_t points[O9X_NUM_POINTS]; - Open9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v209 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 53376a354..e0365487b 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1045,39 +1045,39 @@ class CurvesField: public TransformedField { int _points[C9X_MAX_CURVES*C9X_MAX_POINTS*2]; }; -class CustomSwitchesFunctionsTable: public ConversionTable { +class LogicalSwitchesFunctionsTable: public ConversionTable { public: - CustomSwitchesFunctionsTable(BoardEnum board, unsigned int version) + LogicalSwitchesFunctionsTable(BoardEnum board, unsigned int version) { int val=0; bool release21March2013 = IS_RELEASE_21_MARCH_2013(board, version); - addConversion(CS_FN_OFF, val++); + addConversion(LS_FN_OFF, val++); if (release21March2013) - addConversion(CS_FN_VEQUAL, val++); - addConversion(CS_FN_VPOS, val++); - addConversion(CS_FN_VNEG, val++); + addConversion(LS_FN_VEQUAL, val++); + addConversion(LS_FN_VPOS, val++); + addConversion(LS_FN_VNEG, val++); if (IS_ARM(board) && version >= 216) val++; // later RANGE - addConversion(CS_FN_APOS, val++); - addConversion(CS_FN_ANEG, val++); - addConversion(CS_FN_AND, val++); - addConversion(CS_FN_OR, val++); - addConversion(CS_FN_XOR, val++); - if (IS_ARM(board) && version >= 216) addConversion(CS_FN_STAY, val++); - addConversion(CS_FN_EQUAL, val++); + addConversion(LS_FN_APOS, val++); + addConversion(LS_FN_ANEG, val++); + addConversion(LS_FN_AND, val++); + addConversion(LS_FN_OR, val++); + addConversion(LS_FN_XOR, val++); + if (IS_ARM(board) && version >= 216) addConversion(LS_FN_STAY, val++); + addConversion(LS_FN_EQUAL, val++); if (!release21March2013) - addConversion(CS_FN_NEQUAL, val++); - addConversion(CS_FN_GREATER, val++); - addConversion(CS_FN_LESS, val++); + addConversion(LS_FN_NEQUAL, val++); + addConversion(LS_FN_GREATER, val++); + addConversion(LS_FN_LESS, val++); if (!release21March2013) { - addConversion(CS_FN_EGREATER, val++); - addConversion(CS_FN_ELESS, val++); + addConversion(LS_FN_EGREATER, val++); + addConversion(LS_FN_ELESS, val++); } - addConversion(CS_FN_DPOS, val++); - addConversion(CS_FN_DAPOS, val++); - addConversion(CS_FN_TIMER, val++); + addConversion(LS_FN_DPOS, val++); + addConversion(LS_FN_DAPOS, val++); + addConversion(LS_FN_TIMER, val++); if (version >= 216) - addConversion(CS_FN_STICKY, val++); + addConversion(LS_FN_STICKY, val++); } }; @@ -1153,11 +1153,11 @@ class AndSwitchesConversionTable: public ConversionTable { } }; -class CustomSwitchField: public TransformedField { +class LogicalSwitchField: public TransformedField { public: - CustomSwitchField(CustomSwData & csw, BoardEnum board, unsigned int version, unsigned int variant): + LogicalSwitchField(LogicalSwitchData & csw, BoardEnum board, unsigned int version, unsigned int variant): TransformedField(internalField), - internalField("CustomSwitch"), + internalField("LogicalSwitch"), csw(csw), board(board), version(version), @@ -1202,21 +1202,21 @@ class CustomSwitchField: public TransformedField { virtual void beforeExport() { - if (csw.func == CS_FN_STAY) { + if (csw.func == LS_FN_STAY) { switchesConversionTable->exportValue(csw.val1, v1); v2 = csw.val2; v3 = csw.val3; } - else if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { + else if ((csw.func >= LS_FN_AND && csw.func <= LS_FN_XOR) || csw.func == LS_FN_STICKY) { switchesConversionTable->exportValue(csw.val1, v1); switchesConversionTable->exportValue(csw.val2, v2); } - else if (csw.func >= CS_FN_EQUAL && csw.func <= CS_FN_ELESS) { + else if (csw.func >= LS_FN_EQUAL && csw.func <= LS_FN_ELESS) { sourcesConversionTable->exportValue(csw.val1, v1); sourcesConversionTable->exportValue(csw.val2, v2); } else { - if ((csw.func >= CS_FN_VPOS && csw.func <= CS_FN_ANEG) || (csw.func >= CS_FN_EQUAL && csw.func!=CS_FN_TIMER)) + if ((csw.func >= LS_FN_VPOS && csw.func <= LS_FN_ANEG) || (csw.func >= LS_FN_EQUAL && csw.func!=LS_FN_TIMER)) sourcesConversionTable->exportValue(csw.val1, v1); else v1 = csw.val1; @@ -1226,21 +1226,21 @@ class CustomSwitchField: public TransformedField { virtual void afterImport() { - if (csw.func == CS_FN_STAY) { + if (csw.func == LS_FN_STAY) { switchesConversionTable->importValue(v1, csw.val1); csw.val2 = v2; csw.val3 = v3; } - else if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { + else if ((csw.func >= LS_FN_AND && csw.func <= LS_FN_XOR) || csw.func == LS_FN_STICKY) { switchesConversionTable->importValue(v1, csw.val1); switchesConversionTable->importValue(v2, csw.val2); } - else if (csw.func >= CS_FN_EQUAL && csw.func <= CS_FN_ELESS) { + else if (csw.func >= LS_FN_EQUAL && csw.func <= LS_FN_ELESS) { sourcesConversionTable->importValue(v1, csw.val1); sourcesConversionTable->importValue(v2, csw.val2); } else { - if ((csw.func >= CS_FN_VPOS && csw.func <= CS_FN_ANEG) || (csw.func >= CS_FN_EQUAL && csw.func!=CS_FN_TIMER)) + if ((csw.func >= LS_FN_VPOS && csw.func <= LS_FN_ANEG) || (csw.func >= LS_FN_EQUAL && csw.func!=LS_FN_TIMER)) sourcesConversionTable->importValue(v1, csw.val1); else csw.val1 = v1; @@ -1250,11 +1250,11 @@ class CustomSwitchField: public TransformedField { protected: StructField internalField; - CustomSwData & csw; + LogicalSwitchData & csw; BoardEnum board; unsigned int version; unsigned int variant; - CustomSwitchesFunctionsTable functionsConversionTable; + LogicalSwitchesFunctionsTable functionsConversionTable; SourcesConversionTable * sourcesConversionTable; SwitchesConversionTable * switchesConversionTable; ConversionTable * andswitchesConversionTable; @@ -2087,7 +2087,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u internalField.Append(new ExpoField(modelData.expoData[i], board, version)); internalField.Append(new CurvesField(modelData.curves, board, version)); for (int i=0; i= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = toSource(val1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = toSource(val2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = th9xToSwitch(val1).toValue(); c9x.val2 = th9xToSwitch(val2).toValue(); } @@ -192,7 +192,7 @@ t_Th9xCustomSwData::operator CustomSwData () return c9x; } -int8_t t_Th9xCustomSwData::fromSource(RawSource source) +int8_t t_Th9xLogicalSwitchData::fromSource(RawSource source) { int v1 = 0; if (source.type == SOURCE_TYPE_STICK) @@ -216,7 +216,7 @@ int8_t t_Th9xCustomSwData::fromSource(RawSource source) return v1; } -RawSource t_Th9xCustomSwData::toSource(int8_t value) +RawSource t_Th9xLogicalSwitchData::toSource(int8_t value) { if (value == 0) { return RawSource(SOURCE_TYPE_NONE); diff --git a/companion/src/firmwares/th9x/th9xeeprom.h b/companion/src/firmwares/th9x/th9xeeprom.h index 294a33a0c..467b09c68 100644 --- a/companion/src/firmwares/th9x/th9xeeprom.h +++ b/companion/src/firmwares/th9x/th9xeeprom.h @@ -138,18 +138,18 @@ PACK(typedef struct t_Th9xMixData { t_Th9xMixData(); }) Th9xMixData; -PACK(typedef struct t_Th9xCustomSwData { +PACK(typedef struct t_Th9xLogicalSwitchData { uint8_t sw:3; // 0..7 uint8_t opCmp:2; // < & | ^ uint8_t opRes:3; // 0 => 1=> 0=> !=> & | ^ int8_t val1; int8_t val2; - operator CustomSwData(); - t_Th9xCustomSwData() { memset(this, 0, sizeof(t_Th9xCustomSwData)); } + operator LogicalSwitchData(); + t_Th9xLogicalSwitchData() { memset(this, 0, sizeof(t_Th9xLogicalSwitchData)); } int8_t fromSource(RawSource source); RawSource toSource(int8_t value); -}) Th9xCustomSwData; +}) Th9xLogicalSwitchData; PACK(typedef struct t_Th9xTrimData { int8_t itrim:6; //trim index @@ -173,7 +173,7 @@ PACK(typedef struct t_Th9xModelData { int8_t curves3[TH9X_MAX_CURVES3][3]; // 9 new143 int8_t curves5[TH9X_MAX_CURVES5][5]; // 10 int8_t curves9[TH9X_MAX_CURVES9][9]; // 18 - Th9xCustomSwData switchTab[TH9X_MAX_SWITCHES];// + Th9xLogicalSwitchData switchTab[TH9X_MAX_SWITCHES];// Th9xTrimData trimData[NUM_STICKS]; // 3*4 -> 1*4 operator ModelData(); t_Th9xModelData(); diff --git a/companion/src/firmwares/th9x/th9xinterface.cpp b/companion/src/firmwares/th9x/th9xinterface.cpp index 9bd0cbc4a..8e3e36ab6 100644 --- a/companion/src/firmwares/th9x/th9xinterface.cpp +++ b/companion/src/firmwares/th9x/th9xinterface.cpp @@ -157,7 +157,7 @@ int Th9xInterface::getCapability(const Capability capability) return 9; case CustomFunctions: return 0; - case CustomSwitches: + case LogicalSwitches: return TH9X_MAX_SWITCHES; case Outputs: return 8; diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 0a648bb0f..d12d900cf 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -407,7 +407,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr) if (item == value) b->setCurrentIndex(b->count()-1); } - for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) { + for (int i=-GetEepromInterface()->getCapability(LogicalSwitches); i<0; i++) { item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); @@ -474,7 +474,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr) if (item == value) b->setCurrentIndex(b->count()-1); } - for (int i=1; i<=GetEepromInterface()->getCapability(CustomSwitches); i++) { + for (int i=1; i<=GetEepromInterface()->getCapability(LogicalSwitches); i++) { item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); @@ -582,7 +582,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (item == source) b->setCurrentIndex(b->count()-1); } - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { item = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, i); b->addItem(item.toString(), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); @@ -656,33 +656,33 @@ int TimToVal(float value) void populateCSWCB(QComboBox *b, int value) { int order[] = { - CS_FN_OFF, - CS_FN_VEQUAL, // added at the end to avoid everything renumbered - CS_FN_VPOS, - CS_FN_VNEG, - // CS_FN_RANGE, - CS_FN_APOS, - CS_FN_ANEG, - CS_FN_AND, - CS_FN_OR, - CS_FN_XOR, - CS_FN_STAY, - CS_FN_EQUAL, - CS_FN_NEQUAL, - CS_FN_GREATER, - CS_FN_LESS, - CS_FN_EGREATER, - CS_FN_ELESS, - CS_FN_DPOS, - CS_FN_DAPOS, - CS_FN_TIMER, - CS_FN_STICKY + LS_FN_OFF, + LS_FN_VEQUAL, // added at the end to avoid everything renumbered + LS_FN_VPOS, + LS_FN_VNEG, + // LS_FN_RANGE, + LS_FN_APOS, + LS_FN_ANEG, + LS_FN_AND, + LS_FN_OR, + LS_FN_XOR, + LS_FN_STAY, + LS_FN_EQUAL, + LS_FN_NEQUAL, + LS_FN_GREATER, + LS_FN_LESS, + LS_FN_EGREATER, + LS_FN_ELESS, + LS_FN_DPOS, + LS_FN_DAPOS, + LS_FN_TIMER, + LS_FN_STICKY }; b->clear(); - for (int i=0; iaddItem(CustomSwData(func).funcToString(), func); + b->addItem(LogicalSwitchData(func).funcToString(), func); // if (i>GetEepromInterface()->getCapability(CSFunc)) { // QModelIndex index = b->model()->index(i, 0); // QVariant v(0); diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 4c742faad..ad22a4e7c 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -4,7 +4,7 @@ #include #include "eeprominterface.h" -#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(CustomSwitches)-1) +#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(LogicalSwitches)-1) //convert from mode 1 to mode generalSettings.stickMode //NOTICE! => 1..4 -> 1..4 diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp index 72c9404f0..cf02f4430 100644 --- a/companion/src/modeledit/customswitches.cpp +++ b/companion/src/modeledit/customswitches.cpp @@ -7,7 +7,7 @@ #include #include "helpers.h" -CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): +LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model): ModelPanel(parent, model), selectedSwitch(0) { @@ -18,13 +18,13 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): addLabel(gridLayout, tr("V1"), col++); addLabel(gridLayout, tr("V2"), col++); addLabel(gridLayout, tr("AND"), col++); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { addLabel(gridLayout, tr("Duration"), col++); addLabel(gridLayout, tr("Delay"), col++); } lock = true; - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { // The label QLabel * label = new QLabel(this); label->setProperty("index", i); @@ -81,7 +81,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int))); gridLayout->addWidget(cswitchAnd[i], i+1, 4); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { // Duration cswitchDuration[i] = new QDoubleSpinBox(this); cswitchDuration[i]->setProperty("index", i); @@ -109,19 +109,19 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): lock = false; } -CustomSwitchesPanel::~CustomSwitchesPanel() +LogicalSwitchesPanel::~LogicalSwitchesPanel() { } -void CustomSwitchesPanel::v1Edited(int value) +void LogicalSwitchesPanel::v1Edited(int value) { if (!lock) { int i = sender()->property("index").toInt(); model.customSw[i].val1 = cswitchSource1[i]->itemData(value).toInt(); - if (model.customSw[i].getFunctionFamily() == CS_FAMILY_VOFS) { + if (model.customSw[i].getFunctionFamily() == LS_FAMILY_VOFS) { RawSource source = RawSource(model.customSw[i].val1, &model); if (source.type == SOURCE_TYPE_TELEMETRY) { - if (model.customSw[i].func > CS_FN_ELESS && model.customSw[i].func < CS_FN_VEQUAL) { + if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) { model.customSw[i].val2 = 0; } else { @@ -130,7 +130,7 @@ void CustomSwitchesPanel::v1Edited(int value) } else { RawSourceRange range = source.getRange(); - if (model.customSw[i].func > CS_FN_ELESS && model.customSw[i].func < CS_FN_VEQUAL) { + if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) { model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step); } else { @@ -143,7 +143,7 @@ void CustomSwitchesPanel::v1Edited(int value) } } -void CustomSwitchesPanel::v2Edited(int value) +void LogicalSwitchesPanel::v2Edited(int value) { if (!lock) { int i = sender()->property("index").toInt(); @@ -152,7 +152,7 @@ void CustomSwitchesPanel::v2Edited(int value) } } -void CustomSwitchesPanel::andEdited(int value) +void LogicalSwitchesPanel::andEdited(int value) { if (!lock) { int index = sender()->property("index").toInt(); @@ -161,34 +161,34 @@ void CustomSwitchesPanel::andEdited(int value) } } -void CustomSwitchesPanel::durationEdited(double duration) +void LogicalSwitchesPanel::durationEdited(double duration) { int index = sender()->property("index").toInt(); model.customSw[index].duration = (uint8_t)round(duration*2); emit modified(); } -void CustomSwitchesPanel::delayEdited(double delay) +void LogicalSwitchesPanel::delayEdited(double delay) { int index = sender()->property("index").toInt(); model.customSw[index].delay = (uint8_t)round(delay*2); emit modified(); } -void CustomSwitchesPanel::edited() +void LogicalSwitchesPanel::edited() { if (!lock) { lock = true; int i = sender()->property("index").toInt(); int newFunc = csw[i]->itemData(csw[i]->currentIndex()).toInt(); - bool chAr = (model.customSw[i].getFunctionFamily() != CustomSwData(newFunc).getFunctionFamily()); + bool chAr = (model.customSw[i].getFunctionFamily() != LogicalSwitchData(newFunc).getFunctionFamily()); model.customSw[i].func = newFunc; if (chAr) { - if (model.customSw[i].getFunctionFamily() == CS_FAMILY_TIMER) { + if (model.customSw[i].getFunctionFamily() == LS_FAMILY_TIMER) { model.customSw[i].val1 = -119; model.customSw[i].val2 = -119; } - else if (model.customSw[i].getFunctionFamily() == CS_FAMILY_STAY) { + else if (model.customSw[i].getFunctionFamily() == LS_FAMILY_STAY) { model.customSw[i].val1 = 0; model.customSw[i].val2 = -129; model.customSw[i].val3 = 0; @@ -204,11 +204,11 @@ void CustomSwitchesPanel::edited() RawSource source; switch (model.customSw[i].getFunctionFamily()) { - case CS_FAMILY_VOFS: + case LS_FAMILY_VOFS: { source = RawSource(model.customSw[i].val1, &model); RawSourceRange range = source.getRange(); - if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcLS_FN_ELESS && model.customSw[i].funcvalue() / range.step); cswitchOffset[i]->setValue(model.customSw[i].val2*range.step); } @@ -218,13 +218,13 @@ void CustomSwitchesPanel::edited() } } break; - case CS_FAMILY_TIMER: + case LS_FAMILY_TIMER: model.customSw[i].val1 = TimToVal(cswitchValue[i]->value()); model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value()); updateTimerParam(cswitchValue[i], model.customSw[i].val1); updateTimerParam(cswitchOffset[i], model.customSw[i].val2); break; - case CS_FAMILY_STAY: + case LS_FAMILY_STAY: model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value()); updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true); break; @@ -236,7 +236,7 @@ void CustomSwitchesPanel::edited() } } -void CustomSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero) +void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero) { sb->setVisible(true); sb->setDecimals(1); @@ -252,7 +252,7 @@ void CustomSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool a sb->setValue(value); } -void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) +void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i) { lock = true; @@ -261,7 +261,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) switch (model.customSw[i].getFunctionFamily()) { - case CS_FAMILY_VOFS: + case LS_FAMILY_VOFS: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(false); cswitchValue[i]->setVisible(false); @@ -269,7 +269,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); cswitchOffset[i]->setDecimals(range.decimals); cswitchOffset[i]->setSingleStep(range.step); - if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcLS_FN_ELESS && model.customSw[i].funcsetMinimum(range.step*-127); cswitchOffset[i]->setMaximum(range.step*127); cswitchOffset[i]->setValue(range.step*model.customSw[i].val2); @@ -280,8 +280,8 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset); } break; - case CS_FAMILY_VBOOL: - case CS_FAMILY_STICKY: + case LS_FAMILY_VBOOL: + case LS_FAMILY_STICKY: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(true); cswitchValue[i]->setVisible(false); @@ -289,14 +289,14 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1)); populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2)); break; - case CS_FAMILY_STAY: + case LS_FAMILY_STAY: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(false); cswitchValue[i]->setVisible(false); populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1)); updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true); break; - case CS_FAMILY_VCOMP: + case LS_FAMILY_VCOMP: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(true); cswitchValue[i]->setVisible(false); @@ -304,7 +304,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); break; - case CS_FAMILY_TIMER: + case LS_FAMILY_TIMER: cswitchSource1[i]->setVisible(false); cswitchSource2[i]->setVisible(false); updateTimerParam(cswitchValue[i], model.customSw[i].val1); @@ -315,16 +315,16 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) lock = false; } -void CustomSwitchesPanel::update() +void LogicalSwitchesPanel::update() { - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { lock = true; populateCSWCB(csw[i], model.customSw[i].func); lock = false; setSwitchWidgetVisibility(i); lock = true; populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw)); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { cswitchDuration[i]->setValue(model.customSw[i].duration/2.0); cswitchDelay[i]->setValue(model.customSw[i].delay/2.0); } @@ -332,37 +332,37 @@ void CustomSwitchesPanel::update() } } -void CustomSwitchesPanel::cswPaste() +void LogicalSwitchesPanel::cswPaste() { const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); if (mimeData->hasFormat("application/x-companion-csw")) { QByteArray cswData = mimeData->data("application/x-companion-csw"); - CustomSwData *csw = &model.customSw[selectedSwitch]; - memcpy(csw, cswData.mid(0, sizeof(CustomSwData)).constData(), sizeof(CustomSwData)); + LogicalSwitchData *csw = &model.customSw[selectedSwitch]; + memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData)); emit modified(); updateSelectedSwitch(); } } -void CustomSwitchesPanel::cswDelete() +void LogicalSwitchesPanel::cswDelete() { model.customSw[selectedSwitch].clear(); emit modified(); updateSelectedSwitch(); } -void CustomSwitchesPanel::cswCopy() +void LogicalSwitchesPanel::cswCopy() { QByteArray cswData; - cswData.append((char*)&model.customSw[selectedSwitch],sizeof(CustomSwData)); + cswData.append((char*)&model.customSw[selectedSwitch],sizeof(LogicalSwitchData)); QMimeData *mimeData = new QMimeData; mimeData->setData("application/x-companion-csw", cswData); QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); } -void CustomSwitchesPanel::updateSelectedSwitch() +void LogicalSwitchesPanel::updateSelectedSwitch() { lock = true; populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func); @@ -370,14 +370,14 @@ void CustomSwitchesPanel::updateSelectedSwitch() lock = false; } -void CustomSwitchesPanel::cswCut() +void LogicalSwitchesPanel::cswCut() { cswCopy(); cswDelete(); } // TODO make something generic here! -void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos) +void LogicalSwitchesPanel::csw_customContextMenuRequested(QPoint pos) { QLabel *label = (QLabel *)sender(); selectedSwitch = label->property("index").toInt(); diff --git a/companion/src/modeledit/customswitches.h b/companion/src/modeledit/customswitches.h index 0ff1973d6..ef7945afd 100644 --- a/companion/src/modeledit/customswitches.h +++ b/companion/src/modeledit/customswitches.h @@ -5,13 +5,13 @@ #include #include -class CustomSwitchesPanel : public ModelPanel +class LogicalSwitchesPanel : public ModelPanel { Q_OBJECT public: - CustomSwitchesPanel(QWidget *parent, ModelData & model); - virtual ~CustomSwitchesPanel(); + LogicalSwitchesPanel(QWidget *parent, ModelData & model); + virtual ~LogicalSwitchesPanel(); virtual void update(); diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index 3aed2b38f..9336f913b 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -30,7 +30,7 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i addTab(new InputsPanel(this, model, radioData.generalSettings), tr("Inputs")); addTab(new MixesPanel(this, model, radioData.generalSettings), tr("Mixes")); addTab(new Channels(this, model), tr("Channels")); - addTab(new CustomSwitchesPanel(this, model), tr("Logical Switches")); + addTab(new LogicalSwitchesPanel(this, model), tr("Logical Switches")); if (GetEepromInterface()->getCapability(CustomFunctions)) addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Switch Assignment")); addTab(new Curves(this, model), tr("Curves")); diff --git a/companion/src/modeledit/templates.cpp b/companion/src/modeledit/templates.cpp index 6bfb52247..38bec941a 100644 --- a/companion/src/modeledit/templates.cpp +++ b/companion/src/modeledit/templates.cpp @@ -584,8 +584,8 @@ void Templates::applyTemplate(uint8_t idx) md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch(); md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP; md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - setSwitch(0xB, CS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99); - setSwitch(0xC, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0); + setSwitch(0xB, LS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99); + setSwitch(0xC, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0); updateSwitchesTab(); } @@ -841,9 +841,9 @@ void Templates::applyTemplate(uint8_t idx) md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch(); md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP; md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP; - setSwitch(1, CS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue()); - setSwitch(2, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105); - setSwitch(3, CS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105); + setSwitch(1, LS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue()); + setSwitch(2, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105); + setSwitch(3, LS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105); // redraw switches tab updateSwitchesTab(); diff --git a/companion/src/printdialog.cpp b/companion/src/printdialog.cpp index be95c92be..aecd4c088 100644 --- a/companion/src/printdialog.cpp +++ b/companion/src/printdialog.cpp @@ -642,7 +642,7 @@ void printDialog::printSwitches() str.append(""); str.append("

"+tr("Logical Switches")+"

"); - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { if (g_model->customSw[i].func) { str.append(""); if (i<9) { diff --git a/companion/src/simulatordialog.cpp b/companion/src/simulatordialog.cpp index 85cc110d2..8a26c0ecb 100644 --- a/companion/src/simulatordialog.cpp +++ b/companion/src/simulatordialog.cpp @@ -356,7 +356,7 @@ void simulatorDialog::loadParams(RadioData &radioData, const int model_idx) beepVal = 0; beepShow = 0; - switches=txInterface->getCapability(CustomSwitches); + switches=txInterface->getCapability(LogicalSwitches); if ( switches < 13) { ui->cswitch_13->hide(); ui->labelCSW_13->hide(); diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index eb0ff91c7..defef59ea 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -168,7 +168,7 @@ PACK(typedef struct { int16_t curves[16]; int8_t points[NUM_POINTS]; - CustomSwData customSw[NUM_CSW]; + LogicalSwitchData customSw[NUM_CSW]; CustomFnData funcSw[NUM_CFN]; SwashRingData swashR; PhaseData_v215 phaseData[MAX_PHASES]; @@ -379,13 +379,13 @@ void ConvertModel_215_to_216(ModelData &model) for (uint8_t i=0; i<32; i++) { g_model.customSw[i] = oldModel.customSw[i]; #if defined(PCBTARANIS) - CustomSwData * cs = &g_model.customSw[i]; + LogicalSwitchData * cs = &g_model.customSw[i]; uint8_t cstate = cswFamily(cs->func); - if (cstate == CS_FAMILY_OFS || cstate == CS_FAMILY_COMP || cstate == CS_FAMILY_DIFF) { + if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_COMP || cstate == LS_FAMILY_DIFF) { if (cs->v1 > 0) cs->v1 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; if (cs->v1 > MIXSRC_GVAR1+4) cs->v1 += 4; } - if (cstate == CS_FAMILY_OFS || cstate == CS_FAMILY_DIFF) { + if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_DIFF) { if (cs->v1 >= MIXSRC_FIRST_TELEM) { switch ((uint8_t)cs->v1) { case MIXSRC_FIRST_TELEM + TELEM_TM1-1: @@ -429,7 +429,7 @@ void ConvertModel_215_to_216(ModelData &model) } } } - if (cstate == CS_FAMILY_COMP) { + if (cstate == LS_FAMILY_COMP) { if (cs->v2 > 0) cs->v2 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; if (cs->v2 > MIXSRC_GVAR1+4) cs->v2 += 4; } diff --git a/radio/src/gtests.cpp b/radio/src/gtests.cpp index fe6cb1a0a..5530d21a2 100644 --- a/radio/src/gtests.cpp +++ b/radio/src/gtests.cpp @@ -304,8 +304,8 @@ TEST(getSwitch, circularCSW) { MODEL_RESET(); MIXER_RESET(); - g_model.customSw[0] = { SWSRC_SW1, SWSRC_SW1, CS_OR }; - g_model.customSw[1] = { SWSRC_SW1, SWSRC_SW1, CS_AND }; + g_model.customSw[0] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_OR }; + g_model.customSw[1] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_AND }; EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(-SWSRC_SW1), true); EXPECT_EQ(getSwitch(SWSRC_SW2), false); @@ -324,8 +324,8 @@ TEST(getSwitch, recursiveSW) MODEL_RESET(); MIXER_RESET(); - g_model.customSw[0] = { SWSRC_RUD, -SWSRC_SW2, CS_OR }; - g_model.customSw[1] = { SWSRC_ELE, -SWSRC_SW1, CS_OR }; + g_model.customSw[0] = { SWSRC_RUD, -SWSRC_SW2, LS_FUNC_OR }; + g_model.customSw[1] = { SWSRC_ELE, -SWSRC_SW1, LS_FUNC_OR }; EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), true); diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 89847da43..ba0c68abc 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -55,7 +55,7 @@ enum EnumTabModel { #if LCD_W >= 212 IF_GVARS(e_GVars) #endif - e_CustomSwitches, + e_LogicalSwitches, e_CustomFunctions, #if defined(LUA_MODEL_SCRIPTS) e_CustomScripts, @@ -74,7 +74,7 @@ void menuModelMixAll(uint8_t event); void menuModelLimits(uint8_t event); void menuModelCurvesAll(uint8_t event); void menuModelGVars(uint8_t event); -void menuModelCustomSwitches(uint8_t event); +void menuModelLogicalSwitches(uint8_t event); void menuModelCustomFunctions(uint8_t event); void menuModelCustomScripts(uint8_t event); void menuModelTelemetry(uint8_t event); @@ -93,7 +93,7 @@ const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = { #if LCD_W >= 212 && defined(GVARS) && defined(FLIGHT_MODES) IF_GVARS(menuModelGVars) #endif - menuModelCustomSwitches, + menuModelLogicalSwitches, menuModelCustomFunctions, #if defined(LUA_MODEL_SCRIPTS) menuModelCustomScripts, @@ -4124,20 +4124,20 @@ void menuModelGVars(uint8_t event) #define CHECK_INCDEC_PARAM(event, var, min, max) checkIncDec(event, var, min, max, incdecFlag) #endif -enum CustomSwitchFields { - CSW_FIELD_FUNCTION, - CSW_FIELD_V1, - CSW_FIELD_V2, +enum LogicalSwitchFields { + LS_FIELD_FUNCTION, + LS_FIELD_V1, + LS_FIELD_V2, #if defined(PCBTARANIS) - CSW_FIELD_V3, + LS_FIELD_V3, #endif - CSW_FIELD_ANDSW, + LS_FIELD_ANDSW, #if defined(CPUARM) - CSW_FIELD_DURATION, - CSW_FIELD_DELAY, + LS_FIELD_DURATION, + LS_FIELD_DELAY, #endif - CSW_FIELD_COUNT, - CSW_FIELD_LAST = CSW_FIELD_COUNT-1 + LS_FIELD_COUNT, + LS_FIELD_LAST = LS_FIELD_COUNT-1 }; #if LCD_W >= 212 @@ -4158,15 +4158,15 @@ enum CustomSwitchFields { #define CSWONE_2ND_COLUMN (11*FW) -void menuModelCustomSwitchOne(uint8_t event) +void menuModelLogicalSwitchOne(uint8_t event) { TITLE(STR_MENUCUSTOMSWITCH); - CustomSwData * cs = cswAddress(s_currIdx); + LogicalSwitchData * cs = cswAddress(s_currIdx); uint8_t sw = SWSRC_SW1+s_currIdx; putsSwitches(14*FW, 0, sw, (getSwitch(sw) ? BOLD : 0)); - SUBMENU_NOTITLE(CSW_FIELD_COUNT, {0, 0, 1, 0 /*, 0...*/}); + SUBMENU_NOTITLE(LS_FIELD_COUNT, {0, 0, 1, 0 /*, 0...*/}); int8_t sub = m_posVert; @@ -4176,17 +4176,17 @@ void menuModelCustomSwitchOne(uint8_t event) uint8_t attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0); uint8_t cstate = cswFamily(cs->func); switch(i) { - case CSW_FIELD_FUNCTION: + case LS_FIELD_FUNCTION: lcd_putsLeft(y, STR_FUNC); lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_VCSWFUNC, cs->func, attr); if (attr) { - cs->func = checkIncDec(event, cs->func, 0, CS_MAXF, EE_MODEL, isFunctionAvailable); + cs->func = checkIncDec(event, cs->func, 0, LS_FUNC_MAX, EE_MODEL, isLogicalSwitchFunctionAvailable); uint8_t new_cstate = cswFamily(cs->func); if (cstate != new_cstate) { - if (new_cstate == CS_FAMILY_TIMER) { + if (new_cstate == LS_FAMILY_TIMER) { cs->v1 = cs->v2 = -119; } - else if (new_cstate == CS_FAMILY_STAY) { + else if (new_cstate == LS_FAMILY_STAY) { cs->v1 = 0; cs->v2 = -129; cs->v3 = 0; } else { @@ -4195,15 +4195,15 @@ void menuModelCustomSwitchOne(uint8_t event) } } break; - case CSW_FIELD_V1: + case LS_FIELD_V1: { lcd_putsLeft(y, STR_V1); int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM; - if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY || cstate == CS_FAMILY_STAY) { + if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY || cstate == LS_FAMILY_STAY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; } - else if (cstate == CS_FAMILY_TIMER) { + else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v1+1, LEFT|attr); v1_max = 99; } @@ -4215,19 +4215,19 @@ void menuModelCustomSwitchOne(uint8_t event) } break; } - case CSW_FIELD_V2: + case LS_FIELD_V2: { lcd_putsLeft(y, STR_V2); int16_t v2_min=0, v2_max=MIXSRC_LAST_TELEM; - if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) { + if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr); v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; } - else if (cstate == CS_FAMILY_TIMER) { + else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2+1, LEFT|attr); v2_max = 99; } - else if (cstate == CS_FAMILY_STAY) { + else if (cstate == LS_FAMILY_STAY) { lcd_putc(CSWONE_2ND_COLUMN-4, y, '['); lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|(m_posHorz==0 ? attr : 0)); lcd_putc(lcdLastPos, y, ':'); @@ -4243,7 +4243,7 @@ void menuModelCustomSwitchOne(uint8_t event) } v2_min=-129; v2_max = 122; } - else if (cstate == CS_FAMILY_COMP) { + else if (cstate == LS_FAMILY_COMP) { putsMixerSource(CSWONE_2ND_COLUMN, y, cs->v2, attr); } else { @@ -4251,7 +4251,7 @@ void menuModelCustomSwitchOne(uint8_t event) if (cs->v1 >= MIXSRC_FIRST_TELEM) { putsTelemetryChannel(CSWONE_2ND_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), attr|LEFT); v2_max = maxTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1); - if (cstate == CS_FAMILY_OFS) { + if (cstate == LS_FAMILY_OFS) { v2_min = -128; v2_max -= 128; } @@ -4277,34 +4277,34 @@ void menuModelCustomSwitchOne(uint8_t event) } break; } - case CSW_FIELD_ANDSW: + case LS_FIELD_ANDSW: lcd_putsLeft(y, STR_AND_SWITCH); putsSwitches(CSWONE_2ND_COLUMN, y, cs->andsw, attr); - if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW); + if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_LS_ANDSW, MAX_LS_ANDSW); break; - case CSW_FIELD_DURATION: + case LS_FIELD_DURATION: lcd_putsLeft(y, STR_DURATION); if (cs->duration > 0) lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 5*cs->duration, attr|PREC1|LEFT); else lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); - if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_CSW_DURATION); + if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION); break; - case CSW_FIELD_DELAY: + case LS_FIELD_DELAY: lcd_putsLeft(y, STR_DELAY); if (cs->delay > 0) lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 5*cs->delay, attr|PREC1|LEFT); else lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); - if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_CSW_DELAY); + if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY); break; } } } -void menuModelCustomSwitches(uint8_t event) +void menuModelLogicalSwitches(uint8_t event) { - SIMPLE_MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_CustomSwitches, NUM_CSW+1); + SIMPLE_MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_LogicalSwitches, NUM_CSW+1); uint8_t y = 0; uint8_t k = 0; @@ -4318,7 +4318,7 @@ void menuModelCustomSwitches(uint8_t event) case EVT_KEY_FIRST(KEY_ENTER): if (sub >= 0) { s_currIdx = sub; - pushMenu(menuModelCustomSwitchOne); + pushMenu(menuModelLogicalSwitchOne); } break; } @@ -4326,7 +4326,7 @@ void menuModelCustomSwitches(uint8_t event) for (uint8_t i=0; ifunc); - if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) { + if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, 0); } - else if (cstate == CS_FAMILY_COMP) { + else if (cstate == LS_FAMILY_COMP) { putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, 0); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, 0); } - else if (cstate == CS_FAMILY_STAY) { + else if (cstate == LS_FAMILY_STAY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); lcd_putc(CSW_3RD_COLUMN-4, y, '['); lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1); @@ -4359,7 +4359,7 @@ void menuModelCustomSwitches(uint8_t event) lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1); lcd_putc(lcdLastPos-1, y, ']'); } - else if (cstate == CS_FAMILY_TIMER) { + else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT); lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2+1, LEFT); } @@ -4391,17 +4391,17 @@ enum ClipboardType { struct Clipboard { ClipboardType type; union { - CustomSwData csw; + LogicalSwitchData csw; CustomFnData cfn; } data; }; Clipboard clipboard; -void onCustomSwitchesMenu(const char *result) +void onLogicalSwitchesMenu(const char *result) { int8_t sub = m_posVert-1; - CustomSwData * cs = cswAddress(sub); + LogicalSwitchData * cs = cswAddress(sub); if (result == STR_COPY) { clipboard.type = CLIPBOARD_TYPE_CUSTOM_SWITCH; @@ -4412,17 +4412,17 @@ void onCustomSwitchesMenu(const char *result) eeDirty(EE_MODEL); } else if (result == STR_DELETE) { - memset(cs, 0, sizeof(CustomSwData)); + memset(cs, 0, sizeof(LogicalSwitchData)); eeDirty(EE_MODEL); } } #endif -void menuModelCustomSwitches(uint8_t event) +void menuModelLogicalSwitches(uint8_t event) { INCDEC_DECLARE_VARS(); - MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_CustomSwitches, NUM_CSW+1, {0, NAVIGATION_LINE_BY_LINE|CSW_FIELD_LAST/*repeated...*/}); + MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_LogicalSwitches, NUM_CSW+1, {0, NAVIGATION_LINE_BY_LINE|LS_FIELD_LAST/*repeated...*/}); uint8_t y = 0; uint8_t k = 0; @@ -4438,12 +4438,12 @@ void menuModelCustomSwitches(uint8_t event) #if defined(PCBTARANIS) if (sub>=0 && horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { killEvents(event); - CustomSwData * cs = cswAddress(sub); + LogicalSwitchData * cs = cswAddress(sub); if (cs->func) MENU_ADD_ITEM(STR_COPY); if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH) MENU_ADD_ITEM(STR_PASTE); if (cs->func || cs->v1 || cs->v2 || cs->delay || cs->duration || cs->andsw) MENU_ADD_ITEM(STR_DELETE); - menuHandler = onCustomSwitchesMenu; + menuHandler = onLogicalSwitchesMenu; } #endif @@ -4453,7 +4453,7 @@ void menuModelCustomSwitches(uint8_t event) uint8_t attr = (sub==k ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t attr1 = (horz==1 ? attr : 0); uint8_t attr2 = (horz==2 ? attr : 0); - CustomSwData * cs = cswAddress(k); + LogicalSwitchData * cs = cswAddress(k); // CSW name uint8_t sw = SWSRC_SW1+k; @@ -4471,24 +4471,24 @@ void menuModelCustomSwitches(uint8_t event) int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; #endif - if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) { + if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; INCDEC_SET_FLAG(INCDEC_SWITCH); - INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches); + INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); } #if defined(CPUARM) - else if (cstate == CS_FAMILY_STAY) { + else if (cstate == LS_FAMILY_STAY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); lcd_putc(CSW_3RD_COLUMN-4, y, '['); lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2); lcd_putc(lcdLastPos, y, ':'); if (cs->v3 == 0) - lcd_putsAtt(lcdLastPos+3, y, "--", (horz==CSW_FIELD_V3 ? attr : 0)); + lcd_putsAtt(lcdLastPos+3, y, "--", (horz==LS_FIELD_V3 ? attr : 0)); else - lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==CSW_FIELD_V3 ? attr : 0)); + lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==LS_FIELD_V3 ? attr : 0)); lcd_putc(lcdLastPos, y, ']'); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; v2_min=-129; v2_max = 122; @@ -4503,13 +4503,13 @@ void menuModelCustomSwitches(uint8_t event) } } #endif - else if (cstate == CS_FAMILY_COMP) { + else if (cstate == LS_FAMILY_COMP) { putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, attr2); INCDEC_SET_FLAG(INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); } - else if (cstate == CS_FAMILY_TIMER) { + else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSW_2ND_COLUMN, y, cswTimerValue(cs->v1), LEFT|PREC1|attr1); lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2); v1_min = v2_min = -128; @@ -4538,7 +4538,7 @@ void menuModelCustomSwitches(uint8_t event) eeDirty(EE_MODEL); } #else - if (cstate == CS_FAMILY_OFS) { + if (cstate == LS_FAMILY_OFS) { v2_min = -128; v2_max -= 128; } @@ -4570,37 +4570,37 @@ void menuModelCustomSwitches(uint8_t event) // CSW AND switch #if defined(CPUARM) - putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==CSW_FIELD_ANDSW ? attr : 0); + putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==LS_FIELD_ANDSW ? attr : 0); #else uint8_t andsw = cs->andsw; if (andsw > SWSRC_LAST_SWITCH) { andsw += SWSRC_SW1-SWSRC_LAST_SWITCH-1; } - putsSwitches(CSW_4TH_COLUMN, y, andsw, horz==CSW_FIELD_ANDSW ? attr : 0); + putsSwitches(CSW_4TH_COLUMN, y, andsw, horz==LS_FIELD_ANDSW ? attr : 0); #endif #if defined(CPUARM) // CSW duration if (cs->duration > 0) - lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==CSW_FIELD_DURATION ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); else - lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DURATION ? attr : 0); + lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); // CSW delay - if (cstate == CS_FAMILY_STAY) { + if (cstate == LS_FAMILY_STAY) { lcd_puts(CSW_6TH_COLUMN, y, "N/A"); - if (attr && horz == CSW_FIELD_DELAY) { + if (attr && horz == LS_FIELD_DELAY) { REPEAT_LAST_CURSOR_MOVE(); } } else if (cs->delay > 0) { - lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==CSW_FIELD_DELAY ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); } else { - lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DELAY ? attr : 0); + lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); } - if (attr && horz == CSW_FIELD_V3 && cstate != CS_FAMILY_STAY) { + if (attr && horz == LS_FIELD_V3 && cstate != LS_FAMILY_STAY) { REPEAT_LAST_CURSOR_MOVE(); } #endif @@ -4608,38 +4608,38 @@ void menuModelCustomSwitches(uint8_t event) if ((s_editMode>0 || p1valdiff) && attr) { switch (horz) { - case CSW_FIELD_FUNCTION: + case LS_FIELD_FUNCTION: { #if defined(CPUARM) - cs->func = checkIncDec(event, cs->func, 0, CS_MAXF, EE_MODEL, isFunctionAvailable); + cs->func = checkIncDec(event, cs->func, 0, LS_FUNC_MAX, EE_MODEL, isLogicalSwitchFunctionAvailable); #else - CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, CS_MAXF); + CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, LS_FUNC_MAX); #endif uint8_t new_cstate = cswFamily(cs->func); if (cstate != new_cstate) { #if defined(CPUARM) - if (new_cstate == CS_FAMILY_TIMER) { + if (new_cstate == LS_FAMILY_TIMER) { cs->v1 = cs->v2 = -119; } - else if (new_cstate == CS_FAMILY_STAY) { + else if (new_cstate == LS_FAMILY_STAY) { cs->v1 = 0; cs->v2 = -129; cs->v3 = 0; } else { cs->v1 = cs->v2 = 0; } #else - cs->v1 = cs->v2 = (new_cstate==CS_FAMILY_TIMER ? -119/*1.0*/ : 0); + cs->v1 = cs->v2 = (new_cstate==LS_FAMILY_TIMER ? -119/*1.0*/ : 0); #endif } break; } - case CSW_FIELD_V1: + case LS_FIELD_V1: cs->v1 = CHECK_INCDEC_PARAM(event, cs->v1, v1_min, v1_max); break; - case CSW_FIELD_V2: + case LS_FIELD_V2: cs->v2 = CHECK_INCDEC_PARAM(event, cs->v2, v2_min, v2_max); #if defined(PCBTARANIS) - if (cstate==CS_FAMILY_OFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { + if (cstate==LS_FAMILY_OFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { killEvents(event); getvalue_t x = getValue(cs->v1); if (cs->v1 < MIXSRC_GVAR1) @@ -4651,25 +4651,25 @@ void menuModelCustomSwitches(uint8_t event) #endif break; #if defined(CPUARM) - case CSW_FIELD_V3: + case LS_FIELD_V3: cs->v3 = CHECK_INCDEC_PARAM(event, cs->v3, v3_min, v3_max); break; #endif - case CSW_FIELD_ANDSW: + case LS_FIELD_ANDSW: #if defined(CPUARM) INCDEC_SET_FLAG(INCDEC_SWITCH); - INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches); - cs->andsw = CHECK_INCDEC_PARAM(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW); + INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); + cs->andsw = CHECK_INCDEC_PARAM(event, cs->andsw, -MAX_LS_ANDSW, MAX_LS_ANDSW); #else - CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_CSW_ANDSW); + CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_LS_ANDSW); #endif break; #if defined(CPUARM) - case CSW_FIELD_DURATION: - CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_CSW_DURATION); + case LS_FIELD_DURATION: + CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION); break; - case CSW_FIELD_DELAY: - CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_CSW_DELAY); + case LS_FIELD_DELAY: + CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY); break; #endif } diff --git a/radio/src/gui/menus.cpp b/radio/src/gui/menus.cpp index e6cbfccee..3296994d4 100644 --- a/radio/src/gui/menus.cpp +++ b/radio/src/gui/menus.cpp @@ -1219,8 +1219,8 @@ bool isSourceAvailable(int16_t source) } if (source>=MIXSRC_SW1 && source<=MIXSRC_LAST_CSW) { - CustomSwData * cs = cswAddress(source-MIXSRC_SW1); - return (cs->func != CS_OFF); + LogicalSwitchData * cs = cswAddress(source-MIXSRC_SW1); + return (cs->func != LS_FUNC_NONE); } #if !defined(GVARS) @@ -1248,7 +1248,7 @@ bool isInputSourceAvailable(int16_t source) return false; } -bool isSwitchAvailableInCustomSwitches(int16_t swtch) +bool isSwitchAvailableInLogicalSwitches(int16_t swtch) { if (swtch < 0) { if (swtch <= -SWSRC_ON) @@ -1279,22 +1279,35 @@ bool isSwitchAvailableInCustomSwitches(int16_t swtch) bool isSwitchAvailable(int16_t swtch) { - if (!isSwitchAvailableInCustomSwitches(swtch)) { + if (!isSwitchAvailableInLogicalSwitches(swtch)) { return false; } if (swtch >= SWSRC_FIRST_CSW && swtch <= SWSRC_LAST_CSW) { - CustomSwData * cs = cswAddress(swtch-SWSRC_FIRST_CSW); - return (cs->func != CS_OFF); + LogicalSwitchData * cs = cswAddress(swtch-SWSRC_FIRST_CSW); + return (cs->func != LS_FUNC_NONE); } return true; } // Not available yet, will be needed if we implement the Range function later... -bool isFunctionAvailable(int16_t function) +bool isLogicalSwitchFunctionAvailable(int16_t function) { - return function != CS_RANGE; + return function != LS_FUNC_RANGE; } +bool isAssignableFunctionAvailable(int16_t function) +{ + switch (function) { + +#if !defined(HAPTIC) + case FUNC_HAPTIC: + return false; +#endif + + default: + return true; + } +} #endif diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index eed58fd97..c476f2e71 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -190,9 +190,10 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); var = checkIncDecModelZero(event,var,max) #if defined(CPUARM) - bool isFunctionAvailable(int16_t function); + bool isLogicalSwitchFunctionAvailable(int16_t function); + bool isAssignableFunctionAvailable(int16_t function); bool isSwitchAvailable(int16_t swtch); - bool isSwitchAvailableInCustomSwitches(int16_t swtch); + bool isSwitchAvailableInLogicalSwitches(int16_t swtch); #define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER)) #define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \ var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH|NO_INCDEC_MARKS, isSwitchAvailable) diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index fd1f6db60..cbcfd1389 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -668,39 +668,39 @@ PACK( union u_int8int16_t { #endif -enum CswFunctions { - CS_OFF, - CS_VEQUAL, // v==offset - CS_VPOS, // v>offset - CS_VNEG, // voffset + LS_FUNC_VNEG, // voffset - CS_ANEG, // |v|offset + LS_FUNC_ANEG, // |v|andsw; #else @@ -1432,48 +1432,48 @@ bool getSwitch(int8_t swtch) s += SWSRC_SW1-SWSRC_LAST_SWITCH-1; } #endif - if (cs->func == CS_OFF || (s && !getSwitch(s))) { + if (cs->func == LS_FUNC_NONE || (s && !getSwitch(s))) { csLastValue[cs_idx] = CS_LAST_VALUE_INIT; result = false; } - else if ((s=cswFamily(cs->func)) == CS_FAMILY_BOOL) { + else if ((s=cswFamily(cs->func)) == LS_FAMILY_BOOL) { bool res1 = getSwitch(cs->v1); bool res2 = getSwitch(cs->v2); switch (cs->func) { - case CS_AND: + case LS_FUNC_AND: result = (res1 && res2); break; - case CS_OR: + case LS_FUNC_OR: result = (res1 || res2); break; - // case CS_XOR: + // case LS_FUNC_XOR: default: result = (res1 ^ res2); break; } } - else if (s == CS_FAMILY_TIMER) { + else if (s == LS_FAMILY_TIMER) { result = (csLastValue[cs_idx] <= 0); } - else if (s == CS_FAMILY_STICKY) { + else if (s == LS_FAMILY_STICKY) { result = (csLastValue[cs_idx] & (1<<0)); } #if defined(CPUARM) - else if (s == CS_FAMILY_STAY) { + else if (s == LS_FAMILY_STAY) { result = (csLastValue[cs_idx] & (1<<0)); } #endif else { getvalue_t x = getValue(cs->v1); getvalue_t y; - if (s == CS_FAMILY_COMP) { + if (s == LS_FAMILY_COMP) { y = getValue(cs->v2); switch (cs->func) { - case CS_EQUAL: + case LS_FUNC_EQUAL: result = (x==y); break; - case CS_GREATER: + case LS_FUNC_GREATER: result = (x>y); break; default: @@ -1491,7 +1491,7 @@ bool getSwitch(int8_t swtch) y = convertCswTelemValue(cs); #if defined(FRSKY_HUB) && defined(GAUGES) - if (s == CS_FAMILY_OFS) { + if (s == LS_FAMILY_OFS) { uint8_t idx = cs->v1-MIXSRC_FIRST_TELEM+1-TELEM_ALT; if (idx < THLD_MAX) { // Fill the threshold array @@ -1519,7 +1519,7 @@ bool getSwitch(int8_t swtch) #endif switch (cs->func) { - case CS_VEQUAL: + case LS_FUNC_VEQUAL: #if defined(GVARS) if (cs->v1 >= MIXSRC_GVAR1 && cs->v1 <= MIXSRC_LAST_GVAR) result = (x==y); @@ -1527,16 +1527,16 @@ bool getSwitch(int8_t swtch) #endif result = (abs(x-y) < (1024 / STICK_TOLERANCE)); break; - case CS_VPOS: + case LS_FUNC_VPOS: result = (x>y); break; - case CS_VNEG: + case LS_FUNC_VNEG: result = (xy); break; - case CS_ANEG: + case LS_FUNC_ANEG: result = (abs(x)func == CS_DIFFEGREATER) + if (cs->func == LS_FUNC_DIFFEGREATER) result = (y >= 0 ? (diff >= y) : (diff <= y)); else result = (abs(diff) >= y); @@ -1578,7 +1578,7 @@ bool getSwitch(int8_t swtch) if (cswDurations[cs_idx] > get_tmr10ms()) { result = true; } - else if (s == CS_FAMILY_STICKY) { + else if (s == LS_FAMILY_STICKY) { csLastValue[cs_idx] &= ~(1<<0); } } @@ -1925,7 +1925,7 @@ void setGVarValue(uint8_t idx, int16_t value, int8_t phase) #endif #if defined(FRSKY) -csw_telemetry_value_t minTelemValue(uint8_t channel) +ls_telemetry_value_t minTelemValue(uint8_t channel) { switch (channel) { case TELEM_FUEL: @@ -1944,7 +1944,7 @@ csw_telemetry_value_t minTelemValue(uint8_t channel) } } -csw_telemetry_value_t maxTelemValue(uint8_t channel) +ls_telemetry_value_t maxTelemValue(uint8_t channel) { switch (channel) { case TELEM_FUEL: @@ -1965,7 +1965,7 @@ csw_telemetry_value_t maxTelemValue(uint8_t channel) #endif #if defined(CPUARM) -getvalue_t convert16bitsTelemValue(uint8_t channel, csw_telemetry_value_t value) +getvalue_t convert16bitsTelemValue(uint8_t channel, ls_telemetry_value_t value) { getvalue_t result; switch (channel) { @@ -1979,13 +1979,13 @@ getvalue_t convert16bitsTelemValue(uint8_t channel, csw_telemetry_value_t value) return result; } -csw_telemetry_value_t max8bitsTelemValue(uint8_t channel) +ls_telemetry_value_t max8bitsTelemValue(uint8_t channel) { - return min(255, maxTelemValue(channel)); + return min(255, maxTelemValue(channel)); } #endif -getvalue_t convert8bitsTelemValue(uint8_t channel, csw_telemetry_value_t value) +getvalue_t convert8bitsTelemValue(uint8_t channel, ls_telemetry_value_t value) { getvalue_t result; switch (channel) { @@ -2037,13 +2037,13 @@ getvalue_t convert8bitsTelemValue(uint8_t channel, csw_telemetry_value_t value) return result; } -getvalue_t convertCswTelemValue(CustomSwData * cs) +getvalue_t convertCswTelemValue(LogicalSwitchData * cs) { getvalue_t val; #if defined(CPUARM) val = convert16bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, cs->v2); #else - if (cswFamily(cs->func)==CS_FAMILY_OFS) + if (cswFamily(cs->func)==LS_FAMILY_OFS) val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2); else val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2) - convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128); @@ -4051,8 +4051,8 @@ void doMixerCalculations() s_cnt_1s += 1; for (uint8_t i=0; ifunc == CS_TIMER) { + LogicalSwitchData * cs = cswAddress(i); + if (cs->func == LS_FUNC_TIMER) { int16_t *lastValue = &csLastValue[i]; if (*lastValue == 0 || *lastValue == CS_LAST_VALUE_INIT) { *lastValue = -cswTimerValue(cs->v1); @@ -4065,7 +4065,7 @@ void doMixerCalculations() *lastValue -= 1; } } - else if (cs->func == CS_STICKY) { + else if (cs->func == LS_FUNC_STICKY) { PACK(typedef struct { bool state; bool last; @@ -4092,7 +4092,7 @@ void doMixerCalculations() } } #if defined(CPUARM) - else if (cs->func == CS_STAY) { + else if (cs->func == LS_FUNC_STAY) { PACK(typedef struct { uint8_t state:1; uint16_t duration:15; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 8da0f1d9d..f282209a0 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1225,7 +1225,7 @@ ExpoData *expoAddress(uint8_t idx); MixData *mixAddress(uint8_t idx); LimitData *limitAddress(uint8_t idx); int8_t *curveAddress(uint8_t idx); -CustomSwData *cswAddress(uint8_t idx); +LogicalSwitchData *cswAddress(uint8_t idx); #if !defined(PCBTARANIS) struct CurveInfo { @@ -1290,14 +1290,14 @@ extern int24_t act [MAX_MIXERS]; #endif enum CswFunctionFamilies { - CS_FAMILY_OFS, - CS_FAMILY_BOOL, - CS_FAMILY_COMP, - CS_FAMILY_DIFF, - CS_FAMILY_TIMER, - CS_FAMILY_STICKY, - CS_FAMILY_RANGE, - CS_FAMILY_STAY + LS_FAMILY_OFS, + LS_FAMILY_BOOL, + LS_FAMILY_COMP, + LS_FAMILY_DIFF, + LS_FAMILY_TIMER, + LS_FAMILY_STICKY, + LS_FAMILY_RANGE, + LS_FAMILY_STAY }; uint8_t cswFamily(uint8_t func); @@ -1646,20 +1646,20 @@ extern uint8_t barsThresholds[THLD_MAX]; #endif #if defined(FRSKY) - csw_telemetry_value_t minTelemValue(uint8_t channel); - csw_telemetry_value_t maxTelemValue(uint8_t channel); + ls_telemetry_value_t minTelemValue(uint8_t channel); + ls_telemetry_value_t maxTelemValue(uint8_t channel); #else #define minTelemValue(channel) 255 #define maxTelemValue(channel) 255 #endif #if defined(CPUARM) -getvalue_t convert16bitsTelemValue(uint8_t channel, csw_telemetry_value_t value); -csw_telemetry_value_t max8bitsTelemValue(uint8_t channel); +getvalue_t convert16bitsTelemValue(uint8_t channel, ls_telemetry_value_t value); +ls_telemetry_value_t max8bitsTelemValue(uint8_t channel); #endif -getvalue_t convert8bitsTelemValue(uint8_t channel, csw_telemetry_value_t value); -getvalue_t convertCswTelemValue(CustomSwData * cs); +getvalue_t convert8bitsTelemValue(uint8_t channel, ls_telemetry_value_t value); +getvalue_t convertCswTelemValue(LogicalSwitchData * cs); #if defined(CPUARM) #define convertTelemValue(channel, value) convert16bitsTelemValue(channel, value) diff --git a/radio/src/templates.cpp b/radio/src/templates.cpp index aad22a8c1..1b2e59a10 100644 --- a/radio/src/templates.cpp +++ b/radio/src/templates.cpp @@ -146,7 +146,7 @@ void setCurve(uint8_t c, const pm_int8_t ar[]) void setSwitch(uint8_t idx, uint8_t func, int8_t v1, int8_t v2) { - CustomSwData *cs = cswAddress(idx-1); + LogicalSwitchData *cs = cswAddress(idx-1); cs->func = func; cs->v1 = v1; cs->v2 = v2; @@ -198,8 +198,8 @@ void applyTemplate(uint8_t idx) md=setDest(13, MIXSRC_CH14); // md->weight= 100; done by setDest anyway md=setDest(13, MIXSRC_MAX); mixSetWeight(md, -100); md->swtch=SWSRC_SWB; md->mltpx=MLTPX_REP; md=setDest(13, MIXSRC_MAX); /* md->weight= 100;*/ md->swtch=SWSRC_THR; md->mltpx=MLTPX_REP; - setSwitch(11, CS_VNEG, STK_THR, -99); - setSwitch(12, CS_VPOS, MIXSRC_CH14, 0); + setSwitch(11, LS_FUNC_VNEG, STK_THR, -99); + setSwitch(12, LS_FUNC_VPOS, MIXSRC_CH14, 0); break; // V-Tail @@ -283,7 +283,7 @@ void applyTemplate(uint8_t idx) // Servo Test case TMPL_SERVO_TEST: md=setDest(NUM_CHNOUT-1, MIXSRC_SW1, true); md->weight=110; md->mltpx=MLTPX_ADD; md->delayUp = 6; md->delayDown = 6; md->speedUp = 8; md->speedDown = 8; - setSwitch(1, CS_VNEG, MIXSRC_LAST_CH, 0); + setSwitch(1, LS_FUNC_VNEG, MIXSRC_LAST_CH, 0); break; default: From 63d48e810d66d571e51f7bec9e83cb34799309f7 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sat, 8 Feb 2014 09:30:50 +0100 Subject: [PATCH 28/28] Update DONATIONS.txt --- DONATIONS.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DONATIONS.txt b/DONATIONS.txt index 777f18fbb..b1ff31579 100644 --- a/DONATIONS.txt +++ b/DONATIONS.txt @@ -96,7 +96,6 @@ Michael Collins Michael Manning Craig Lorentz Jonathan Modellismo - jonathan.it -Aviomotive - www.aviomotive.com André Lasseret Felipe Alexandre de Oliveira Brian Harris @@ -316,3 +315,4 @@ Henry Deucker Christian Fuchs Arold Reinders Robert Miller +Aviomotive - www.aviomotive.com