void menuModelLogicalSwitchOne(uint8_t event) { TITLE(STR_MENULOGICALSWITCH); LogicalSwitchData * cs = lswAddress(s_currIdx); uint8_t sw = SWSRC_SW1+s_currIdx; putsSwitches(14*FW, 0, sw, (getSwitch(sw) ? BOLD : 0)); SUBMENU_NOTITLE(LS_FIELD_COUNT, {0, 0, 1, 0 /*, 0...*/}); int8_t sub = m_posVert; INCDEC_DECLARE_VARS(EE_MODEL); int v1_val = cs->v1; for (uint8_t k=0; k<LCD_LINES-1; k++) { coord_t y = MENU_HEADER_HEIGHT + 1 + k*FH; uint8_t i = k + s_pgOfs; uint8_t attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0); uint8_t cstate = lswFamily(cs->func); switch(i) { 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, LS_FUNC_MAX, EE_MODEL, isLogicalSwitchFunctionAvailable); uint8_t new_cstate = lswFamily(cs->func); if (cstate != new_cstate) { if (new_cstate == LS_FAMILY_TIMER) { cs->v1 = cs->v2 = 0; } else if (new_cstate == LS_FAMILY_EDGE) { cs->v1 = 0; cs->v2 = -129; cs->v3 = 0; } else { cs->v1 = cs->v2 = 0; } } } break; case LS_FIELD_V1: { lcd_putsLeft(y, STR_V1); int v1_min=0, v1_max=MIXSRC_LAST_TELEM; if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY || cstate == LS_FAMILY_EDGE) { putsSwitches(CSWONE_2ND_COLUMN, y, v1_val, attr); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; } else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSWONE_2ND_COLUMN, y, v1_val+1, LEFT|attr); v1_max = 99; } else { v1_val = (uint8_t)cs->v1; putsMixerSource(CSWONE_2ND_COLUMN, y, v1_val, attr); INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); } if (attr) { cs->v1 = CHECK_INCDEC_PARAM(event, v1_val, v1_min, v1_max); } break; } case LS_FIELD_V2: { lcd_putsLeft(y, STR_V2); int v2_min=0, v2_max=MIXSRC_LAST_TELEM; 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 == LS_FAMILY_TIMER) { lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2+1, LEFT|attr); v2_max = 99; } else if (cstate == LS_FAMILY_EDGE) { putsEdgeDelayParam(CSWONE_2ND_COLUMN, y, cs, m_posHorz==0 ? attr : 0, m_posHorz==1 ? attr : 0); if (s_editMode <= 0) continue; if (attr && m_posHorz==1) { CHECK_INCDEC_MODELVAR(event, cs->v3, -1, 222 - cs->v2); break; } v2_min = -129; v2_max = 122; } else if (cstate == LS_FAMILY_COMP) { putsMixerSource(CSWONE_2ND_COLUMN, y, cs->v2, attr); INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); } else { #if defined(FRSKY) if (v1_val >= MIXSRC_FIRST_TELEM) { putsTelemetryChannelValue(CSWONE_2ND_COLUMN, y, v1_val - MIXSRC_FIRST_TELEM, convertLswTelemValue(cs), attr|LEFT); v2_max = maxTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1); if (cs->func == LS_FUNC_DIFFEGREATER) v2_min = -v2_max; else if (cs->func == LS_FUNC_ADIFFEGREATER) v2_min = 0; else v2_min = minTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1); INCDEC_SET_FLAG(EE_MODEL | INCDEC_REP10 | NO_INCDEC_MARKS); if (cs->v2 < v2_min || cs->v2 > v2_max) { cs->v2 = 0; eeDirty(EE_MODEL); } } else #endif { v2_min = -LIMIT_EXT_PERCENT; v2_max = +LIMIT_EXT_PERCENT; lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2, LEFT|attr); } } if (attr) { CHECK_INCDEC_MODELVAR(event, cs->v2, v2_min, v2_max); } break; } 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_LS_ANDSW, MAX_LS_ANDSW); break; case LS_FIELD_DURATION: lcd_putsLeft(y, STR_DURATION); if (cs->duration > 0) lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 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_LS_DURATION); break; case LS_FIELD_DELAY: lcd_putsLeft(y, STR_DELAY); if (cs->delay > 0) lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 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_LS_DELAY); break; } } }
void menuModelExpoOne(uint8_t event) { if (event == EVT_KEY_LONG(KEY_MENU)) { pushMenu(menuChannelsView); killEvents(event); } ExpoData *ed = expoAddress(s_currIdx); putsMixerSource(7*FW+FW/2, 0, MIXSRC_FIRST_INPUT+ed->chn, 0); SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX, {0, 0, 0, ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)0 : (uint8_t)HIDDEN_ROW, 0, 0, CASE_CURVES(CURVE_ROWS) CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/}); SET_SCROLLBAR_X(EXPO_ONE_2ND_COLUMN+10*FW); int8_t sub = m_posVert; coord_t y = MENU_HEADER_HEIGHT + 1; for (unsigned int k=0; k<NUM_BODY_LINES; k++) { int i = k + s_pgOfs; for (int j=0; j<=i; ++j) { if (j<(int)DIM(mstate_tab) && mstate_tab[j] == HIDDEN_ROW) { ++i; } } LcdFlags attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0); switch(i) { case EXPO_FIELD_INPUT_NAME: editSingleName(EXPO_ONE_2ND_COLUMN, y, STR_INPUTNAME, g_model.inputNames[ed->chn], sizeof(g_model.inputNames[ed->chn]), event, attr); break; case EXPO_FIELD_NAME: editSingleName(EXPO_ONE_2ND_COLUMN, y, STR_EXPONAME, ed->name, sizeof(ed->name), event, attr); break; case EXPO_FIELD_SOURCE: lcd_putsLeft(y, NO_INDENT(STR_SOURCE)); putsMixerSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, STREXPANDED|attr); if (attr) ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isInputSourceAvailable); break; case EXPO_FIELD_SCALE: lcd_putsLeft(y, STR_SCALE); putsTelemetryChannelValue(EXPO_ONE_2ND_COLUMN, y, (ed->srcRaw - MIXSRC_FIRST_TELEM)/3, convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale), LEFT|attr); if (attr) ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1), EE_MODEL); break; case EXPO_FIELD_WEIGHT: lcd_putsLeft(y, STR_WEIGHT); ed->weight = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->weight, MIN_EXPO_WEIGHT, 100, LEFT|attr, 0, event); break; case EXPO_FIELD_OFFSET: lcd_putsLeft(y, NO_INDENT(STR_OFFSET)); ed->offset = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->offset, -100, 100, LEFT|attr, 0, event); break; #if defined(CURVES) case EXPO_FIELD_CURVE: lcd_putsLeft(y, STR_CURVE); editCurveRef(EXPO_ONE_2ND_COLUMN, y, ed->curve, event, attr); break; #endif #if defined(FLIGHT_MODES) case EXPO_FIELD_FLIGHT_MODES: ed->flightModes = editFlightModes(EXPO_ONE_2ND_COLUMN, y, event, ed->flightModes, attr); break; #endif case EXPO_FIELD_SWITCH: ed->swtch = switchMenuItem(EXPO_ONE_2ND_COLUMN, y, ed->swtch, attr, event); break; case EXPO_FIELD_SIDE: ed->mode = 4 - selectMenuItem(EXPO_ONE_2ND_COLUMN, y, STR_SIDE, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); break; case EXPO_FIELD_TRIM: uint8_t not_stick = (ed->srcRaw > MIXSRC_Ail); int8_t carryTrim = -ed->carryTrim; lcd_putsLeft(y, STR_TRIM); lcd_putsiAtt(EXPO_ONE_2ND_COLUMN, y, STR_VMIXTRIMS, (not_stick && carryTrim == 0) ? 0 : carryTrim+1, m_posHorz==0 ? attr : 0); if (attr) ed->carryTrim = -checkIncDecModel(event, carryTrim, not_stick ? TRIM_ON : -TRIM_OFF, -TRIM_AIL); break; } y += FH; } DrawFunction(expoFn); int x512 = getValue(ed->srcRaw); if (ed->srcRaw >= MIXSRC_FIRST_TELEM) { putsTelemetryChannelValue(LCD_W-8, 6*FH, (ed->srcRaw - MIXSRC_FIRST_TELEM) / 3, x512, 0); if (ed->scale > 0) x512 = (x512 * 1024) / convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale); } else { lcd_outdezAtt(LCD_W-8, 6*FH, calcRESXto1000(x512), PREC1); } x512 = limit(-1024, x512, 1024); int y512 = expoFn(x512); y512 = limit(-1024, y512, 1024); lcd_outdezAtt(LCD_W-8-6*FW, 1*FH, calcRESXto1000(y512), PREC1); x512 = X0+x512/(RESX/WCHART); y512 = (LCD_H-1) - ((y512+RESX)/2) * (LCD_H-1) / RESX; lcd_vline(x512, y512-3, 3*2+1); lcd_hline(x512-3, y512, 3*2+1); }
void menuModelLogicalSwitches(uint8_t event) { INCDEC_DECLARE_VARS(EE_MODEL); MENU(STR_MENULOGICALSWITCHES, menuTabModel, e_LogicalSwitches, NUM_LOGICAL_SWITCH+1, {0, NAVIGATION_LINE_BY_LINE|LS_FIELD_LAST/*repeated...*/}); uint8_t k = 0; int8_t sub = m_posVert - 1; horzpos_t horz = m_posHorz; for (uint8_t i=0; i<LCD_LINES-1; i++) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; k = i+s_pgOfs; 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); LogicalSwitchData * cs = lswAddress(k); // CSW name uint8_t sw = SWSRC_SW1+k; putsSwitches(0, y, sw, (getSwitch(sw) ? BOLD : 0) | ((sub==k && CURSOR_ON_LINE()) ? INVERS : 0)); // CSW func lcd_putsiAtt(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, horz==0 ? attr : 0); // CSW params uint8_t cstate = lswFamily(cs->func); #if defined(CPUARM) int16_t v1_val=cs->v1, v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; int16_t v3_min=-1, v3_max=100; #else int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; #define v1_val cs->v1 #endif 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_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES; v2_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v2_max = SWSRC_LAST_IN_LOGICAL_SWITCHES; INCDEC_SET_FLAG(EE_MODEL | INCDEC_SWITCH); INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); } #if defined(CPUARM) else if (cstate == LS_FAMILY_EDGE) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); putsEdgeDelayParam(CSW_3RD_COLUMN, y, cs, attr2, horz==LS_FIELD_V3 ? attr : 0); v1_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES; v2_min=-129; v2_max = 122; v3_max = 222 - cs->v2; if (horz == 1) { INCDEC_SET_FLAG(EE_MODEL | INCDEC_SWITCH); INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); } else { INCDEC_SET_FLAG(EE_MODEL); INCDEC_ENABLE_CHECK(NULL); } } #endif else if (cstate == LS_FAMILY_COMP) { #if defined(CPUARM) v1_val = (uint8_t)cs->v1; #endif putsMixerSource(CSW_2ND_COLUMN, y, v1_val, attr1); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, attr2); INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); } else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSW_2ND_COLUMN, y, lswTimerValue(cs->v1), LEFT|PREC1|attr1); lcd_outdezAtt(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|attr2); v1_min = v2_min = -128; v1_max = v2_max = 122; INCDEC_SET_FLAG(EE_MODEL); INCDEC_ENABLE_CHECK(NULL); } else { #if defined(CPUARM) v1_val = (uint8_t)cs->v1; #endif putsMixerSource(CSW_2ND_COLUMN, y, v1_val, attr1); if (horz == 1) { INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailableInCustomSwitches); } else { INCDEC_SET_FLAG(EE_MODEL); INCDEC_ENABLE_CHECK(NULL); } #if defined(CPUARM) putsChannelValue(CSW_3RD_COLUMN, y, v1_val, calc100toRESX(cs->v2), LEFT|attr2); v2_min = -30000; v2_max = 30000; #elif defined(FRSKY) if (v1_val >= MIXSRC_FIRST_TELEM) { putsTelemetryChannelValue(CSW_3RD_COLUMN, y, v1_val - MIXSRC_FIRST_TELEM, convertLswTelemValue(cs), LEFT|attr2); v2_max = maxTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1); #if defined(CPUARM) if (cs->func == LS_FUNC_DIFFEGREATER) v2_min = -v2_max; else if (cs->func == LS_FUNC_ADIFFEGREATER) v2_min = 0; else v2_min = minTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1); if (horz == 2 && v2_max-v2_min > 1000) INCDEC_SET_FLAG(EE_MODEL | INCDEC_REP10 | NO_INCDEC_MARKS); if (cs->v2 < v2_min || cs->v2 > v2_max) { cs->v2 = 0; eeDirty(EE_MODEL); } #else if (cstate == LS_FAMILY_OFS) { v2_min = -128; v2_max -= 128; } else { v2_max = min((uint8_t)127, (uint8_t)v2_max); v2_min = -v2_max; } if (cs->v2 > v2_max) { cs->v2 = v2_max; eeDirty(EE_MODEL); } #endif } else { lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT|attr2); #if defined(CPUARM) && defined(GVARS) if (v1_val >= MIXSRC_GVAR1) { v2_min = -1024; v2_max = +1024; } else #endif { v2_min = -LIMIT_EXT_PERCENT; v2_max = +LIMIT_EXT_PERCENT; } } #else if (v1_val >= MIXSRC_FIRST_TELEM) { putsTelemetryChannelValue(CSW_3RD_COLUMN, y, v1_val - MIXSRC_FIRST_TELEM, convertLswTelemValue(cs), LEFT|attr2); v2_min = -128; v2_max = 127; } else { lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT|attr2); v2_min = -LIMIT_EXT_PERCENT; v2_max = +LIMIT_EXT_PERCENT; } #endif } // CSW AND switch #if defined(CPUARM) 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==LS_FIELD_ANDSW ? attr : 0); #endif #if defined(CPUARM) // CSW duration if (cs->duration > 0) lcd_outdezAtt(CSW_5TH_COLUMN, y, cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); else lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); // CSW delay if (cstate == LS_FAMILY_EDGE) { lcd_puts(CSW_6TH_COLUMN, y, STR_NA); if (attr && horz == LS_FIELD_DELAY) { REPEAT_LAST_CURSOR_MOVE(); } } else if (cs->delay > 0) { lcd_outdezAtt(CSW_6TH_COLUMN, y, cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); } else { lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); } if (attr && horz == LS_FIELD_V3 && cstate != LS_FAMILY_EDGE) { REPEAT_LAST_CURSOR_MOVE(); } #endif if ((s_editMode>0 || p1valdiff) && attr) { switch (horz) { case LS_FIELD_FUNCTION: { #if defined(CPUARM) cs->func = checkIncDec(event, cs->func, 0, LS_FUNC_MAX, EE_MODEL, isLogicalSwitchFunctionAvailable); #else CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, LS_FUNC_MAX); #endif uint8_t new_cstate = lswFamily(cs->func); if (cstate != new_cstate) { #if defined(CPUARM) if (new_cstate == LS_FAMILY_TIMER) { cs->v1 = cs->v2 = -119; } else if (new_cstate == LS_FAMILY_EDGE) { cs->v1 = 0; cs->v2 = -129; cs->v3 = 0; } else { cs->v1 = cs->v2 = 0; } #else cs->v1 = cs->v2 = (new_cstate==LS_FAMILY_TIMER ? -119/*1.0*/ : 0); #endif } break; } case LS_FIELD_V1: cs->v1 = CHECK_INCDEC_PARAM(event, v1_val, v1_min, v1_max); break; case LS_FIELD_V2: cs->v2 = CHECK_INCDEC_PARAM(event, cs->v2, v2_min, v2_max); if (checkIncDec_Ret) TRACE("v2=%d", cs->v2); break; #if defined(CPUARM) case LS_FIELD_V3: cs->v3 = CHECK_INCDEC_PARAM(event, cs->v3, v3_min, v3_max); break; #endif case LS_FIELD_ANDSW: #if defined(CPUARM) INCDEC_SET_FLAG(EE_MODEL | INCDEC_SWITCH); 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_LS_ANDSW); #endif break; #if defined(CPUARM) case LS_FIELD_DURATION: CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION); break; case LS_FIELD_DELAY: CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY); break; #endif } } } }