From dbc0a161343bff7afca9029dd36846e0c998bd7e Mon Sep 17 00:00:00 2001 From: bsongis Date: Sat, 19 Jan 2013 10:40:26 +0000 Subject: [PATCH] [all] - Issue 159 fixed (Pots calibration) - Issue 174 fixed (Custom switches delta steps for telemetry) - Flash/RAM saving in vario function and "editName" function - -GVxx feature added [ACT] Global variables screen continued --- src/frsky.cpp | 41 ++++------ src/frsky.h | 3 +- src/general_menus.cpp | 12 +-- src/menus.cpp | 31 +++----- src/menus.h | 7 +- src/model_menus.cpp | 175 ++++++++++++++++++++++-------------------- src/myeeprom.h | 5 +- src/open9x.cpp | 55 +++++++++---- src/translations/en.h | 2 +- 9 files changed, 177 insertions(+), 154 deletions(-) diff --git a/src/frsky.cpp b/src/frsky.cpp index 5bee15865..43ec1b38a 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -780,33 +780,16 @@ NOINLINE void check_frsky() int16_t varioSpeedDownMin = (VARIO_SPEED_LIMIT_DOWN_OFF - g_model.frsky.varioSpeedDownMin)*(-VARIO_SPEED_LIMIT_MUL); int16_t verticalSpeed = limit((int16_t)(-VARIO_SPEED_LIMIT*100), frskyData.varioSpeed, (int16_t)(+VARIO_SPEED_LIMIT*100)); - uint8_t SoundVarioBeepNextFreq = 0; - uint8_t SoundVarioBeepNextTime = 0; - static uint8_t SoundVarioBeepFreq = 0; - static uint8_t SoundVarioBeepTime = 0; - if ((verticalSpeed < varioSpeedUpMin) && (verticalSpeed > varioSpeedDownMin)) { //check thresholds here in cm/s - SoundVarioBeepNextFreq = (0); - SoundVarioBeepNextTime = (0); - } - else { + if (verticalSpeed <= varioSpeedDownMin || verticalSpeed >= varioSpeedUpMin) { // check thresholds here in cm/s if (varioSpeedUpMin < 0 && verticalSpeed >= varioSpeedUpMin) { verticalSpeed -= varioSpeedUpMin; } - SoundVarioBeepNextFreq = (verticalSpeed * 10 + 16000) >> 8; - SoundVarioBeepNextTime = (1600 - verticalSpeed) / 100; - if (verticalSpeed >= 0) { - if ((uint16_t)(g_tmr10ms - s_varioTmr) > (uint16_t)SoundVarioBeepTime*2) { - s_varioTmr = g_tmr10ms; - SoundVarioBeepTime = SoundVarioBeepNextTime; - SoundVarioBeepFreq = SoundVarioBeepNextFreq; - AUDIO_VARIO(SoundVarioBeepFreq, SoundVarioBeepTime); - } - } - else { - // negative vertical speed gives sound without pauses - SoundVarioBeepTime = SoundVarioBeepNextTime; - SoundVarioBeepFreq = SoundVarioBeepNextFreq; - AUDIO_VARIO(SoundVarioBeepFreq, 1); + uint16_t tmr10ms = g_tmr10ms; + if (verticalSpeed < 0 || tmr10ms > s_varioTmr) { + uint8_t SoundVarioBeepTime = (1600 - verticalSpeed) / 100; + uint8_t SoundVarioBeepFreq = (verticalSpeed * 10 + 16000) >> 8; + s_varioTmr = tmr10ms + (SoundVarioBeepTime*2); + AUDIO_VARIO(SoundVarioBeepFreq, SoundVarioBeepTime); } } #else @@ -1036,6 +1019,16 @@ int16_t convertTelemValue(uint8_t channel, uint8_t value) return result; } +int16_t convertCswTelemValue(CustomSwData * cs) +{ + int16_t val; + if (CS_STATE(cs->func)==CS_VOFS) + val = convertTelemValue(cs->v1 - (CSW_CHOUT_BASE+NUM_CHNOUT), 128+cs->v2); + else + val = convertTelemValue(cs->v1 - (CSW_CHOUT_BASE+NUM_CHNOUT), 128+cs->v2) - convertTelemValue(cs->v1 - (CSW_CHOUT_BASE+NUM_CHNOUT), 128); + return val; +} + const pm_uint8_t bchunit_ar[] PROGMEM = { UNIT_METERS, // Alt UNIT_RAW, // Rpm diff --git a/src/frsky.h b/src/frsky.h index b0746cb57..4db0d318a 100644 --- a/src/frsky.h +++ b/src/frsky.h @@ -75,7 +75,7 @@ class FrskyValueWithMinMax: public FrskyValueWithMin { #define VARIO_SPEED_LIMIT_MUL 10 //to get 0.1m/s steps #define VARIO_SPEED_LIMIT_DOWN_OFF (100+1) //100 steps + OFF #define VARIO_SPEED_LIMIT_UP_CENTER 10 -#define VARIO_SPEED_LIMIT_UP_MAX 30 +#define VARIO_SPEED_LIMIT_UP_MAX (10+30) #if defined(FRSKY_HUB) PACK(struct FrskyHubData { @@ -212,6 +212,7 @@ bool FRSKY_alarmRaised(uint8_t idx); void resetTelemetry(); uint8_t maxTelemValue(uint8_t channel); int16_t convertTelemValue(uint8_t channel, uint8_t value); +int16_t convertCswTelemValue(CustomSwData * cs); NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm); extern const pm_uint8_t bchunit_ar[]; diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 42f761d30..de9ab080f 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -50,9 +50,7 @@ enum EnumTabDiag { }; void menuGeneralSetup(uint8_t event); -#if defined(SDCARD) void menuGeneralSdManager(uint8_t event); -#endif void menuGeneralTrainer(uint8_t event); void menuGeneralVersion(uint8_t event); void menuGeneralDiagKeys(uint8_t event); @@ -253,8 +251,7 @@ void menuGeneralSetup(uint8_t event) CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerVolume, 0, NUM_VOL_LEVELS-1); } #else - uint8_t b ; - b = g_eeGeneral.speakerVolume+7; + uint8_t b = g_eeGeneral.speakerVolume+7; lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, b, attr|LEFT); if (attr) { CHECK_INCDEC_GENVAR(event, b, 0, 7); @@ -429,7 +426,7 @@ void menuGeneralSetup(uint8_t event) #endif case ITEM_SETUP_RX_CHANNEL_ORD: - lcd_putsLeft( y,STR_RXCHANNELORD);// RAET->AETR + lcd_putsLeft(y, STR_RXCHANNELORD); // RAET->AETR for (uint8_t i=1; i<=4; i++) putsChnLetter(RADIO_SETUP_2ND_COLUMN - FW + i*FW, y, channel_order(i), attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23); @@ -999,6 +996,9 @@ void menuGeneralCalib(uint8_t event) int16_t vt = anaIn(i); reusableBuffer.calib.loVals[i] = min(vt, reusableBuffer.calib.loVals[i]); reusableBuffer.calib.hiVals[i] = max(vt, reusableBuffer.calib.hiVals[i]); + if (i >= NUM_STICKS) { + reusableBuffer.calib.midVals[i] = (reusableBuffer.calib.hiVals[i] + reusableBuffer.calib.loVals[i]) / 2; + } } s_noScroll = idxState; // make sure we don't scroll while calibrating @@ -1044,7 +1044,7 @@ void menuGeneralCalib(uint8_t event) for (uint8_t i=0; i50) { - g_eeGeneral.calibMid[i] = reusableBuffer.calib.midVals[i]; + if (i < NUM_STICKS) g_eeGeneral.calibMid[i] = reusableBuffer.calib.midVals[i]; int16_t v = reusableBuffer.calib.midVals[i] - reusableBuffer.calib.loVals[i]; g_eeGeneral.calibSpanNeg[i] = v - v/64; v = reusableBuffer.calib.hiVals[i] - reusableBuffer.calib.midVals[i]; diff --git a/src/menus.cpp b/src/menus.cpp index 8f058e855..1280ce37d 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -302,21 +302,11 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t return false; } - if (IS_RE_NAVIGATION_ENABLE() && event==EVT_KEY_BREAK(RE_NAV_ENTER)) { - if (s_editMode > 0 && (maxcol & ZCHAR)) { - if (l_posHorz < maxcol-ZCHAR) { - l_posHorz++; - } - else { - s_editMode = 0; - } - } - else { - scrollRE = 0; - if (s_editMode++ > 0) s_editMode = 0; - if (s_editMode > 0 && l_posVert == 0 && menuTab) s_editMode = -1; - if (maxrow == 0) s_editMode = -1; - } + if (IS_RE_NAVIGATION_ENABLE() && event==EVT_KEY_BREAK(RE_NAV_ENTER) && s_editMode != EDIT_MODIFY_STRING) { + scrollRE = 0; + if (s_editMode++ > 0) s_editMode = 0; + if (s_editMode > 0 && l_posVert == 0 && menuTab) s_editMode = -1; + if (maxrow == 0) s_editMode = -1; } #else #define scrollRE 0 @@ -420,7 +410,6 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t if (scrollRE > 0) { --scrollRE; maxcol = MAXCOL(l_posVert); - if (maxcol & ZCHAR) maxcol = 0; lastCursorMove = +1; if (++l_posHorz > maxcol) { if (l_posVert < maxrow) { @@ -428,7 +417,6 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t ++l_posVert; } while(MAXCOL(l_posVert) == (uint8_t)-1); maxcol = MAXCOL(l_posVert); - if (maxcol & ZCHAR) maxcol = 0; l_posHorz = 0; } else { @@ -466,7 +454,6 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t #endif else { maxcol = MAXCOL(l_posVert); - if (maxcol & ZCHAR) maxcol = 0; l_posHorz = maxcol; } } @@ -708,13 +695,15 @@ int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max, value = ((value >= 126 || value <= -126) ? GET_GVAR(value, min, max, s_perout_flight_phase) : 126); eeDirty(EE_MODEL); } - if (value >= 126 || value <= -126) { + if (value >= 126 || value <= -126 || (max <= 120 && value >= 121)) { if (attr & LEFT) attr -= LEFT; /* because of ZCHAR */ else x -= 2*FW+FWNUM; - putsStrIdx(x, y, STR_GV, (uint8_t)value - 125, attr); - if (invers) value = checkIncDec(event, (uint8_t)value, 126, 130, EE_MODEL); + int8_t idx = value - 125; + if (idx <= 0) { idx = 1-idx; lcd_putcAtt(x-6, y, '-', attr); } + putsStrIdx(x, y, STR_GV, idx, attr); + if (invers) value = checkIncDec(event, (uint8_t)value, max <= 120 ? 121 : 126, 130, EE_MODEL); } else { lcd_outdezAtt(x, y, value, attr); diff --git a/src/menus.h b/src/menus.h index 30b3c6b99..20921c1ec 100644 --- a/src/menus.h +++ b/src/menus.h @@ -122,7 +122,12 @@ extern int16_t p1valdiff; #endif extern int8_t checkIncDec_Ret; // global helper vars -extern int8_t s_editMode; // global editmode + +#define EDIT_SELECT_MENU -1 +#define EDIT_SELECT_FIELD 0 +#define EDIT_MODIFY_FIELD 1 +#define EDIT_MODIFY_STRING 2 +extern int8_t s_editMode; // global editmode // checkIncDec flags #define EE_GENERAL 0x01 diff --git a/src/model_menus.cpp b/src/model_menus.cpp index c5b5bfd7c..24712417b 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -560,17 +560,24 @@ void menuModelSelect(uint8_t event) #endif } -void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, bool active, uint8_t & cur) +void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, bool active) { +#if defined(CPUM64) + // in order to save flash lcd_putsLeft(y, STR_NAME); +#define cursorPos m_posHorz +#else + static uint8_t cursorPos = 0; +#endif lcd_putsnAtt(x, y, name, size, ZCHAR | (active ? ((s_editMode>0) ? 0 : INVERS) : 0)); if (active) { - if (s_editMode>0) { - uint8_t next = cur; - char c = name[next]; + uint8_t cur = cursorPos; + if (s_editMode > 0) { + char c = name[cur]; int8_t v = c; + if (p1valdiff || 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); @@ -578,24 +585,31 @@ void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, boo } switch (event) { +#if defined(ROTARY_ENCODER_NAVIGATION) #if defined(PCBX9D) || defined(PCBACT) case EVT_KEY_BREAK(KEY_ENTER): - if (next0) next--; - break; - case EVT_KEY_BREAK(KEY_RIGHT): - if (next0) cur--; + break; + case EVT_KEY_BREAK(KEY_RIGHT): + if (cur NUM_POTS) idx = NUM_STICKS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+3+NUM_PPM+g_model.thrTraceSrc; - else if (g_model.thrTraceSrc > 0) idx = NUM_STICKS+g_model.thrTraceSrc; - putsChnRaw(MODEL_SETUP_2ND_COLUMN, y, idx, attr); if (attr) CHECK_INCDEC_MODELVAR(event, g_model.thrTraceSrc, 0, NUM_POTS+NUM_CHNOUT); + uint8_t idx = g_model.thrTraceSrc + MIXSRC_Thr; + if (idx > MIXSRC_Thr) + idx += 1; + if (idx >= MIXSRC_Pot1+NUM_POTS) + idx += MIXSRC_CH1 - MIXSRC_Pot1 - NUM_POTS; + putsMixerSource(MODEL_SETUP_2ND_COLUMN, y, idx, attr); break; } @@ -1043,7 +1068,7 @@ enum menuModelPhaseItems { IF_ROTARY_ENCODERS(ITEM_MODEL_PHASE_ROTARY_ENCODERS) ITEM_MODEL_PHASE_FADE_IN, ITEM_MODEL_PHASE_FADE_OUT, -#if defined(GVARS) && !defined(CPUM64) +#if defined(GVARS) && !defined(CPUM64) && LCD_W < 260 ITEM_MODEL_PHASE_GVARS_LABEL, ITEM_MODEL_PHASE_GV1, ITEM_MODEL_PHASE_GV2, @@ -1059,13 +1084,9 @@ void menuModelPhaseOne(uint8_t event) PhaseData *phase = phaseaddress(s_currIdx); putsFlightPhase(13*FW, 0, s_currIdx+1, (getFlightPhase()==s_currIdx ? BOLD : 0)); -#if defined(GVARS) && !defined(CPUM64) - static bool editingName = false; - if (editingName && s_editMode <= 0) editingName = false; - if (!editingName && s_editMode > 0 && m_posHorz == 0) editingName = true; - - static const pm_uint8_t mstate_tab_phase1[] PROGMEM = {ZCHAR|(sizeof(phase->name)-1), 0, 0, (uint8_t)-1, 2, 2, 2, 2, 2}; - static const pm_uint8_t mstate_tab_others[] PROGMEM = {ZCHAR|(sizeof(phase->name)-1), 0, 3, IF_ROTARY_ENCODERS(NUM_ROTARY_ENCODERS-1) 0, 0, (uint8_t)-1, 2, 2, 2, 2, 2}; +#if defined(GVARS) && !defined(CPUM64) && LCD_W < 260 + static const pm_uint8_t mstate_tab_phase1[] PROGMEM = {0, 0, 0, (uint8_t)-1, 2, 2, 2, 2, 2}; + static const pm_uint8_t mstate_tab_others[] PROGMEM = {0, 0, 3, IF_ROTARY_ENCODERS(NUM_ROTARY_ENCODERS-1) 0, 0, (uint8_t)-1, 2, 2, 2, 2, 2}; if (!check(event, 0, NULL, 0, (s_currIdx == 0) ? mstate_tab_phase1 : mstate_tab_others, DIM(mstate_tab_others)-1, ITEM_MODEL_PHASE_MAX - 1 - (s_currIdx==0 ? (ITEM_MODEL_PHASE_FADE_IN-ITEM_MODEL_PHASE_SWITCH) : 0))) return; @@ -1073,14 +1094,14 @@ void menuModelPhaseOne(uint8_t event) #define PHASE_ONE_FIRST_LINE (1+1*FH) #else - SUBMENU(STR_MENUFLIGHTPHASE, 3 + (s_currIdx==0 ? 0 : 2 + (bool)NUM_ROTARY_ENCODERS), {ZCHAR|(sizeof(phase->name)-1), 0, 3, IF_ROTARY_ENCODERS(NUM_ROTARY_ENCODERS-1) 0/*, 0*/}); + SUBMENU(STR_MENUFLIGHTPHASE, 3 + (s_currIdx==0 ? 0 : 2 + (bool)NUM_ROTARY_ENCODERS), {0, 0, 3, IF_ROTARY_ENCODERS(NUM_ROTARY_ENCODERS-1) 0/*, 0*/}); #define PHASE_ONE_FIRST_LINE (1+1*FH) #endif int8_t sub = m_posVert; int8_t editMode = s_editMode; -#if defined(GVARS) && !defined(CPUM64) +#if defined(GVARS) && !defined(CPUM64) && LCD_W < 260 if (s_currIdx == 0 && sub>=ITEM_MODEL_PHASE_SWITCH) sub += ITEM_MODEL_PHASE_FADE_IN-ITEM_MODEL_PHASE_SWITCH; for (uint8_t k=0; kname, sizeof(phase->name), event, attr, m_posHorz); + editSingleName(MIXES_2ND_COLUMN, y, phase->name, sizeof(phase->name), event, attr); break; case ITEM_MODEL_PHASE_SWITCH: phase->swtch = switchMenuItem(MIXES_2ND_COLUMN, y, phase->swtch, attr, event); @@ -1157,7 +1178,7 @@ void menuModelPhaseOne(uint8_t event) phase->fadeOut = editDelay(y, event, attr, STR_FADEOUT, phase->fadeOut); break; -#if defined(GVARS) && !defined(CPUM64) +#if defined(GVARS) && !defined(CPUM64) && LCD_W < 260 case ITEM_MODEL_PHASE_GVARS_LABEL: lcd_putsLeft(y, STR_GLOBAL_VARS); break; @@ -1166,29 +1187,20 @@ void menuModelPhaseOne(uint8_t event) { uint8_t idx = i-ITEM_MODEL_PHASE_GV1; - if (editingName) { -#if defined(PCBX9D) || defined(PCBACT) - if (attr) s_editMode = 1; -#endif - editName(4*FW, y, g_model.gvarsNames[idx], sizeof(gvar_name_t), event, attr, m_posHorz); - } - else { - lcd_putsnAtt(4*FW, y, g_model.gvarsNames[idx], sizeof(gvar_name_t), ZCHAR|(m_posHorz==0 ? attr : 0)); - } - - lcd_putsLeft(y, PSTR(" ")); putsStrIdx(INDENT_WIDTH, y, STR_GV, idx+1); + editName(4*FW, y, g_model.gvarsNames[idx], sizeof(gvar_name_t), event, m_posHorz==0 ? attr : 0); + int16_t v = phase->gvars[idx]; if (v > GVAR_MAX) { uint8_t p = v - GVAR_MAX - 1; if (p >= s_currIdx) p++; - putsFlightPhase(MIXES_2ND_COLUMN, y, p+1, !editingName && m_posHorz==1 ? attr : 0); + putsFlightPhase(MIXES_2ND_COLUMN, y, p+1, m_posHorz==1 ? attr : 0); } else { - lcd_putsAtt(MIXES_2ND_COLUMN, y, STR_OWN, !editingName && m_posHorz==1 ? attr : 0); + lcd_putsAtt(MIXES_2ND_COLUMN, y, STR_OWN, m_posHorz==1 ? attr : 0); } - if (attr && !editingName && s_currIdx>0 && m_posHorz==1 && ((editMode>0) || p1valdiff)) { + if (attr && s_currIdx>0 && m_posHorz==1 && ((editMode>0) || p1valdiff)) { if (v < GVAR_MAX) v = GVAR_MAX; v = checkIncDec(event, v, GVAR_MAX, GVAR_MAX+MAX_PHASES-1, EE_MODEL); if (checkIncDec_Ret) { @@ -1198,8 +1210,8 @@ void menuModelPhaseOne(uint8_t event) } uint8_t p = getGVarFlightPhase(s_currIdx, idx); - lcd_outdezAtt(21*FW, y, GVAR_VALUE(idx, p), !editingName && m_posHorz==2 ? attr : 0); - if (attr && !editingName && m_posHorz==2 && ((editMode>0) || p1valdiff)) + lcd_outdezAtt(21*FW, y, GVAR_VALUE(idx, p), m_posHorz==2 ? attr : 0); + if (attr && m_posHorz==2 && ((editMode>0) || p1valdiff)) GVAR_VALUE(idx, p) = checkIncDec(event, GVAR_VALUE(idx, p), -GVAR_MAX, GVAR_MAX, EE_MODEL); break; @@ -1775,7 +1787,7 @@ void menuModelExpoOne(uint8_t event) ExpoData *ed = expoaddress(s_currIdx); putsChnRaw(7*FW+FW/2,0,ed->chn+1,0); - SUBMENU(STR_MENUDREXPO, EXPO_FIELD_MAX, {IF_CPUARM(ZCHAR|(sizeof(ed->name)-1)) 0, 0, IF_CURVES(0) IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/}); + SUBMENU(STR_MENUDREXPO, EXPO_FIELD_MAX, {IF_CPUARM(0) 0, 0, IF_CURVES(0) IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/}); int8_t sub = m_posVert; @@ -1787,7 +1799,7 @@ void menuModelExpoOne(uint8_t event) { #if defined(CPUARM) case EXPO_FIELD_NAME: - editName(EXPO_ONE_2ND_COLUMN+3*FW-sizeof(ed->name)*FW, y, ed->name, sizeof(ed->name), event, attr, m_posHorz); + editSingleName(EXPO_ONE_2ND_COLUMN+3*FW-sizeof(ed->name)*FW, y, ed->name, sizeof(ed->name), event, attr); break; #endif case EXPO_FIELD_WIDTH: @@ -1891,11 +1903,11 @@ void menuModelMixOne(uint8_t event) #else if (m_posVert == MIX_FIELD_TRIM && md2->srcRaw > NUM_STICKS) #endif - SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 0, IF_CURVES(0) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/}) + SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, 0, IF_CURVES(0) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/}) else - SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 1, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/}); + SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, 1, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/}); #else - SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 1, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/}); + SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, 1, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/}); #endif int8_t sub = m_posVert; @@ -1908,7 +1920,7 @@ void menuModelMixOne(uint8_t event) switch(i) { #if defined(CPUARM) case MIX_FIELD_NAME: - editName(MIXES_2ND_COLUMN, y, md2->name, sizeof(md2->name), event, attr, m_posHorz); + editSingleName(MIXES_2ND_COLUMN, y, md2->name, sizeof(md2->name), event, attr); break; #endif case MIX_FIELD_SOURCE: @@ -2584,46 +2596,43 @@ void menuModelGVars(uint8_t event) MENU(PSTR("GLOBAL VARIABLES"), menuTabModel, e_GVars, 1+MAX_GVARS, {0, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES}); uint8_t sub = m_posVert - 1; - static bool editingName = false; - if (editingName && s_editMode <= 0) editingName = false; - if (!editingName && s_editMode > 0 && m_posHorz == 0) editingName = true; for (uint8_t i=0; i0) ? BLINK|INVERS : INVERS) : 0); + xcoord_t x = 14*FW + (j-1)*(2+4*FWNUM) - 1; + + if (i==0 && j!=9) putsStrIdx(x+FWNUM, 2*FH, STR_FP, j, 0); + switch(j) { case 0: - if (editingName && sub==i) - editName(4*FW-3, y, g_model.gvarsNames[i], sizeof(gvar_name_t), event, attr, m_posHorz); - else - lcd_putsnAtt(4*FW-3, y, g_model.gvarsNames[i], sizeof(gvar_name_t), ZCHAR|(m_posHorz==0 ? attr : 0)); - // lcd_putsLeft(y, PSTR(" ")); - putsStrIdx(0, y, STR_GV, i+1); + editName(4*FW-3, y, g_model.gvarsNames[i], sizeof(gvar_name_t), event, attr); break; default: { PhaseData *phase = &g_model.phaseData[j-1]; int16_t v = phase->gvars[i]; - xcoord_t x = 14*FW + (j-1)*(2+4*FWNUM) - 1; int16_t vmin, vmax; if (v > GVAR_MAX) { uint8_t p = v - GVAR_MAX - 1; if (p >= s_currIdx) p++; - putsFlightPhase(x, y, p+1, !editingName ? attr : 0); + putsFlightPhase(x, y, p+1, attr); vmin = GVAR_MAX+1; vmax = GVAR_MAX+MAX_PHASES; } else { if (abs(v) >= 1000) - lcd_outdezAtt(x, y+1, v, (editingName ? 0 : attr) | TINSIZE); + lcd_outdezAtt(x, y+1, v, attr | TINSIZE); else - lcd_outdezAtt(x, y, v, (editingName ? 0 : attr)); + lcd_outdezAtt(x, y, v, attr); vmin = -GVAR_MAX; vmax = GVAR_MAX; } - if (attr && !editingName && ((s_editMode>0) || p1valdiff)) { + if (attr && ((s_editMode>0) || p1valdiff)) { phase->gvars[i] = checkIncDec(event, v, vmin, vmax, EE_MODEL); } break; @@ -2701,9 +2710,9 @@ void menuModelCustomSwitchOne(uint8_t event) } else { #if defined(FRSKY) - if (cs->v1 > NUM_XCHNCSW-NUM_TELEMETRY) { - putsTelemetryChannel(CSW_2ND_COLUMN, y, cs->v1 - (NUM_XCHNCSW-NUM_TELEMETRY+1), cstate==CS_VOFS ? convertTelemValue(cs->v1 - (NUM_XCHNCSW-NUM_TELEMETRY), 128+cs->v2) : cs->v2, attr|LEFT); - v2_max = maxTelemValue(cs->v1 - (NUM_XCHNCSW-NUM_TELEMETRY)); + if (cs->v1 > CSW_CHOUT_BASE+NUM_CHNOUT) { + putsTelemetryChannel(CSW_2ND_COLUMN, y, cs->v1 - (CSW_CHOUT_BASE+NUM_CHNOUT+1), convertCswTelemValue(cs), attr|LEFT); + v2_max = maxTelemValue(cs->v1 - (CSW_CHOUT_BASE+NUM_CHNOUT)); if (cstate == CS_VOFS) { v2_min = -128; v2_max -= 128; @@ -2807,7 +2816,7 @@ void menuModelCustomSwitches(uint8_t event) #if defined(FRSKY) if (cs->v1 > NUM_XCHNCSW-NUM_TELEMETRY) { - putsTelemetryChannel(19*FW, y, cs->v1 - (NUM_XCHNCSW-NUM_TELEMETRY+1), cstate==CS_VOFS ? convertTelemValue(cs->v1 - (NUM_XCHNCSW-NUM_TELEMETRY), 128+cs->v2) : cs->v2, 0); + putsTelemetryChannel(19*FW, y, cs->v1 - (CSW_CHOUT_BASE+NUM_CHNOUT+1), convertCswTelemValue(cs), 0); } else #endif @@ -2819,6 +2828,7 @@ void menuModelCustomSwitches(uint8_t event) } } #else + void menuModelCustomSwitches(uint8_t event) { MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_CustomSwitches, NUM_CSW+1, {0, 2/*repeated...*/}); @@ -2858,9 +2868,10 @@ void menuModelCustomSwitches(uint8_t event) putsChnRaw(12*FW-4, y, cs->v1, (m_posHorz==1 ? attr : 0)); #if defined(FRSKY) - if (cs->v1 > NUM_XCHNCSW-NUM_TELEMETRY) { - putsTelemetryChannel(19*FW, y, cs->v1 - (NUM_XCHNCSW-NUM_TELEMETRY+1), cstate==CS_VOFS ? convertTelemValue(cs->v1 - (NUM_XCHNCSW-NUM_TELEMETRY), 128+cs->v2) : cs->v2, m_posHorz==2 ? attr : 0); - v2_max = maxTelemValue(cs->v1 - (NUM_XCHNCSW-NUM_TELEMETRY)); + assert(CSW_CHOUT_BASE+NUM_CHNOUT==NUM_XCHNCSW-NUM_TELEMETRY); + if (cs->v1 > CSW_CHOUT_BASE+NUM_CHNOUT) { + putsTelemetryChannel(19*FW, y, cs->v1 - (CSW_CHOUT_BASE+NUM_CHNOUT+1), convertCswTelemValue(cs), m_posHorz==2 ? attr : 0); + v2_max = maxTelemValue(cs->v1 - (CSW_CHOUT_BASE+NUM_CHNOUT)); if (cstate == CS_VOFS) { v2_min = -128; v2_max -= 128; diff --git a/src/myeeprom.h b/src/myeeprom.h index aa9313910..c05d6f299 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -681,13 +681,14 @@ enum MixSources { MIXSRC_Ele, MIXSRC_Thr, MIXSRC_Ail, + MIXSRC_Pot1, #if defined(PCBX9D) || defined(PCBACT) - MIXSRC_S1, + MIXSRC_S1 = MIXSRC_Pot1, MIXSRC_S2, MIXSRC_S3, MIXSRC_S4, #else - MIXSRC_P1, + MIXSRC_P1 = MIXSRC_Pot1, MIXSRC_P2, MIXSRC_P3, #endif diff --git a/src/open9x.cpp b/src/open9x.cpp index 82fc3f362..9aafbba97 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -804,19 +804,18 @@ bool __getSwitch(int8_t swtch) if (cs->v1 > CSW_CHOUT_BASE+NUM_CHNOUT) { if (frskyStreaming <= 0 && cs->v1 > CSW_CHOUT_BASE+NUM_CHNOUT+MAX_TIMERS) return swtch > 0 ? false : true; - if (s == CS_VOFS) { - y = convertTelemValue(cs->v1-(CSW_CHOUT_BASE+NUM_CHNOUT), 128+cs->v2); + + y = convertCswTelemValue(cs); + #if defined(FRSKY_HUB) + if (s == CS_VOFS) { uint8_t idx = cs->v1-CSW_CHOUT_BASE-NUM_CHNOUT-TELEM_ALT; if (idx < THLD_MAX) { // Fill the threshold array barsThresholds[idx] = 128 + cs->v2; } + } #endif - } - else { - y = cs->v2; - } } else { y = calc100toRESX(cs->v2); @@ -1073,6 +1072,25 @@ uint8_t s_gvar_last = 0; int16_t getGVarValue(int8_t x, int16_t min, int16_t max) { return (x >= 126 || x <= -126) ? limit(min, GVAR_VALUE((uint8_t)x - 126, -1), max) : x; + + + if (x >= -125 && x <= 120) + return x; + + int8_t idx = (uint8_t)x - 126; + int8_t mul = 1; + if (idx <= 0) { + if (max <= 120) { + idx = 1-idx; mul = -1; + } + else { + return x; + } + } + + return limit(min, GVAR_VALUE(idx, -1), max) * mul; + + } void setGVarValue(uint8_t idx, int8_t value) @@ -1100,11 +1118,21 @@ uint8_t getGVarFlightPhase(uint8_t phase, uint8_t idx) int16_t getGVarValue(int8_t x, int16_t min, int16_t max, int8_t phase) { - if (x >= -125 && x <= 125) + if (x >= -125 && x <= 120) return x; - uint8_t idx = (uint8_t)x - 126; - return limit(min, GVAR_VALUE(idx, getGVarFlightPhase(phase, idx)), max); + int8_t idx = (uint8_t)x - 126; + int8_t mul = 1; + if (idx <= 0) { + if (max <= 120) { + idx = 1-idx; mul = -1; + } + else { + return x; + } + } + + return limit(min, GVAR_VALUE(idx, getGVarFlightPhase(phase, idx)), max) * mul; } void setGVarValue(uint8_t idx, int8_t value, int8_t phase) @@ -2676,10 +2704,7 @@ void doMixerCalculations() /* Throttle trace */ int16_t val; - if (g_model.thrTraceSrc == 0) { - val = calibratedStick[THR_STICK]; // get throttle channel value - } - else if (g_model.thrTraceSrc > NUM_POTS) { + if (g_model.thrTraceSrc > NUM_POTS) { uint8_t ch = g_model.thrTraceSrc-NUM_POTS-1; val = g_chans512[ch]; if (g_model.limitData[ch].revert) @@ -2691,13 +2716,11 @@ void doMixerCalculations() val -= calc1000toRESX(g_model.limitData[ch].offset); #endif val = val * 10 / (10+(g_model.limitData[ch].max-g_model.limitData[ch].min)/20); - val -= RESX; } else { - val = calibratedStick[g_model.thrTraceSrc+NUM_STICKS-1]; + val = RESX + calibratedStick[g_model.thrTraceSrc == 0 ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1]; } - val += RESX; val /= (RESX/16); // calibrate it static tmr10ms_t s_time_tot; diff --git a/src/translations/en.h b/src/translations/en.h index 4746da60b..9173d51ce 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -350,7 +350,7 @@ #else #define TR_MENUTOSTART CENTER"\006[MENU] TO START" #endif -#define TR_SETMIDPOINT CENTER"\012SET MIDPOINT" +#define TR_SETMIDPOINT CENTER"\003SET STICKS MIDPOINT" #define TR_MOVESTICKSPOTS CENTER"\006MOVE STICKS/POTS" #define TR_RXBATT "Rx Batt:" #define TR_TXnRX "Tx:\0Rx:"