diff --git a/src/Makefile b/src/Makefile index d9cd86e4a..0ec3646d9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -63,6 +63,10 @@ PCBREV = # Values = STD, FRSKY, JETI, NMEA, ARDUPILOT, MAVLINK, TELEMETREZ EXT = STD +# FAI mode +# Values = YES, NO, CHOICE +FAI = NO + # Enable heli menu # Values = YES, NO HELI = NO @@ -893,6 +897,13 @@ ifeq ($(PPM_UNIT), PERCENT_PREC0) CPPDEFS += -DPPM_UNIT_PERCENT_PREC0 endif +ifeq ($(FAI), YES) + CPPDEFS += -DFAI +endif +ifeq ($(FAI), CHOICE) + CPPDEFS += -DFAI_CHOICE +endif + ifeq ($(HELI), YES) CPPDEFS += -DHELI endif diff --git a/src/eeprom_raw.cpp b/src/eeprom_raw.cpp index 526aade7e..4b7a867b0 100644 --- a/src/eeprom_raw.cpp +++ b/src/eeprom_raw.cpp @@ -390,7 +390,7 @@ void eeLoadModel(uint8_t id) for (uint8_t i=0; i0 || p1valdiff)) t.tm_mday = checkIncDec(event, t.tm_mday, 1, dlim, 0); break; @@ -525,6 +526,12 @@ void menuGeneralSetup(uint8_t event) break; #endif +#if defined(FAI_CHOICE) + case ITEM_SETUP_FAI: + g_eeGeneral.fai = onoffMenuItem(g_eeGeneral.fai, RADIO_SETUP_2ND_COLUMN, y, PSTR("FAI Mode"), attr, event ) ; + break; +#endif + case ITEM_SETUP_RX_CHANNEL_ORD: lcd_putsLeft(y, STR_RXCHANNELORD); // RAET->AETR for (uint8_t i=1; i<=4; i++) @@ -551,9 +558,7 @@ void menuGeneralSetup(uint8_t event) clearKeyEvents(); } #if defined(ROTARY_ENCODER_NAVIGATION) - if (m_posHorz > 0) { - REPEAT_LAST_CURSOR_MOVE(); - } + MOVE_CURSOR_FROM_HERE(); #endif break; } diff --git a/src/gui/menu_model.cpp b/src/gui/menu_model.cpp index b6c0e0303..2e76b956f 100644 --- a/src/gui/menu_model.cpp +++ b/src/gui/menu_model.cpp @@ -754,7 +754,6 @@ void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, uin int8_t c = name[cur]; int8_t v = c; - /* TODO work with masks */ if (p1valdiff || IS_ROTARY_RIGHT(event) || IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_DOWN) || event==EVT_KEY_REPT(KEY_UP)) { v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0); @@ -909,22 +908,7 @@ void onModelSetupMenu(const char *result) void menuModelSetup(uint8_t event) { -// TODO this is quick & dirty, should be done in place of the return which is hidden inside MENU(...) -#if defined(DSM2) - if (event == EVT_KEY_LONG(KEY_EXIT)) { - s_rangecheck_mode = 0; - } -#endif - #if defined(PCBTARANIS) - if (event == EVT_KEY_LONG(KEY_EXIT)) { - pxxFlag[INTERNAL_MODULE] = 0; - pxxFlag[EXTERNAL_MODULE] = 0; - } -#endif - -#if defined(PCBTARANIS) - bool CURSOR_ON_CELL = (m_posHorz >= 0); #define IF_PORT1_ON(x) (g_model.moduleData[0].rfProtocol == RF_PROTO_OFF ? HIDDEN_ROW : (uint8_t)(x)) #define IF_PORT2_ON(x) (g_model.externalModule == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x)) #define IF_TRAINER_ON(x) (g_model.trainerMode ? (uint8_t)(x) : HIDDEN_ROW) @@ -935,17 +919,37 @@ void menuModelSetup(uint8_t event) #define TRAINER_CHANNELS_ROWS() IF_TRAINER_ON(1) #define PORT_CHANNELS_ROWS(x) (x==0 ? PORT1_CHANNELS_ROWS() : (x==1 ? PORT2_CHANNELS_ROWS() : TRAINER_CHANNELS_ROWS())) #define FAILSAFE_ROWS(x) ((g_model.moduleData[x].rfProtocol==RF_PROTO_X16 || g_model.moduleData[x].rfProtocol==RF_PROTO_LR12) ? (g_model.moduleData[x].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0) : HIDDEN_ROW) - MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, 1+ITEM_MODEL_SETUP_MAX, { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), LABEL(InternalModule), 0, IF_PORT1_ON(1), IF_PORT1_ON(2), IF_PORT1_ON(FAILSAFE_ROWS(0)), LABEL(ExternalModule), g_model.externalModule==MODULE_TYPE_XJT ? (uint8_t)1 : (uint8_t)0, PORT2_CHANNELS_ROWS(), (IS_MODULE_PPM(1) || IS_MODULE_XJT(1) ? (uint8_t)2 : HIDDEN_ROW), IF_PORT2_XJT(FAILSAFE_ROWS(1)), LABEL(Trainer), 0, TRAINER_CHANNELS_ROWS(), IF_TRAINER_ON(2)}); + #define MODEL_SETUP_MAX_LINES (1+ITEM_MODEL_SETUP_MAX) + + bool CURSOR_ON_CELL = (m_posHorz >= 0); + MENU_TAB({ 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), LABEL(InternalModule), 0, IF_PORT1_ON(1), IF_PORT1_ON(2), IF_PORT1_ON(FAILSAFE_ROWS(0)), LABEL(ExternalModule), g_model.externalModule==MODULE_TYPE_XJT ? (uint8_t)1 : (uint8_t)0, PORT2_CHANNELS_ROWS(), (IS_MODULE_PPM(1) || IS_MODULE_XJT(1) ? (uint8_t)2 : HIDDEN_ROW), IF_PORT2_XJT(FAILSAFE_ROWS(1)), LABEL(Trainer), 0, TRAINER_CHANNELS_ROWS(), IF_TRAINER_ON(2)}); #elif defined(CPUM64) - #define CURSOR_ON_CELL (true) + #define CURSOR_ON_CELL (true) + #define MODEL_SETUP_MAX_LINES ((IS_PPM_PROTOCOL(protocol)||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 1+ITEM_MODEL_SETUP_MAX : ITEM_MODEL_SETUP_MAX) + uint8_t protocol = g_model.protocol; - MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, ((IS_PPM_PROTOCOL(protocol)||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 1+ITEM_MODEL_SETUP_MAX : ITEM_MODEL_SETUP_MAX), { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, 2 }); + MENU_TAB({ 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, 2 }); #else - #define CURSOR_ON_CELL (true) + #define CURSOR_ON_CELL (true) + #define MODEL_SETUP_MAX_LINES ((IS_PPM_PROTOCOL(protocol)||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 1+ITEM_MODEL_SETUP_MAX : ITEM_MODEL_SETUP_MAX) + uint8_t protocol = g_model.protocol; - MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, ((IS_PPM_PROTOCOL(protocol)||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 1+ITEM_MODEL_SETUP_MAX : ITEM_MODEL_SETUP_MAX), { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, 2, IF_PCBSKY9X(1) IF_PCBSKY9X(2) }); + MENU_TAB({ 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, 2, IF_PCBSKY9X(1) IF_PCBSKY9X(2) }); #endif + if (!MENU_CHECK(menuTabModel, e_ModelSetup, MODEL_SETUP_MAX_LINES)) { +#if defined(DSM2) + s_rangecheck_mode = 0; +#endif +#if defined(PCBTARANIS) + pxxFlag[INTERNAL_MODULE] = 0; + pxxFlag[EXTERNAL_MODULE] = 0; +#endif + return; + } + + TITLE(STR_MENUSETUP); + uint8_t sub = m_posVert - 1; int8_t editMode = s_editMode; @@ -1358,8 +1362,8 @@ void menuModelSetup(uint8_t event) if (IS_PPM_PROTOCOL(protocol)) { lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+7*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, m_posHorz!=0 ? attr : 0); } - else if (attr && m_posHorz > 0 /* TODO avoid it on stock with another macro*/) { - REPEAT_LAST_CURSOR_MOVE(); + else if (attr) { + MOVE_CURSOR_FROM_HERE(); } #endif @@ -1722,12 +1726,11 @@ void menuModelFlightModesAll(uint8_t event) putsFlightPhase(OFS_CHECKTRIMS, (LCD_LINES-1)*FH+1, s_perout_flight_phase+1); if (sub==MAX_PHASES && !trimsCheckTimer) { lcd_status_line(); - // TODO [ENTER] here } return; } - PhaseData *p = phaseaddress(k); + PhaseData *p = phaseAddress(k); putsFlightPhase(0, y, k+1, (getFlightPhase()==k ? BOLD : 0) | ((sub==k && m_posHorz<0) ? INVERS : 0)); @@ -1793,7 +1796,7 @@ enum menuModelPhaseItems { void menuModelPhaseOne(uint8_t event) { - PhaseData *phase = phaseaddress(s_currIdx); + PhaseData *phase = phaseAddress(s_currIdx); putsFlightPhase(13*FW, 0, s_currIdx+1, (getFlightPhase()==s_currIdx ? BOLD : 0)); #if defined(GVARS) && !defined(PCBSTD) @@ -1858,11 +1861,11 @@ void menuModelPhaseOne(uint8_t event) #if ROTARY_ENCODERS > 2 int16_t v; if(t < (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)) - v = phaseaddress(s_currIdx)->rotaryEncoders[t]; + v = phaseAddress(s_currIdx)->rotaryEncoders[t]; else v = g_model.rotaryEncodersExtra[s_currIdx][t-(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)]; #else - int16_t v = phaseaddress(s_currIdx)->rotaryEncoders[t]; + int16_t v = phaseAddress(s_currIdx)->rotaryEncoders[t]; #endif if (v < ROTARY_ENCODER_MAX) v = ROTARY_ENCODER_MAX; v = checkIncDec(event, v, ROTARY_ENCODER_MAX, ROTARY_ENCODER_MAX+MAX_PHASES-1, EE_MODEL); @@ -1870,11 +1873,11 @@ void menuModelPhaseOne(uint8_t event) if (v == ROTARY_ENCODER_MAX) v = 0; #if ROTARY_ENCODERS > 2 if (t < (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)) - phaseaddress(s_currIdx)->rotaryEncoders[t] = v; + phaseAddress(s_currIdx)->rotaryEncoders[t] = v; else g_model.rotaryEncodersExtra[s_currIdx][t-(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)] = v; #else - phaseaddress(s_currIdx)->rotaryEncoders[t] = v; + phaseAddress(s_currIdx)->rotaryEncoders[t] = v; #endif } } @@ -1984,7 +1987,7 @@ void menuModelFlightModesAll(uint8_t event) uint8_t y = 1 + (i+1)*FH; #endif att = (i==sub ? INVERS : 0); - PhaseData *p = phaseaddress(i); + PhaseData *p = phaseAddress(i); #if ROTARY_ENCODERS > 2 putsFlightPhase(0, y, i+1, att|CONDENSED|(getFlightPhase()==i ? BOLD : 0)); #else @@ -2089,7 +2092,7 @@ typedef int16_t (*FnFuncP) (int16_t x); int16_t expoFn(int16_t x) { - ExpoData *ed = expoaddress(s_currIdx); + ExpoData *ed = expoAddress(s_currIdx); int16_t anas[NUM_INPUTS] = {0}; anas[ed->chn] = x; applyExpos(anas, e_perout_mode_inactive_phase); @@ -2133,7 +2136,7 @@ struct point_t { point_t getPoint(uint8_t i) { point_t result = {0, 0}; - CurveInfo crv = curveinfo(s_curveChan); + CurveInfo crv = curveInfo(s_curveChan); if (i < crv.points) { result.x = X0-1-WCHART+i*WCHART/(crv.points/2); result.y = (LCD_H-1) - (100 + crv.crv[i]) * (LCD_H-1) / 200; @@ -2164,13 +2167,13 @@ bool moveCurve(uint8_t index, int8_t shift, int8_t custom=0) return false; } - int8_t *crv = curveaddress(index); + int8_t *crv = curveAddress(index); if (shift < 0) { for (uint8_t i=0; i=0; i--) { - ch = (expo ? expoaddress(i)->mode : mixaddress(i)->srcRaw); + ch = (expo ? expoAddress(i)->mode : mixAddress(i)->srcRaw); if (ch != 0) { count++; } @@ -2491,12 +2494,12 @@ void deleteExpoMix(uint8_t expo, uint8_t idx) { pauseMixerCalculations(); if (expo) { - ExpoData *expo = expoaddress(idx); + ExpoData *expo = expoAddress(idx); memmove(expo, expo+1, (MAX_EXPOS-(idx+1))*sizeof(ExpoData)); memclear(&g_model.expoData[MAX_EXPOS-1], sizeof(ExpoData)); } else { - MixData *mix = mixaddress(idx); + MixData *mix = mixAddress(idx); memmove(mix, mix+1, (MAX_MIXERS-(idx+1))*sizeof(MixData)); memclear(&g_model.mixData[MAX_MIXERS-1], sizeof(MixData)); } @@ -2509,7 +2512,7 @@ void insertExpoMix(uint8_t expo, uint8_t idx) { pauseMixerCalculations(); if (expo) { - ExpoData *expo = expoaddress(idx); + ExpoData *expo = expoAddress(idx); memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData)); memclear(expo, sizeof(ExpoData)); expo->mode = 3; // pos&neg @@ -2517,7 +2520,7 @@ void insertExpoMix(uint8_t expo, uint8_t idx) expo->weight = 100; } else { - MixData *mix = mixaddress(idx); + MixData *mix = mixAddress(idx); memmove(mix+1, mix, (MAX_MIXERS-(idx+1))*sizeof(MixData)); memclear(mix, sizeof(MixData)); mix->destCh = s_currCh-1; @@ -2532,11 +2535,11 @@ void copyExpoMix(uint8_t expo, uint8_t idx) { pauseMixerCalculations(); if (expo) { - ExpoData *expo = expoaddress(idx); + ExpoData *expo = expoAddress(idx); memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData)); } else { - MixData *mix = mixaddress(idx); + MixData *mix = mixAddress(idx); memmove(mix+1, mix, (MAX_MIXERS-(idx+1))*sizeof(MixData)); } resumeMixerCalculations(); @@ -2563,7 +2566,7 @@ bool swapExpoMix(uint8_t expo, uint8_t &idx, uint8_t up) int8_t tgt_idx = (up ? idx-1 : idx+1); if (expo) { - x = (ExpoData *)expoaddress(idx); + x = (ExpoData *)expoAddress(idx); if (tgt_idx < 0) { if (((ExpoData *)x)->chn == 0) @@ -2579,7 +2582,7 @@ bool swapExpoMix(uint8_t expo, uint8_t &idx, uint8_t up) return true; } - y = (ExpoData *)expoaddress(tgt_idx); + y = (ExpoData *)expoAddress(tgt_idx); if(((ExpoData *)x)->chn != ((ExpoData *)y)->chn || !((ExpoData *)y)->mode) { if (up) { if (((ExpoData *)x)->chn>0) ((ExpoData *)x)->chn--; @@ -2595,7 +2598,7 @@ bool swapExpoMix(uint8_t expo, uint8_t &idx, uint8_t up) size = sizeof(ExpoData); } else { - x = (MixData *)mixaddress(idx); + x = (MixData *)mixAddress(idx); if (tgt_idx < 0) { if (((MixData *)x)->destCh == 0) @@ -2611,7 +2614,7 @@ bool swapExpoMix(uint8_t expo, uint8_t &idx, uint8_t up) return true; } - y = (MixData *)mixaddress(tgt_idx); + y = (MixData *)mixAddress(tgt_idx); uint8_t destCh = ((MixData *)x)->destCh; if(!((MixData *)y)->srcRaw || destCh != ((MixData *)y)->destCh) { if (up) { @@ -2657,7 +2660,7 @@ void menuModelExpoOne(uint8_t event) } #endif - ExpoData *ed = expoaddress(s_currIdx); + ExpoData *ed = expoAddress(s_currIdx); putsMixerSource(7*FW+FW/2, 0, ed->chn+1, 0); SUBMENU(STR_MENUDREXPO, EXPO_FIELD_MAX, {IF_CPUARM(0) 0, 0, IF_CURVES(0) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/}); @@ -2775,7 +2778,7 @@ void menuModelMixOne(uint8_t event) #endif TITLE(s_currCh ? STR_INSERTMIX : STR_EDITMIX); - MixData *md2 = mixaddress(s_currIdx) ; + MixData *md2 = mixAddress(s_currIdx) ; putsChn(lcdLastPos+1*FW, 0, md2->destCh+1,0); #if defined(ROTARY_ENCODERS) @@ -2880,9 +2883,7 @@ void menuModelMixOne(uint8_t event) if (md2->curveParam == 0) md2->curveMode = MODE_DIFFERENTIAL; #if defined(ROTARY_ENCODER_NAVIGATION) || defined(PCBTARANIS) - if (m_posHorz != 0) { - REPEAT_LAST_CURSOR_MOVE(); - } + MOVE_CURSOR_FROM_HERE(); #else m_posHorz = 0; #endif @@ -2970,7 +2971,7 @@ static uint8_t s_copySrcCh; void onExpoMixMenu(const char *result) { bool expo = (g_menuStack[g_menuStackPtr] == menuModelExposAll); - uint8_t chn = (expo ? expoaddress(s_currIdx)->chn+1 : mixaddress(s_currIdx)->destCh+1); + uint8_t chn = (expo ? expoAddress(s_currIdx)->chn+1 : mixAddress(s_currIdx)->destCh+1); if (result == STR_EDIT) { pushMenu(expo ? menuModelExpoOne : menuModelMixOne); @@ -3014,7 +3015,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) if (s_editMode > 0) s_editMode = 0; - uint8_t chn = (expo ? expoaddress(s_currIdx)->chn+1 : mixaddress(s_currIdx)->destCh+1); + uint8_t chn = (expo ? expoAddress(s_currIdx)->chn+1 : mixAddress(s_currIdx)->destCh+1); switch (event) { @@ -3166,7 +3167,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) for (uint8_t ch=1; ch<=(expo ? NUM_INPUTS : NUM_CHNOUT); ch++) { void *pointer = NULL; MixData * &md = (MixData * &)pointer; ExpoData * &ed = (ExpoData * &)pointer; uint8_t y = 1+(cur-s_pgOfs)*FH; - if (expo ? (ichn+1 == ch && ed->mode) : (isrcRaw && md->destCh+1 == ch)) { + if (expo ? (ichn+1 == ch && ed->mode) : (isrcRaw && md->destCh+1 == ch)) { if (s_pgOfs < cur && cur-s_pgOfs < LCD_LINES) { if (expo) { putsMixerSource(0, y, ch, 0); @@ -3322,7 +3323,7 @@ void menuModelMixAll(uint8_t event) bool thrOutput(uint8_t ch) { for (uint8_t i=0; idestCh==ch && mix->srcRaw==MIXSRC_Thr) return true; } @@ -3415,7 +3416,7 @@ void menuModelLimits(uint8_t event) #endif if (s_warning_result) { - LimitData *ld = limitaddress(sub); + LimitData *ld = limitAddress(sub); ld->revert = !ld->revert; s_warning_result = 0; AUDIO_WARNING2(); @@ -3440,7 +3441,7 @@ void menuModelLimits(uint8_t event) return; } - LimitData *ld = limitaddress(k) ; + LimitData *ld = limitAddress(k) ; #if LCD_W >= 212 || !defined(PPM_CENTER_ADJUSTABLE) int16_t v = (ld->revert) ? -ld->offset : ld->offset; @@ -3452,7 +3453,7 @@ void menuModelLimits(uint8_t event) #endif #if defined(PPM_CENTER_ADJUSTABLE) - int8_t limit = ((g_model.extendedLimits && !limitaddress(k)->ppmCenter) ? 125 : 100); + int8_t limit = ((g_model.extendedLimits && !limitAddress(k)->ppmCenter) ? 125 : 100); #else int8_t limit = (g_model.extendedLimits ? 125 : 100); #endif @@ -3612,7 +3613,7 @@ void menuModelCurvesAll(uint8_t event) putsStrIdx(0, y, STR_CV, k+1, attr); #if defined(PCBTARANIS) editName(4*FW, y, g_model.curveNames[k], sizeof(g_model.curveNames[k]), 0, 0); - CurveInfo crv = curveinfo(k); + CurveInfo crv = curveInfo(k); lcd_outdezAtt(11*FW, y, crv.points, LEFT); lcd_putsAtt(lcdLastPos, y, crv.custom ? PSTR("pt'") : PSTR("pt"), 0); #endif @@ -3727,7 +3728,7 @@ void menuModelCustomSwitchOne(uint8_t event) { TITLE(STR_MENUCUSTOMSWITCH); - CustomSwData * cs = cswaddress(s_currIdx); + 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); @@ -3738,14 +3739,14 @@ void menuModelCustomSwitchOne(uint8_t event) uint8_t y = 1 + (k+1)*FH; uint8_t i = k + s_pgOfs; uint8_t attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0); - uint8_t cstate = CS_STATE(cs->func); + uint8_t cstate = cswFamily(cs->func); switch(i) { case CSW_FIELD_FUNCTION: 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 != CS_STATE(cs->func)) { + if (cstate != cswFamily(cs->func)) { cs->v1 = 0; cs->v2 = 0; } @@ -3759,6 +3760,10 @@ void menuModelCustomSwitchOne(uint8_t event) putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; } + else if (cstate == CS_VTIMER) { + lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v1+1, LEFT|attr); + v1_max = 99; + } else { putsMixerSource(CSWONE_2ND_COLUMN, y, cs->v1, attr); } @@ -3775,6 +3780,10 @@ void menuModelCustomSwitchOne(uint8_t event) putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr); v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; } + else if (cstate == CS_VTIMER) { + lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2+1, LEFT|attr); + v2_max = 99; + } else if (cstate == CS_VCOMP) { putsMixerSource(CSWONE_2ND_COLUMN, y, cs->v2, attr); } @@ -3800,7 +3809,7 @@ void menuModelCustomSwitchOne(uint8_t event) #endif { v2_min = -125; v2_max = 125; - lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2, attr|LEFT); + lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2, LEFT|attr); } } @@ -3860,7 +3869,7 @@ void menuModelCustomSwitches(uint8_t event) for (uint8_t i=0; ifunc, 0); // CSW params - uint8_t cstate = CS_STATE(cs->func); + uint8_t cstate = cswFamily(cs->func); if (cstate == CS_VBOOL) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); @@ -3882,6 +3891,10 @@ void menuModelCustomSwitches(uint8_t event) putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, 0); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, 0); } + else if (cstate == CS_VTIMER) { + lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT); + lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2+1, LEFT); + } else { putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, 0); if (cs->v1 >= MIXSRC_FIRST_TELEM) { @@ -3912,13 +3925,14 @@ void menuModelCustomSwitches(uint8_t event) MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_CustomSwitches, NUM_CSW+1, {0, NAVIGATION_LINE_BY_LINE|CSW_FIELD_LAST/*repeated...*/}); - uint8_t y = 0; - uint8_t k = 0; - int8_t sub = m_posVert - 1; + uint8_t y = 0; + uint8_t k = 0; + int8_t sub = m_posVert - 1; + horzpos_t horz = m_posHorz; #if LCD_W >= 212 - if (m_posHorz>=0) { - displayColumnHeader(STR_CSW_HEADERS, m_posHorz); + if (horz>=0) { + displayColumnHeader(STR_CSW_HEADERS, horz); } #endif @@ -3926,40 +3940,48 @@ void menuModelCustomSwitches(uint8_t event) y = 1 + (i+1)*FH; k = i+s_pgOfs; uint8_t attr = (sub==k ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); - CustomSwData * cs = cswaddress(k); + uint8_t attr1 = (horz==1 ? attr : 0); + uint8_t attr2 = (horz==2 ? attr : 0); + CustomSwData * cs = cswAddress(k); // CSW name uint8_t sw = SWSRC_SW1+k; - putsSwitches(0, y, sw, (getSwitch(sw) ? BOLD : 0) | ((sub==k && m_posHorz<0) ? INVERS : 0)); + putsSwitches(0, y, sw, (getSwitch(sw) ? BOLD : 0) | ((sub==k && horz<0) ? INVERS : 0)); // CSW func - lcd_putsiAtt(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, m_posHorz==0 ? attr : 0); + lcd_putsiAtt(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, horz==0 ? attr : 0); // CSW params - uint8_t cstate = CS_STATE(cs->func); + uint8_t cstate = cswFamily(cs->func); int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; if (cstate == CS_VBOOL) { - putsSwitches(CSW_2ND_COLUMN, y, cs->v1, m_posHorz==1 ? attr : 0); - putsSwitches(CSW_3RD_COLUMN, y, cs->v2, m_posHorz==2 ? attr : 0); + 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); } else if (cstate == CS_VCOMP) { - putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, m_posHorz==1 ? attr : 0); - putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, m_posHorz==2 ? attr : 0); + putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1); + putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, attr2); INCDEC_SET_FLAG(INCDEC_SOURCE); } + else if (cstate == CS_VTIMER) { + lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT|attr1); + lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2+1, LEFT|attr2); + v1_max = 99; v2_max = 99; + INCDEC_SET_FLAG(0); + } else { - putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, (m_posHorz==1 ? attr : 0)); - if (m_posHorz == 1) + putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1); + if (horz == 1) INCDEC_SET_FLAG(INCDEC_SOURCE); else INCDEC_SET_FLAG(0); #if defined(FRSKY) if (cs->v1 >= MIXSRC_FIRST_TELEM) { - putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT | (m_posHorz==2 ? attr : 0)); + putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT|attr2); v2_max = maxTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1); if (cstate == CS_VOFS) { v2_min = -128; @@ -3975,43 +3997,43 @@ void menuModelCustomSwitches(uint8_t event) } } else { - lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT | (m_posHorz==2 ? attr : 0)); + lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT|attr2); v2_min = -125; v2_max = 125; } #else if (cs->v1 >= MIXSRC_FIRST_TELEM) { - putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT | (m_posHorz==2 ? attr : 0)); + putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT|attr2); v2_min = -128; v2_max = 127; } else { - lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT | (m_posHorz==2 ? attr : 0)); + lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT|attr2); v2_min = -125; v2_max = 125; } #endif } // CSW and switch - putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, m_posHorz==3 ? attr : 0); + putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==3 ? attr : 0); #if defined(CPUARM) // CSW duration if (cs->duration > 0) - lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (m_posHorz==4 ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==4 ? attr : 0)|PREC1|LEFT); else - lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, m_posHorz==4 ? attr : 0); + lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==4 ? attr : 0); // CSW delay if (cs->delay > 0) - lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (m_posHorz==5 ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==5 ? attr : 0)|PREC1|LEFT); else - lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, m_posHorz==5 ? attr : 0); + lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==5 ? attr : 0); #endif if ((s_editMode>0 || p1valdiff) && attr) { - switch (m_posHorz) { + switch (horz) { case CSW_FIELD_FUNCTION: CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, CS_MAXF); - if (cstate != CS_STATE(cs->func)) { + if (cstate != cswFamily(cs->func)) { cs->v1 = 0; cs->v2 = 0; } @@ -4270,21 +4292,20 @@ void menuModelCustomFunctions(uint8_t event) #endif ) { switch (CFN_GVAR_MODE(sd)) { - // TODO constants - case 0: + 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 1: + case FUNC_ADJUST_GVAR_SOURCE: val_max = MIXSRC_LAST_CH-1; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+1, attr); break; - case 2: + 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: + default: // FUNC_ADJUST_GVAR_INC val_max = 1; lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\002-1+1"), val_displayed, attr); break; @@ -4439,9 +4460,15 @@ enum menuModelTelemetryItems { #define SCREEN_TYPE_ROWS (uint8_t)-1 #endif +#if defined(TOTO) + #define VARIO_RANGE_ROWS 1 +#else + #define VARIO_RANGE_ROWS 3 +#endif + void menuModelTelemetry(uint8_t event) { - MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, CHANNEL_ROWS CHANNEL_ROWS RSSI_ROWS USRDATA_LINES 0, 0, IF_VARIO((uint8_t)-1) IF_VARIO(0) IF_VARIO(3) SCREEN_TYPE_ROWS, 2, 2, 2, 2, SCREEN_TYPE_ROWS, 2, 2, 2, 2, IF_CPUARM(SCREEN_TYPE_ROWS) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) }); + MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, CHANNEL_ROWS CHANNEL_ROWS RSSI_ROWS USRDATA_LINES 0, 0, IF_VARIO((uint8_t)-1) IF_VARIO(0) IF_VARIO(VARIO_RANGE_ROWS) SCREEN_TYPE_ROWS, 2, 2, 2, 2, SCREEN_TYPE_ROWS, 2, 2, 2, 2, IF_CPUARM(SCREEN_TYPE_ROWS) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) }); uint8_t sub = m_posVert - 1; @@ -4625,6 +4652,20 @@ void menuModelTelemetry(uint8_t event) case ITEM_TELEMETRY_VARIO_RANGE: lcd_putsLeft(y, STR_LIMIT); +#if defined(TOTO) + lcd_outdezAtt(TELEM_COL2, y, 5+g_model.frsky.varioCenterMax, (m_posHorz==0 ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(TELEM_COL2+8*FW, y, 10+g_model.frsky.varioMax, (m_posHorz==1 ? attr : 0)); + if (attr && (s_editMode>0 || p1valdiff)) { + switch (m_posHorz) { + case 0: + CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioCenterMax, -15, +15); + break; + case 1: + CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioMax, -7, 7); + break; + } + } +#else lcd_outdezAtt(TELEM_COL2, y, -10+g_model.frsky.varioMin, (m_posHorz<=0 ? attr : 0)|LEFT); if (g_model.frsky.varioCenterMin == -16) lcd_putsAtt(TELEM_COL2+4*FW-2, y, STR_OFF, m_posHorz==1 ? attr : 0); @@ -4648,6 +4689,7 @@ void menuModelTelemetry(uint8_t event) break; } } +#endif break; #endif @@ -4724,8 +4766,8 @@ void menuModelTelemetry(uint8_t event) putsTelemetryChannel(TELEM_BARS_COLMIN, y, barSource-1, convertTelemValue(barSource, bar.barMin), (m_posHorz==1 ? attr : 0) | LEFT); putsTelemetryChannel(TELEM_BARS_COLMAX, y, barSource-1, convertTelemValue(barSource, 255-bar.barMax), (m_posHorz==2 ? attr : 0) | LEFT); } - else if (attr && m_posHorz>0) { - REPEAT_LAST_CURSOR_MOVE(); + else if (attr) { + MOVE_CURSOR_FROM_HERE(); } if (attr && (s_editMode>0 || p1valdiff)) { switch (m_posHorz) { diff --git a/src/gui/menus.h b/src/gui/menus.h index 941d857b3..95b9aedfa 100644 --- a/src/gui/menus.h +++ b/src/gui/menus.h @@ -204,39 +204,41 @@ void title(const pm_char * s); #define TITLE(str) title(str) #if defined(CPUARM) -#define MENU(title, tab, menu, lines_count, ...) \ -const uint8_t mstate_tab[] = __VA_ARGS__; \ -if (!check(event,menu,tab,DIM(tab),mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; \ -TITLE(title) + #define MENU_TAB(...) const uint8_t mstate_tab[] = __VA_ARGS__ #else -#define MENU(title, tab, menu, lines_count, ...) \ -static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \ -if (!check(event,menu,tab,DIM(tab),mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; \ -TITLE(title) + #define MENU_TAB(...) static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__ #endif +#define MENU_CHECK(tab, menu, lines_count) \ + check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, (lines_count)-1) + +#define MENU(title, tab, menu, lines_count, ...) \ + MENU_TAB(__VA_ARGS__); \ + if (!MENU_CHECK(tab, menu, lines_count)) return; \ + TITLE(title) + #define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \ -if (!check_simple(event,menu,tab,DIM(tab),(lines_count)-1)) return; + if (!check_simple(event,menu,tab,DIM(tab),(lines_count)-1)) return; #define SIMPLE_MENU(title, tab, menu, lines_count) \ -SIMPLE_MENU_NOTITLE(tab, menu, lines_count); \ -TITLE(title) + SIMPLE_MENU_NOTITLE(tab, menu, lines_count); \ + TITLE(title) #define SUBMENU_NOTITLE(lines_count, ...) { \ -static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \ -if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; } + static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \ + if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; } #define SUBMENU(title, lines_count, ...) \ -static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \ -if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; \ -TITLE(title) + static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \ + if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; \ + TITLE(title) #define SIMPLE_SUBMENU_NOTITLE(lines_count) \ -if (!check_submenu_simple(event,(lines_count)-1)) return; + if (!check_submenu_simple(event,(lines_count)-1)) return; #define SIMPLE_SUBMENU(title, lines_count) \ -SIMPLE_SUBMENU_NOTITLE(lines_count); \ -TITLE(title) + SIMPLE_SUBMENU_NOTITLE(lines_count); \ + TITLE(title) int8_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, int8_t value, int8_t min, int8_t max, LcdFlags attr, uint8_t event); uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, LcdFlags attr, uint8_t event ); @@ -342,10 +344,13 @@ void menuChannelsView(uint8_t event); #if defined(PCBTARANIS) #define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else m_posHorz = 0; } + #define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE() #elif defined(ROTARY_ENCODER_NAVIGATION) #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; + #define MOVE_CURSOR_FROM_HERE() REPEAT_LAST_CURSOR_MOVE() #endif #if defined(PCBTARANIS) diff --git a/src/gui/view_main.cpp b/src/gui/view_main.cpp index 1d2e11169..a657c4fba 100644 --- a/src/gui/view_main.cpp +++ b/src/gui/view_main.cpp @@ -317,28 +317,30 @@ void displayTimers() { // Main timer if (g_model.timers[0].mode) { - putsTime(TIMERS_X, TIMER1_Y, s_timerVal[0], MIDSIZE|LEFT, MIDSIZE|LEFT); + 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, SWCONDENSED|SMLSIZE); if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE); - if (s_timerVal[0] < 0) lcd_hline(TIMERS_X-6, TIMER1_Y+2, 4); + if (timerState.val < 0) lcd_hline(TIMERS_X-6, TIMER1_Y+2, 4); } // Second timer if (g_model.timers[1].mode) { - putsTime(TIMERS_X, TIMER2_Y, s_timerVal[1], MIDSIZE|LEFT, MIDSIZE|LEFT); + 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, SWCONDENSED|SMLSIZE); if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE); - if (s_timerVal[1] < 0) lcd_hline(TIMERS_X-6, TIMER2_Y+2, 4); + if (timerState.val < 0) lcd_hline(TIMERS_X-6, TIMER2_Y+2, 4); } // Main timer beeping - if (s_timerState[0]==TMR_BEEPING) { + if (timersStates[0].state==TMR_BEEPING) { if (BLINK_ON_PHASE) lcd_filled_rect(TIMERS_X-17, TIMER1_Y, 70, 12); } // Second timer beeping - if (s_timerState[1]==TMR_BEEPING) { + if (timersStates[1].state==TMR_BEEPING) { if (BLINK_ON_PHASE) lcd_filled_rect(TIMERS_X-17, TIMER2_Y, 70, 12); } @@ -348,9 +350,10 @@ void displayTimers() { // Main timer if (g_model.timers[0].mode) { - uint8_t att = DBLSIZE | (s_timerState[0]==TMR_BEEPING ? BLINK|INVERS : 0); - putsTime(12*FW+2+10*FWNUM-4, FH*2, s_timerVal[0], att, att); - putsTmrMode(s_timerVal[0] >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode, SWCONDENSED); + TimerState & timerState = timersStates[0]; + uint8_t att = DBLSIZE | (timerState.state==TMR_BEEPING ? 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, SWCONDENSED); } } #endif @@ -564,7 +567,8 @@ void menuMainView(uint8_t event) case EVT_KEY_TELEMETRY: #if defined(FRSKY) - chainMenu(menuTelemetryFrsky); + if (!IS_FAI_ENABLED()) + chainMenu(menuTelemetryFrsky); #elif defined(JETI) JETI_EnableRXD(); // enable JETI-Telemetry reception chainMenu(menuTelemetryJeti); @@ -583,8 +587,8 @@ void menuMainView(uint8_t event) return; case EVT_KEY_FIRST(KEY_EXIT): - if (s_timerState[0]==TMR_BEEPING) { - s_timerState[0] = TMR_STOPPED; + if (timersStates[0].state==TMR_BEEPING) { + timersStates[0].state = TMR_STOPPED; } else if (s_global_warning) { s_global_warning = NULL; @@ -796,8 +800,8 @@ void menuMainView(uint8_t event) } } else { // timer2 - putsTime(33+FW+2+10*FWNUM-4, FH*5, s_timerVal[1], DBLSIZE, DBLSIZE); - putsTmrMode(s_timerVal[1] >= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode, SWCONDENSED); + 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, SWCONDENSED); // lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s } #endif // PCBTARANIS diff --git a/src/gui/view_statistics.cpp b/src/gui/view_statistics.cpp index 3c0fafd2d..5d13bdc56 100644 --- a/src/gui/view_statistics.cpp +++ b/src/gui/view_statistics.cpp @@ -54,8 +54,8 @@ void menuStatisticsView(uint8_t event) } lcd_puts( 1*FW, FH*1, STR_TM1TM2); - putsTime( 5*FW+5*FWNUM+1, FH*1, s_timerVal[0], 0, 0); - putsTime( 12*FW+5*FWNUM+1, FH*1, s_timerVal[1], 0, 0); + putsTime( 5*FW+5*FWNUM+1, FH*1, timersStates[0].val, 0, 0); + putsTime( 12*FW+5*FWNUM+1, FH*1, timersStates[1].val, 0, 0); lcd_puts( 1*FW, FH*2, STR_THRTHP); putsTime( 5*FW+5*FWNUM+1, FH*2, s_timeCumThr, 0, 0); diff --git a/src/lcd.cpp b/src/lcd.cpp index 51746dfa8..c7e60ff0d 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -685,8 +685,8 @@ void lcdDrawTelemetryTopBar() uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0); putsVBat(14*FW,0,att); if (g_model.timers[0].mode) { - att = (s_timerState[0]==TMR_BEEPING ? BLINK : 0); - putsTime(17*FW+5*FWNUM+1, 0, s_timerVal[0], att, att); + att = (timersStates[0].state==TMR_BEEPING ? BLINK : 0); + putsTime(17*FW+5*FWNUM+1, 0, timersStates[0].val, att, att); } lcd_invert_line(0); } @@ -697,13 +697,13 @@ void lcdDrawTelemetryTopBar() uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0); putsVBat(16*FW+2,0,att); if (g_model.timers[0].mode) { - att = (s_timerState[0]==TMR_BEEPING ? BLINK : 0); - putsTime(22*FW+5*FWNUM+1, 0, s_timerVal[0], att, att); + att = (timersStates[0].state==TMR_BEEPING ? BLINK : 0); + putsTime(22*FW+5*FWNUM+1, 0, timersStates[0].val, att, att); lcd_putsiAtt(18*FW+2, 1, STR_VTELEMCHNS, TELEM_TM1, SMLSIZE); } if (g_model.timers[1].mode) { - att = (s_timerState[1]==TMR_BEEPING ? BLINK : 0); - putsTime(31*FW+5*FWNUM+1, 0, s_timerVal[1], att, att); + att = (timersStates[1].state==TMR_BEEPING ? BLINK : 0); + putsTime(31*FW+5*FWNUM+1, 0, timersStates[1].val, att, att); lcd_putsiAtt(27*FW+2, 1, STR_VTELEMCHNS, TELEM_TM2, SMLSIZE); } lcd_invert_line(0); @@ -946,11 +946,11 @@ void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, Lc #if ROTARY_ENCODERS > 2 int16_t v; if(idx < (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)) - v = phaseaddress(phase)->rotaryEncoders[idx]; + v = phaseAddress(phase)->rotaryEncoders[idx]; else v = g_model.rotaryEncodersExtra[phase][idx - (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)]; #else - int16_t v = phaseaddress(phase)->rotaryEncoders[idx]; + int16_t v = phaseAddress(phase)->rotaryEncoders[idx]; #endif if (v > ROTARY_ENCODER_MAX) { diff --git a/src/myeeprom.h b/src/myeeprom.h index 716b02b92..b4910c98f 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -282,16 +282,16 @@ PACK(typedef struct t_EEGeneral { TrainerData trainer; uint8_t view; // index of view in main screen int8_t buzzerMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all - uint8_t spare1:1; + uint8_t fai:1; int8_t beepMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all uint8_t alarmsFlash:1; uint8_t disableMemoryWarning:1; uint8_t disableAlarmWarning:1; uint8_t stickMode:2; int8_t timezone:5; - uint8_t spare2:1; + uint8_t spare1:1; uint8_t inactivityTimer; - uint8_t spare3:3; + uint8_t spare2:3; SPLASH_MODE; /* 3bits */ int8_t hapticMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all uint8_t blOffBright:4; @@ -606,6 +606,13 @@ enum ResetFunctionParam { FUNC_RESET_PARAM_LAST = FUNC_RESET_PARAMS_COUNT-1 }; +enum AdjustGvarFunctionParam { + FUNC_ADJUST_GVAR_CONSTANT, + FUNC_ADJUST_GVAR_SOURCE, + FUNC_ADJUST_GVAR_GVAR, + FUNC_ADJUST_GVAR_INC, +}; + #if defined(CPUARM) #if defined(PCBTARANIS) #define LEN_CFN_NAME 10 diff --git a/src/opentx.cpp b/src/opentx.cpp index 7c90956f3..4b8ad71ea 100644 --- a/src/opentx.cpp +++ b/src/opentx.cpp @@ -316,36 +316,36 @@ void per10ms() heartbeat |= HEART_TIMER_10MS; } -PhaseData *phaseaddress(uint8_t idx) +PhaseData *phaseAddress(uint8_t idx) { return &g_model.phaseData[idx]; } -ExpoData *expoaddress(uint8_t idx ) +ExpoData *expoAddress(uint8_t idx ) { return &g_model.expoData[idx]; } -MixData *mixaddress(uint8_t idx) +MixData *mixAddress(uint8_t idx) { return &g_model.mixData[idx]; } -LimitData *limitaddress(uint8_t idx) +LimitData *limitAddress(uint8_t idx) { return &g_model.limitData[idx]; } -int8_t *curveaddress(uint8_t idx) +int8_t *curveAddress(uint8_t idx) { return &g_model.points[idx==0 ? 0 : 5*idx+g_model.curves[idx-1]]; } -CurveInfo curveinfo(uint8_t idx) +CurveInfo curveInfo(uint8_t idx) { CurveInfo result; - result.crv = curveaddress(idx); - int8_t *next = curveaddress(idx+1); + result.crv = curveAddress(idx); + int8_t *next = curveAddress(idx+1); uint8_t size = next - result.crv; if ((size & 1) == 0) { result.points = (size / 2) + 1; @@ -358,11 +358,16 @@ CurveInfo curveinfo(uint8_t idx) return result; } -CustomSwData *cswaddress(uint8_t idx) +CustomSwData *cswAddress(uint8_t idx) { return &g_model.customSw[idx]; } +uint8_t cswFamily(uint8_t func) +{ + return (funcdestCh = i; md->weight = 100; md->srcRaw = channel_order(i+1); @@ -452,7 +457,7 @@ void modelDefault(uint8_t id) int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100 { - CurveInfo crv = curveinfo(idx); + CurveInfo crv = curveInfo(idx); int16_t erg = 0; x+=RESXu; @@ -754,7 +759,7 @@ int8_t calcRESXto100(int16_t x) // rescaled from -262144 to 262144 int16_t applyLimits(uint8_t channel, int32_t value) { - LimitData * lim = limitaddress(channel); + LimitData * lim = limitAddress(channel); int16_t ofs = calc1000toRESX(lim->offset); // multiply to 1.24 to get range (-1024..1024) int16_t lim_p = calc100toRESX(lim->max + 100); int16_t lim_n = calc100toRESX(lim->min - 100); //multiply by 10.24 to get same range (-1024..1024) @@ -859,7 +864,7 @@ getvalue_t getValue(uint8_t i) else if (iandsw; if (cs->func == CS_OFF || (s && !__getSwitch(s))) { result = false; } - else if ((s=CS_STATE(cs->func)) == CS_VBOOL) { + else if ((s=cswFamily(cs->func)) == CS_VBOOL) { bool res1 = __getSwitch(cs->v1); bool res2 = __getSwitch(cs->v2); switch (cs->func) { @@ -960,6 +965,9 @@ bool __getSwitch(int8_t swtch) break; } } + else if (s == CS_VTIMER) { + result = int8_t(csLastValue[cs_idx]) >= 0; + } else { getvalue_t x = getValue(cs->v1-1); getvalue_t y; @@ -1194,7 +1202,7 @@ uint8_t getFlightPhase() int16_t getRawTrimValue(uint8_t phase, uint8_t idx) { - PhaseData *p = phaseaddress(phase); + PhaseData *p = phaseAddress(phase); #if defined(PCBSTD) return (((int16_t)p->trim[idx]) << 2) + ((p->trim_ext >> (2*idx)) & 0x03); #else @@ -1209,7 +1217,7 @@ int16_t getTrimValue(uint8_t phase, uint8_t idx) void setTrimValue(uint8_t phase, uint8_t idx, int16_t trim) { - PhaseData *p = phaseaddress(phase); + PhaseData *p = phaseAddress(phase); #if defined(PCBSTD) p->trim[idx] = (int8_t)(trim >> 2); p->trim_ext = (p->trim_ext & ~(0x03 << (2*idx))) + (((trim & 0x03) << (2*idx))); @@ -1241,11 +1249,11 @@ uint8_t getRotaryEncoderFlightPhase(uint8_t idx) #if ROTARY_ENCODERS > 2 int16_t value; if(idx<(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)) - value = phaseaddress(phase)->rotaryEncoders[idx]; + value = phaseAddress(phase)->rotaryEncoders[idx]; else value = g_model.rotaryEncodersExtra[phase][idx-(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)]; #else - int16_t value = phaseaddress(phase)->rotaryEncoders[idx]; + int16_t value = phaseAddress(phase)->rotaryEncoders[idx]; #endif if (value <= ROTARY_ENCODER_MAX) return phase; uint8_t result = value-ROTARY_ENCODER_MAX-1; @@ -1261,7 +1269,7 @@ int16_t getRotaryEncoder(uint8_t idx) if(idx >= (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)) return g_model.rotaryEncodersExtra[getRotaryEncoderFlightPhase(idx)][idx-(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)]; #endif - return phaseaddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]; + return phaseAddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]; } void incRotaryEncoder(uint8_t idx, int8_t inc) @@ -1270,11 +1278,11 @@ void incRotaryEncoder(uint8_t idx, int8_t inc) #if ROTARY_ENCODERS > 2 int16_t *value; if (idx < (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)) - value = &(phaseaddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]); + value = &(phaseAddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]); else value = &(g_model.rotaryEncodersExtra[getRotaryEncoderFlightPhase(idx)][idx-(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)]); #else - int16_t *value = &(phaseaddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]); + int16_t *value = &(phaseAddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]); #endif *value = limit((int16_t)-1024, (int16_t)(*value + (inc * 8)), (int16_t)+1024); eeDirty(EE_MODEL); @@ -1441,7 +1449,7 @@ getvalue_t convertTelemValue(uint8_t channel, uint8_t value) getvalue_t convertCswTelemValue(CustomSwData * cs) { getvalue_t val; - if (CS_STATE(cs->func)==CS_VOFS) + if (cswFamily(cs->func)==CS_VOFS) val = convertTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2); else val = convertTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2) - convertTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128); @@ -2049,17 +2057,15 @@ uint8_t flashCounter = 0; uint16_t s_timeCumTot; uint16_t s_timeCumThr; // THR in 1/16 sec uint16_t s_timeCum16ThrP; // THR% in 1/16 sec -uint8_t s_timerState[2]; -int16_t s_timerVal[2]; -uint8_t s_timerVal_10ms[2] = {0, 0}; uint8_t trimsCheckTimer = 0; void resetTimer(uint8_t idx) { - s_timerState[idx] = TMR_OFF; // is changed to RUNNING dep from mode - s_timerVal[idx] = g_model.timers[idx].start; - s_timerVal_10ms[idx] = 0 ; + TimerState & timerState = timersStates[idx]; + timerState.state = TMR_OFF; // is changed to RUNNING dep from mode + timerState.val = g_model.timers[idx].start; + timerState.val_10ms = 0 ; } void resetAll() @@ -2076,7 +2082,7 @@ void resetAll() resetTelemetry(); #endif for (uint8_t i=0; i=500*repeatParam)) { @@ -2609,7 +2612,7 @@ void evalFunctions() } } } - else if (CFN_FUNC(sd) == FUNC_BACKGND_MUSIC) { + else if (!IS_FAI_ENABLED() && (CFN_FUNC(sd) == FUNC_BACKGND_MUSIC)) { if (!IS_PLAYING(i+1)) { playCustomFunctionFile(sd, i+1); } @@ -2623,7 +2626,7 @@ void evalFunctions() } } #elif defined(VOICE) - else if (CFN_FUNC(sd) == FUNC_PLAY_TRACK || CFN_FUNC(sd) == FUNC_PLAY_BOTH || CFN_FUNC(sd) == FUNC_PLAY_VALUE) { + else if (!IS_FAI_ENABLED() && (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)) { @@ -2808,7 +2811,7 @@ void perOut(uint8_t mode, uint8_t tick10ms) if (mode==e_perout_mode_normal && pass==0) swOn[i].activeMix = 0; #endif - MixData *md = mixaddress(i); + MixData *md = mixAddress(i); if (md->srcRaw == 0) break; @@ -2977,7 +2980,7 @@ void perOut(uint8_t mode, uint8_t tick10ms) *ptr = dv; #if defined(BOLD_FONT) if (mode==e_perout_mode_normal) { - for (uint8_t m=i-1; mdestCh==md->destCh; m--) + for (uint8_t m=i-1; mdestCh==md->destCh; m--) swOn[m].activeMix = false; } #endif @@ -3178,17 +3181,17 @@ void doMixerCalculations() uint8_t ch = g_model.thrTraceSrc-NUM_POTS-1; val = channelOutputs[ch]; - int16_t gModelMax = calc100toRESX(g_model.limitData[ch].max)+1024; - int16_t gModelMin = calc100toRESX(g_model.limitData[ch].min)-1024; + int16_t gModelMax = calc100toRESX(limitAddress(ch)->max)+1024; + int16_t gModelMin = calc100toRESX(limitAddress(ch)->min)-1024; - if (g_model.limitData[ch].revert) + if (limitAddress(ch)->revert) val = -val + gModelMax; else val = val - gModelMin; #if defined(PPM_LIMITS_SYMETRICAL) - if (g_model.limitData[ch].symetrical) - val -= calc1000toRESX(g_model.limitData[ch].offset); + if (limitAddress(ch)->symetrical) + val -= calc1000toRESX(limitAddress(ch)->offset); #endif // @@@ open.20.fsguruh optimized calculation; now *8 /8 instead of 10 base; (*16/16 already cause a overrun; unsigned calculation also not possible, because v may be negative) gModelMax -= gModelMin; // we compare difference between Max and Mix for recaling needed; Max and Min are shifted to 0 by default @@ -3196,10 +3199,10 @@ void doMixerCalculations() gModelMax >>= (10-2); if (gModelMax != 8) - val = (val << 3) / (gModelMax); // recaling only needed if Min, Max differs + val = (val << 3) / (gModelMax); // rescaling only needed if Min, Max differs // if (gModelMax!=2048) val = (int32_t) (val << 11) / (gModelMax); // recaling only needed if Min, Max differs - // val = val * 10 / (10+(g_model.limitData[ch].max-g_model.limitData[ch].min)/20); + // val = val * 10 / (10+(limitAddress(ch)->max-limitAddress(ch)->min)/20); if (val<0) val=0; // prevent val be negative, which would corrupt throttle trace and timers; could occur if safetyswitch is smaller than limits } else { @@ -3223,12 +3226,13 @@ void doMixerCalculations() for (uint8_t i=0; istate == TMR_OFF) { + timerState->state = TMR_RUNNING; + timerState->cnt = 0; + timerState->sum = 0; } uint8_t atm = (tm >= 0 ? tm : TMR_VAROFS-tm-1); @@ -3236,20 +3240,20 @@ void doMixerCalculations() // value for time described in timer->mode // OFFABSTHsTH%THt if (atm == TMRMODE_THR_REL) { - s_cnt[i]++; - s_sum[i]+=val; + timerState->cnt++; + timerState->sum+=val; } if (atm>=(TMR_VAROFS+MAX_SWITCH)){ // toggeled switch - if(!(sw_toggled[i] | s_sum[i] | s_cnt[i] | lastSwPos[i])) { lastSwPos[i] = tm < 0; s_sum[i] = 1; } // if initializing then init the lastSwPos + 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+MAX_SWITCH-1) : tm+MAX_SWITCH); - if (swPos && !lastSwPos[i]) sw_toggled[i] = !sw_toggled[i]; // if switch is flipped first time -> change counter state - lastSwPos[i] = swPos; + if (swPos && !timerState->lastPos) timerState->toggled = !timerState->toggled; // if switch is flipped first time -> change counter state + timerState->lastPos = swPos; } - if ( (s_timerVal_10ms[i] += tick10ms ) >= 100 ) { - s_timerVal_10ms[i] -= 100 ; - int16_t newTimerVal = s_timerVal[i]; + if ((timerState->val_10ms += tick10ms) >= 100) { + timerState->val_10ms -= 100 ; + int16_t newTimerVal = timerState->val; if (tv) newTimerVal = tv - newTimerVal; if (atm==TMRMODE_ABS) { @@ -3262,17 +3266,17 @@ void doMixerCalculations() // @@@ 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) - if ((s_sum[i]/s_cnt[i])>=128) { // throttle was normalized to 0 to 128 value (throttle/64*2 (because - range is added as well) + if ((timerState->sum/timerState->cnt)>=128) { // throttle was normalized to 0 to 128 value (throttle/64*2 (because - range is added as well) newTimerVal++; // add second used of throttle - s_sum[i]-=128*s_cnt[i]; + timerState->sum-=128*timerState->cnt; } #else - if ((s_sum[i]/s_cnt[i])>=32) { // throttle was normalized to 0 to 32 value (throttle/16*2 (because - range is added as well) + if ((timerState->sum/timerState->cnt)>=32) { // throttle was normalized to 0 to 32 value (throttle/16*2 (because - range is added as well) newTimerVal++; // add second used of throttle - s_sum[i]-=32*s_cnt[i]; + timerState->sum-=32*timerState->cnt; } #endif - s_cnt[i]=0; + timerState->cnt=0; } else if (atm==TMRMODE_THR_TRG) { if (val || newTimerVal > 0) @@ -3280,26 +3284,26 @@ void doMixerCalculations() } else { if (atm<(TMR_VAROFS+MAX_SWITCH)) - sw_toggled[i] = tm>0 ? getSwitch(tm-(TMR_VAROFS-1)) : !getSwitch(-tm); // normal switch - if (sw_toggled[i]) + timerState->toggled = tm>0 ? getSwitch(tm-(TMR_VAROFS-1)) : !getSwitch(-tm); // normal switch + if (timerState->toggled) newTimerVal++; } - switch(s_timerState[i]) + switch(timerState->state) { case TMR_RUNNING: - if (tv && newTimerVal>=(int16_t)tv) s_timerState[i]=TMR_BEEPING; + if (tv && newTimerVal>=(int16_t)tv) timerState->state = TMR_BEEPING; break; case TMR_BEEPING: - if (newTimerVal >= (int16_t)tv + MAX_ALERT_TIME) s_timerState[i]=TMR_STOPPED; + if (newTimerVal >= (int16_t)tv + MAX_ALERT_TIME) timerState->state = TMR_STOPPED; break; } if (tv) newTimerVal = tv - newTimerVal; //if counting backwards - display backwards - if (newTimerVal != s_timerVal[i]) { // beep only if seconds advance - s_timerVal[i] = newTimerVal; - if (s_timerState[i] == TMR_RUNNING) { + if (newTimerVal != timerState->val) { // beep only if seconds advance + timerState->val = newTimerVal; + if (timerState->state == TMR_RUNNING) { if (g_model.timers[i].countdownBeep && g_model.timers[i].start) { // beep when 30, 15, 10, 5,4,3,2,1 seconds remaining if (newTimerVal==30) AUDIO_TIMER_30(); // beep three times if (newTimerVal==20) AUDIO_TIMER_20(); // beep two times @@ -3310,7 +3314,7 @@ void doMixerCalculations() AUDIO_TIMER_MINUTE(newTimerVal); } } - else if (s_timerState[0] == TMR_BEEPING) { + else if (timerState->state == TMR_BEEPING) { AUDIO_WARNING1(); } } @@ -3330,7 +3334,7 @@ void doMixerCalculations() s_cnt_1s++; s_sum_1s+=val; - // @@@ open.20.fsguruh: moved code here; at least val variable conflicts with caculations above, safer here? + // @@@ open.20.fsguruh: moved code here; at least val variable conflicts with calculations above, safer here? // even reduced code size about 8 bytes, why ever? if ((tmr10ms_t)(tmr10ms - s_time_tot) >= 100) { // 1sec s_time_tot += 100; @@ -3338,7 +3342,6 @@ void doMixerCalculations() struct t_inactivity *ptrInactivity = &inactivity; FORCE_INDIRECT(ptrInactivity) ; - ptrInactivity->counter++; if ((((uint8_t)ptrInactivity->counter)&0x07)==0x01 && g_eeGeneral.inactivityTimer && g_vbat100mV>50 && ptrInactivity->counter > ((uint16_t)g_eeGeneral.inactivityTimer*60)) AUDIO_INACTIVITY(); @@ -3381,6 +3384,30 @@ void doMixerCalculations() s_cnt_1s = 0; s_sum_1s = 0; + + for (uint8_t i=0; ifunc == CS_TIMER) { + if (*lastValue == 0) { + *lastValue = -cs->v1-1; + } + else if (*lastValue < 0) { + if (++(*lastValue) == 0) + *lastValue = cs->v2; + } + else { // if (*lastValue > 0) + *lastValue -= 1; + } + if (cs->andsw) { + int8_t x; + x = cs->andsw; + if (!getSwitch(x) == 0) { + *lastValue = -1; + } + } + } + } } if (s_fade_flight_phases) { @@ -3440,34 +3467,25 @@ static const pm_uint8_t rate[] PROGMEM = { 0, 0, 100, 40, 16, 7, 3, 1 } ; uint8_t calcStickScroll( uint8_t index ) { - uint8_t direction ; - int8_t value ; + uint8_t direction; + int8_t value; - if ( ( g_eeGeneral.stickMode & 1 ) == 0 ) - { - index ^= 3 ; - } + if ( ( g_eeGeneral.stickMode & 1 ) == 0 ) + index ^= 3; - value = calibratedStick[index] / 128 ; - direction = value > 0 ? 0x80 : 0 ; - if ( value < 0 ) - { - value = -value ; // (abs) - } - if ( value > 7 ) - { - value = 7 ; - } - value = pgm_read_byte(rate+(uint8_t)value) ; - if ( value ) - { - StickScrollTimer = STICK_SCROLL_TIMEOUT ; // Seconds - } - return value | direction ; + value = calibratedStick[index] / 128; + direction = value > 0 ? 0x80 : 0; + if (value < 0) + value = -value; // (abs) + if (value > 7) + value = 7; + value = pgm_read_byte(rate+(uint8_t)value); + if (value) + StickScrollTimer = STICK_SCROLL_TIMEOUT; // Seconds + return value | direction; } #endif - void perMain() { #if defined(SIMU) @@ -4033,8 +4051,9 @@ void saveTimers() { for (uint8_t i=0; ival) { + g_model.timers[i].value = timerState->val; eeDirty(EE_MODEL); } } diff --git a/src/opentx.h b/src/opentx.h index 51049ed57..33a548743 100644 --- a/src/opentx.h +++ b/src/opentx.h @@ -198,6 +198,17 @@ typedef __int24 int24_t; #endif +#if defined(FAI) + #define IS_FAI_ENABLED() true + #define IF_FAI_CHOICE(x) +#elif defined(FAI_CHOICE) + #define IS_FAI_ENABLED() g_eeGeneral.fai + #define IF_FAI_CHOICE(x) x, +#else + #define IS_FAI_ENABLED() false + #define IF_FAI_CHOICE(x) +#endif + #if defined(SIMU) #ifndef FORCEINLINE #define FORCEINLINE @@ -386,7 +397,7 @@ enum EnumKeys { #define PPM_CENTER 1500 #if defined(PPM_CENTER_ADJUSTABLE) - #define PPM_CH_CENTER(ch) (PPM_CENTER+limitaddress(ch)->ppmCenter) + #define PPM_CH_CENTER(ch) (PPM_CENTER+limitAddress(ch)->ppmCenter) #else #define PPM_CH_CENTER(ch) (PPM_CENTER) #endif @@ -581,15 +592,16 @@ enum CswFunctions { CS_LESS, CS_DIFFEGREATER, CS_ADIFFEGREATER, - // TODO add CS_TIMER, - CS_MAXF = CS_ADIFFEGREATER + CS_TIMER, + CS_MAXF = CS_TIMER }; -#define CS_VOFS 0 -#define CS_VBOOL 1 -#define CS_VCOMP 2 -#define CS_VDIFF 3 -#define CS_STATE(x) ((x)srcRaw && mix->destCh <= dch) { if (clear && mix->destCh == dch) deleteExpoMix(0, i); else { if (++i==MAX_MIXERS) { // TODO should return null pointer but needs to be tested then - mix = mixaddress(0); + mix = mixAddress(0); break; } } @@ -108,7 +108,7 @@ void clearCurves() void setCurve(uint8_t c, const pm_int8_t ar[]) { - int8_t * cv = curveaddress(c); + int8_t * cv = curveAddress(c); for (uint8_t i=0; i<5; i++) { cv[i] = pgm_read_byte(&ar[i]); } @@ -116,7 +116,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); + CustomSwData *cs = cswAddress(idx-1); cs->func = func; cs->v1 = v1; cs->v2 = v2; diff --git a/src/translations/cz.h b/src/translations/cz.h index c02f378e6..058eed61c 100644 --- a/src/translations/cz.h +++ b/src/translations/cz.h @@ -136,7 +136,7 @@ #define TR_VMIXTRIMS "VYP\0""ZAP\0""Sm\203r""V\212\207k""Plyn""K\206id" #define LEN_VCSWFUNC "\005" -#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""ax\0 ""ax""|a|b\0 ""a