void menuModelPhaseOne(uint8_t event) { FlightModeData *fm = flightModeAddress(s_currIdx); putsFlightMode(13*FW, 0, s_currIdx+1, (getFlightMode()==s_currIdx ? BOLD : 0)); #if defined(GVARS) && !defined(PCBSTD) static const pm_uint8_t mstate_tab_fm1[] PROGMEM = {0, 0, 0, (uint8_t)-1, 1, 1, 1, 1, 1}; 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}; check(event, 0, NULL, 0, (s_currIdx == 0) ? mstate_tab_fm1 : 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)); TITLE(STR_MENUFLIGHTPHASE); #define PHASE_ONE_FIRST_LINE (1+1*FH) #else 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(PCBSTD) if (s_currIdx == 0 && sub>=ITEM_MODEL_PHASE_SWITCH) sub += ITEM_MODEL_PHASE_FADE_IN-ITEM_MODEL_PHASE_SWITCH; for (uint8_t k=0; k<LCD_LINES-1; k++) { coord_t y = MENU_HEADER_HEIGHT + 1 + k*FH; int8_t i = k + s_pgOfs; if (s_currIdx == 0 && i>=ITEM_MODEL_PHASE_SWITCH) i += ITEM_MODEL_PHASE_FADE_IN-ITEM_MODEL_PHASE_SWITCH; uint8_t attr = (sub==i ? (editMode>0 ? BLINK|INVERS : INVERS) : 0); #else for (uint8_t i=0, k=0, y=PHASE_ONE_FIRST_LINE; i<ITEM_MODEL_PHASE_MAX; i++, k++, y+=FH) { if (s_currIdx == 0 && i==ITEM_MODEL_PHASE_SWITCH) i = ITEM_MODEL_PHASE_FADE_IN; uint8_t attr = (sub==k ? (editMode>0 ? BLINK|INVERS : INVERS) : 0); #endif switch(i) { case ITEM_MODEL_PHASE_NAME: editSingleName(MIXES_2ND_COLUMN, y, STR_PHASENAME, fm->name, sizeof(fm->name), event, attr); break; case ITEM_MODEL_PHASE_SWITCH: fm->swtch = switchMenuItem(MIXES_2ND_COLUMN, y, fm->swtch, attr, event); break; case ITEM_MODEL_PHASE_TRIMS: lcd_putsLeft(y, STR_TRIMS); for (uint8_t t=0; t<NUM_STICKS; t++) { putsTrimMode(MIXES_2ND_COLUMN+(t*FW), y, s_currIdx, t, m_posHorz==t ? attr : 0); if (attr && m_posHorz==t && ((editMode>0) || p1valdiff)) { int16_t v = getRawTrimValue(s_currIdx, t); if (v < TRIM_EXTENDED_MAX) v = TRIM_EXTENDED_MAX; v = checkIncDec(event, v, TRIM_EXTENDED_MAX, TRIM_EXTENDED_MAX+MAX_FLIGHT_MODES-1, EE_MODEL); if (checkIncDec_Ret) { if (v == TRIM_EXTENDED_MAX) v = 0; setTrimValue(s_currIdx, t, v); } } } break; #if ROTARY_ENCODERS > 0 case ITEM_MODEL_PHASE_ROTARY_ENCODERS: lcd_putsLeft(y, STR_ROTARY_ENCODER); for (uint8_t t=0; t<NUM_ROTARY_ENCODERS; t++) { putsRotaryEncoderMode(MIXES_2ND_COLUMN+(t*FW), y, s_currIdx, t, m_posHorz==t ? attr : 0); if (attr && m_posHorz==t && ((editMode>0) || p1valdiff)) { int16_t v = flightModeAddress(s_currIdx)->rotaryEncoders[t]; if (v < ROTARY_ENCODER_MAX) v = ROTARY_ENCODER_MAX; v = checkIncDec(event, v, ROTARY_ENCODER_MAX, ROTARY_ENCODER_MAX+MAX_FLIGHT_MODES-1, EE_MODEL); if (checkIncDec_Ret) { if (v == ROTARY_ENCODER_MAX) v = 0; flightModeAddress(s_currIdx)->rotaryEncoders[t] = v; } } } break; #endif case ITEM_MODEL_PHASE_FADE_IN: fm->fadeIn = EDIT_DELAY(0, y, event, attr, STR_FADEIN, fm->fadeIn); break; case ITEM_MODEL_PHASE_FADE_OUT: fm->fadeOut = EDIT_DELAY(0, y, event, attr, STR_FADEOUT, fm->fadeOut); break; #if defined(GVARS) && !defined(PCBSTD) case ITEM_MODEL_PHASE_GVARS_LABEL: lcd_putsLeft(y, STR_GLOBAL_VARS); break; default: { uint8_t idx = i-ITEM_MODEL_PHASE_GV1; uint8_t posHorz = m_posHorz; if (attr && posHorz > 0 && s_currIdx==0) posHorz++; putsStrIdx(INDENT_WIDTH, y, STR_GV, idx+1); editName(4*FW, y, g_model.gvars[idx].name, LEN_GVAR_NAME, event, posHorz==0 ? attr : 0); int16_t v = fm->gvars[idx]; if (v > GVAR_MAX) { uint8_t p = v - GVAR_MAX - 1; if (p >= s_currIdx) p++; putsFlightMode(11*FW, y, p+1, posHorz==1 ? attr : 0); } else { lcd_putsAtt(11*FW, y, STR_OWN, posHorz==1 ? attr : 0); } if (attr && s_currIdx>0 && posHorz==1 && (editMode>0 || p1valdiff)) { if (v < GVAR_MAX) v = GVAR_MAX; v = checkIncDec(event, v, GVAR_MAX, GVAR_MAX+MAX_FLIGHT_MODES-1, EE_MODEL); if (checkIncDec_Ret) { if (v == GVAR_MAX) v = 0; fm->gvars[idx] = v; } } uint8_t p = getGVarFlightPhase(s_currIdx, idx); lcd_outdezAtt(21*FW, y, GVAR_VALUE(idx, p), posHorz==2 ? attr : 0); if (attr && posHorz==2 && ((editMode>0) || p1valdiff)) { GVAR_VALUE(idx, p) = checkIncDec(event, GVAR_VALUE(idx, p), -GVAR_LIMIT, GVAR_LIMIT, EE_MODEL); } break; } #endif } } } #if defined(ROTARY_ENCODERS) #if ROTARY_ENCODERS > 2 #define NAME_OFS (-4-12) #define SWITCH_OFS (-FW/2-2-13) #define TRIMS_OFS (-FW/2-4-15) #define ROTARY_ENC_OFS (0) #else #define NAME_OFS (-4) #define SWITCH_OFS (-FW/2-2) #define TRIMS_OFS (-FW/2-4) #define ROTARY_ENC_OFS (2) #endif #else #define NAME_OFS 0 #define SWITCH_OFS (FW/2) #define TRIMS_OFS (FW/2) #endif void menuModelFlightModesAll(uint8_t event) { SIMPLE_MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, 1+MAX_FLIGHT_MODES+1); int8_t sub = m_posVert - 1; switch (event) { CASE_EVT_ROTARY_BREAK case EVT_KEY_FIRST(KEY_ENTER): if (sub == MAX_FLIGHT_MODES) { s_editMode = 0; trimsCheckTimer = 200; // 2 seconds } // no break case EVT_KEY_FIRST(KEY_RIGHT): if (sub >= 0 && sub < MAX_FLIGHT_MODES) { s_currIdx = sub; pushMenu(menuModelPhaseOne); } break; } uint8_t att; for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) { #if defined(CPUARM) int8_t y = 1 + (1+i-s_pgOfs)*FH; if (y<1*FH+1 || y>(LCD_LINES-1)*FH+1) continue; #else uint8_t y = 1 + (i+1)*FH; #endif att = (i==sub ? INVERS : 0); FlightModeData *p = flightModeAddress(i); putsFlightMode(0, y, i+1, att|(getFlightMode()==i ? BOLD : 0)); lcd_putsnAtt(4*FW+NAME_OFS, y, p->name, sizeof(p->name), ZCHAR); if (i == 0) { lcd_puts((5+LEN_FLIGHT_MODE_NAME)*FW+SWITCH_OFS, y, STR_DEFAULT); } else { putsSwitches((5+LEN_FLIGHT_MODE_NAME)*FW+SWITCH_OFS, y, p->swtch, 0); for (uint8_t t=0; t<NUM_STICKS; t++) { putsTrimMode((9+LEN_FLIGHT_MODE_NAME+t)*FW+TRIMS_OFS, y, i, t, 0); } #if defined(CPUM2560) for (uint8_t t=0; t<NUM_ROTARY_ENCODERS; t++) { putsRotaryEncoderMode((13+LEN_FLIGHT_MODE_NAME+t)*FW+TRIMS_OFS+ROTARY_ENC_OFS, y, i, t, 0); } #endif } if (p->fadeIn || p->fadeOut) { lcd_putc(LCD_W-FW-MENUS_SCROLLBAR_WIDTH, y, (p->fadeIn && p->fadeOut) ? '*' : (p->fadeIn ? 'I' : 'O')); } } #if defined(CPUARM) if (s_pgOfs != MAX_FLIGHT_MODES-(LCD_LINES-2)) return; #endif lcd_putsLeft((LCD_LINES-1)*FH+1, STR_CHECKTRIMS); putsFlightMode(OFS_CHECKTRIMS, (LCD_LINES-1)*FH+1, mixerCurrentFlightMode+1); if (sub==MAX_FLIGHT_MODES && !trimsCheckTimer) { lcd_status_line(); } }
void menuModelSensor(uint8_t event) { TelemetrySensor * sensor = & g_model.telemetrySensors[s_currIdx]; SUBMENU(STR_MENUSENSOR, SENSOR_FIELD_MAX, {0, 0, sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, SENSOR_UNIT_ROWS, SENSOR_PREC_ROWS, SENSOR_PARAM1_ROWS, SENSOR_PARAM2_ROWS, SENSOR_PARAM3_ROWS, SENSOR_PARAM4_ROWS, SENSOR_AUTOOFFSET_ROWS, SENSOR_FILTER_ROWS, SENSOR_PERSISTENT_ROWS, 0 }); lcd_outdezAtt(PSIZE(TR_MENUSENSOR)*FW+1, 0, s_currIdx+1, INVERS|LEFT); putsTelemetryChannelValue(SENSOR_2ND_COLUMN, 0, s_currIdx, getValue(MIXSRC_FIRST_TELEM+3*s_currIdx), LEFT); int8_t sub = m_posVert; for (uint8_t i=0; i<LCD_LINES-1; i++) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; uint8_t k = i + s_pgOfs; for (int j=0; j<k; j++) { if (mstate_tab[j+1] == HIDDEN_ROW) k++; } uint8_t attr = (sub==k ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0); switch (k) { case SENSOR_FIELD_NAME: editSingleName(SENSOR_2ND_COLUMN, y, STR_NAME, sensor->label, TELEM_LABEL_LEN, event, attr); break; case SENSOR_FIELD_TYPE: sensor->type = selectMenuItem(SENSOR_2ND_COLUMN, y, NO_INDENT(STR_TYPE), STR_VSENSORTYPES, sensor->type, 0, 1, attr, event); if (attr && checkIncDec_Ret) { sensor->instance = 0; if (sensor->type == TELEM_TYPE_CALCULATED) { sensor->param = 0; sensor->autoOffset = 0; sensor->filter = 0; } } break; case SENSOR_FIELD_ID: if (sensor->type == TELEM_TYPE_CUSTOM) { lcd_putsLeft(y, STR_ID); lcd_outhex4(SENSOR_2ND_COLUMN, y, sensor->id, LEFT|(m_posHorz==0 ? attr : 0)); lcd_outdezAtt(SENSOR_3RD_COLUMN, y, sensor->instance, LEFT|(m_posHorz==1 ? attr : 0)); if (attr) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR_ZERO(event, sensor->id, 0xffff); break; case 1: CHECK_INCDEC_MODELVAR_ZERO(event, sensor->instance, 0xff); break; } } } else { sensor->formula = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_FORMULA, STR_VFORMULAS, sensor->formula, 0, TELEM_FORMULA_LAST, attr, event); if (attr && checkIncDec_Ret) { sensor->param = 0; if (sensor->formula == TELEM_FORMULA_CELL) { sensor->unit = UNIT_VOLTS; sensor->prec = 2; } else if (sensor->formula == TELEM_FORMULA_DIST) { sensor->unit = UNIT_DIST; sensor->prec = 0; } else if (sensor->formula == TELEM_FORMULA_CONSUMPTION) { sensor->unit = UNIT_MAH; sensor->prec = 0; } } } break; case SENSOR_FIELD_UNIT: lcd_putsLeft(y, "Unit"); // TODO flash saving with selectMenuItem where I copied those 2 lines? lcd_putsiAtt(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr); if (attr) { CHECK_INCDEC_MODELVAR_ZERO(event, sensor->unit, UNIT_MAX); if (checkIncDec_Ret) { telemetryItems[s_currIdx].clear(); } } break; case SENSOR_FIELD_PRECISION: sensor->prec = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_PRECISION, STR_VPREC, sensor->prec, 0, 2, attr, event); if (attr && checkIncDec_Ret) { telemetryItems[s_currIdx].clear(); } break; case SENSOR_FIELD_PARAM1: if (sensor->type == TELEM_TYPE_CALCULATED) { if (sensor->formula == TELEM_FORMULA_CELL) { lcd_putsLeft(y, STR_CELLSENSOR); putsMixerSource(SENSOR_2ND_COLUMN, y, sensor->cell.source ? MIXSRC_FIRST_TELEM+3*(sensor->cell.source-1) : 0, attr); if (attr) { sensor->cell.source = checkIncDec(event, sensor->cell.source, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isCellsSensor); } break; } else if (sensor->formula == TELEM_FORMULA_DIST) { lcd_putsLeft(y, STR_GPSSENSOR); putsMixerSource(SENSOR_2ND_COLUMN, y, sensor->dist.gps ? MIXSRC_FIRST_TELEM+3*(sensor->dist.gps-1) : 0, attr); if (attr) { sensor->dist.gps = checkIncDec(event, sensor->dist.gps, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isGPSSensor); } break; } else if (sensor->formula == TELEM_FORMULA_CONSUMPTION) { lcd_putsLeft(y, STR_CURRENTSENSOR); putsMixerSource(SENSOR_2ND_COLUMN, y, sensor->consumption.source ? MIXSRC_FIRST_TELEM+3*(sensor->consumption.source-1) : 0, attr); if (attr) { sensor->consumption.source = checkIncDec(event, sensor->consumption.source, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isCurrentSensor); } break; } } else { if (sensor->unit == UNIT_RPMS) { lcd_putsLeft(y, NO_INDENT(STR_BLADES)); if (attr) CHECK_INCDEC_MODELVAR(event, sensor->custom.ratio, 1, 30000); lcd_outdezAtt(SENSOR_2ND_COLUMN, y, sensor->custom.ratio, LEFT|attr); break; } else { lcd_putsLeft(y, STR_RATIO); if (attr) CHECK_INCDEC_MODELVAR(event, sensor->custom.ratio, 0, 30000); if (sensor->custom.ratio == 0) lcd_putcAtt(SENSOR_2ND_COLUMN, y, '-', attr); else lcd_outdezAtt(SENSOR_2ND_COLUMN, y, sensor->custom.ratio, LEFT|attr|PREC1); break; } } // no break case SENSOR_FIELD_PARAM2: if (sensor->type == TELEM_TYPE_CALCULATED) { if (sensor->formula == TELEM_FORMULA_CELL) { sensor->cell.index = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_CELLINDEX, STR_VCELLINDEX, sensor->cell.index, 0, 8, attr, event); break; } else if (sensor->formula == TELEM_FORMULA_DIST) { lcd_putsLeft(y, STR_ALTSENSOR); putsMixerSource(SENSOR_2ND_COLUMN, y, sensor->dist.alt ? MIXSRC_FIRST_TELEM+3*(sensor->dist.alt-1) : 0, attr); if (attr) { sensor->dist.alt = checkIncDec(event, sensor->dist.alt, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isAltSensor); } break; } } else { lcd_putsLeft(y, NO_INDENT(STR_OFFSET)); if (attr) CHECK_INCDEC_MODELVAR(event, sensor->custom.offset, -30000, +30000); if (sensor->prec > 0) attr |= (sensor->prec == 2 ? PREC2 : PREC1); lcd_outdezAtt(SENSOR_2ND_COLUMN, y, sensor->custom.offset, LEFT|attr); break; } // no break case SENSOR_FIELD_PARAM3: // no break case SENSOR_FIELD_PARAM4: { putsStrIdx(0, y, NO_INDENT(STR_SOURCE), k-SENSOR_FIELD_PARAM1+1); int8_t & source = sensor->calc.sources[k-SENSOR_FIELD_PARAM1]; if (attr) { source = checkIncDec(event, source, -MAX_SENSORS, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable); } if (source < 0) { lcd_putcAtt(SENSOR_2ND_COLUMN, y, '-', attr); putsMixerSource(lcdNextPos, y, MIXSRC_FIRST_TELEM+3*(-1-source), attr); } else { putsMixerSource(SENSOR_2ND_COLUMN, y, source ? MIXSRC_FIRST_TELEM+3*(source-1) : 0, attr); } break; } case SENSOR_FIELD_AUTOOFFSET: ON_OFF_MENU_ITEM(sensor->autoOffset, SENSOR_2ND_COLUMN, y, STR_AUTOOFFSET, attr, event); break; case SENSOR_FIELD_ONLYPOSITIVE: ON_OFF_MENU_ITEM(sensor->onlyPositive, SENSOR_2ND_COLUMN, y, STR_ONLYPOSITIVE, attr, event); break; case SENSOR_FIELD_FILTER: ON_OFF_MENU_ITEM(sensor->filter, SENSOR_2ND_COLUMN, y, STR_FILTER, attr, event); break; case SENSOR_FIELD_PERSISTENT: ON_OFF_MENU_ITEM(sensor->persistent, SENSOR_2ND_COLUMN, y, NO_INDENT(STR_PERSISTENT), attr, event); break; case SENSOR_FIELD_LOGS: ON_OFF_MENU_ITEM(sensor->logs, SENSOR_2ND_COLUMN, y, STR_LOGS, attr, event); break; } } }
void menuModelSetup(uint8_t event) { #if defined(CPUM64) #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_TAB({ 0, 0, 2, CASE_PERSISTENT_TIMERS(0) 0, 0, 2, CASE_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, 2 }); #else #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_TAB({ 0, 0, 2, CASE_PERSISTENT_TIMERS(0) 0, 0, 2, CASE_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, NUM_SWITCHES, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, 2, }); #endif MENU_CHECK(menuTabModel, e_ModelSetup, MODEL_SETUP_MAX_LINES); TITLE(STR_MENUSETUP); uint8_t sub = menuVerticalPosition - 1; int8_t editMode = s_editMode; for (uint8_t i=0; i<NUM_BODY_LINES; ++i) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; uint8_t k = i+menuVerticalOffset; LcdFlags blink = ((editMode>0) ? BLINK|INVERS : INVERS); LcdFlags attr = (sub == k ? blink : 0); switch(k) { case ITEM_MODEL_NAME: editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_MODELNAME, g_model.header.name, sizeof(g_model.header.name), event, attr); break; case ITEM_MODEL_TIMER1: case ITEM_MODEL_TIMER2: case ITEM_MODEL_TIMER1_MINUTE_BEEP: case ITEM_MODEL_TIMER2_MINUTE_BEEP: case ITEM_MODEL_TIMER1_COUNTDOWN_BEEP: case ITEM_MODEL_TIMER2_COUNTDOWN_BEEP: { TimerData *timer = &g_model.timers[k>=ITEM_MODEL_TIMER2 ? 1 : 0]; if (k==ITEM_MODEL_TIMER1_MINUTE_BEEP || k==ITEM_MODEL_TIMER2_MINUTE_BEEP) { timer->minuteBeep = onoffMenuItem(timer->minuteBeep, MODEL_SETUP_2ND_COLUMN, y, STR_MINUTEBEEP, attr, event); } else if (k==ITEM_MODEL_TIMER1_COUNTDOWN_BEEP || k==ITEM_MODEL_TIMER2_COUNTDOWN_BEEP) { timer->countdownBeep = onoffMenuItem(timer->countdownBeep, MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, attr, event); } else { lcdDrawStringWithIndex(0*FW, y, STR_TIMER, k>=ITEM_MODEL_TIMER2 ? 2 : 1); lcdPutsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, menuHorizontalPosition==0 ? attr : 0); putsTimer(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, menuHorizontalPosition==1 ? attr : 0, menuHorizontalPosition==2 ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { div_t qr = div(timer->start, 60); switch (menuHorizontalPosition) { case 0: CHECK_INCDEC_MODELVAR_CHECK(event, timer->mode, SWSRC_FIRST, TMRMODE_COUNT+SWSRC_LAST-1/*SWSRC_None removed*/, isSwitchAvailableInTimers); break; case 1: CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59); timer->start = qr.rem + qr.quot*60; break; case 2: qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2; timer->start -= qr.rem ; #if defined(CPUM2560) if ((int16_t)timer->start < 0) timer->start=0; if ((int16_t)timer->start > 5999) timer->start=32399; // 8:59:59 #endif break; } } } break; } #if defined(CPUM2560) case ITEM_MODEL_TIMER1_PERSISTENT: case ITEM_MODEL_TIMER2_PERSISTENT: { TimerData &timer = g_model.timers[k==ITEM_MODEL_TIMER2_PERSISTENT]; timer.persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, timer.persistent, 0, 2, attr, event); break; } #endif case ITEM_MODEL_EXTENDED_LIMITS: ON_OFF_MENU_ITEM(g_model.extendedLimits, MODEL_SETUP_2ND_COLUMN, y, STR_ELIMITS, attr, event); break; case ITEM_MODEL_EXTENDED_TRIMS: #if defined(CPUM64) ON_OFF_MENU_ITEM(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, attr, event); #else ON_OFF_MENU_ITEM(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, menuHorizontalPosition<=0 ? attr : 0, event==EVT_KEY_BREAK(KEY_ENTER) ? event : 0); lcdDrawTextAtt(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_RESET_BTN, (menuHorizontalPosition>0 && !NO_HIGHLIGHT()) ? attr : 0); if (attr && menuHorizontalPosition>0) { s_editMode = 0; if (event==EVT_KEY_LONG(KEY_ENTER)) { START_NO_HIGHLIGHT(); for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) { memclear(&g_model.flightModeData[i], TRIMS_ARRAY_SIZE); } eeDirty(EE_MODEL); AUDIO_WARNING1(); } } #endif break; case ITEM_MODEL_TRIM_INC: g_model.trimInc = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_TRIMINC, STR_VTRIMINC, g_model.trimInc, -2, 2, attr, event); break; case ITEM_MODEL_THROTTLE_REVERSED: ON_OFF_MENU_ITEM(g_model.throttleReversed, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLEREVERSE, attr, event ) ; break; case ITEM_MODEL_THROTTLE_TRACE: { lcdDrawTextLeft(y, STR_TTRACE); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.thrTraceSrc, NUM_POTS+NUM_CHNOUT); uint8_t idx = g_model.thrTraceSrc + MIXSRC_Thr; if (idx > MIXSRC_Thr) idx += 1; if (idx >= MIXSRC_FIRST_POT+NUM_POTS) idx += MIXSRC_CH1 - MIXSRC_FIRST_POT - NUM_POTS; putsMixerSource(MODEL_SETUP_2ND_COLUMN, y, idx, attr); break; } case ITEM_MODEL_THROTTLE_TRIM: ON_OFF_MENU_ITEM(g_model.thrTrim, MODEL_SETUP_2ND_COLUMN, y, STR_TTRIM, attr, event); break; case ITEM_MODEL_THROTTLE_WARNING: g_model.disableThrottleWarning = !onoffMenuItem(!g_model.disableThrottleWarning, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLEWARNING, attr, event); break; case ITEM_MODEL_SWITCHES_WARNING: { lcdDrawTextLeft(y, STR_SWITCHWARNING); swarnstate_t states = g_model.switchWarningState; char c; if (attr) { s_editMode = 0; if (!READ_ONLY()) { switch (event) { CASE_EVT_ROTARY_BREAK case EVT_KEY_BREAK(KEY_ENTER): #if defined(CPUM64) g_model.switchWarningEnable ^= (1 << menuHorizontalPosition); eeDirty(EE_MODEL); #else if (menuHorizontalPosition < NUM_SWITCHES-1) { g_model.switchWarningEnable ^= (1 << menuHorizontalPosition); eeDirty(EE_MODEL); } #endif break; case EVT_KEY_LONG(KEY_ENTER): #if defined(CPUM64) getMovedSwitch(); g_model.switchWarningState = switches_states; AUDIO_WARNING1(); eeDirty(EE_MODEL); #else if (menuHorizontalPosition == NUM_SWITCHES-1) { START_NO_HIGHLIGHT(); getMovedSwitch(); g_model.switchWarningState = switches_states; AUDIO_WARNING1(); eeDirty(EE_MODEL); } #endif killEvents(event); break; } } } LcdFlags line = attr; for (uint8_t i=0; i<NUM_SWITCHES-1/*not on TRN switch*/; i++) { uint8_t swactive = !(g_model.switchWarningEnable & 1 << i); attr = 0; if (IS_3POS(i)) { c = '0'+(states & 0x03); states >>= 2; } else { if ((states & 0x01) && swactive) attr = INVERS; c = pgm_read_byte(STR_VSWITCHES - 2 + 9 + (3*(i+1))); states >>= 1; } if (line && (menuHorizontalPosition == i)) { attr = BLINK; if (swactive) attr |= INVERS; } lcdDrawCharAtt(MODEL_SETUP_2ND_COLUMN+i*FW, y, (swactive || (attr & BLINK)) ? c : '-', attr); #if !defined(CPUM64) lcdDrawTextAtt(MODEL_SETUP_2ND_COLUMN+(NUM_SWITCHES*FW), y, PSTR("<]"), (menuHorizontalPosition == NUM_SWITCHES-1 && !NO_HIGHLIGHT()) ? line : 0); #endif } break; } case ITEM_MODEL_BEEP_CENTER: lcdDrawTextLeft(y, STR_BEEPCTR); for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS; i++) { // TODO flash saving, \001 not needed in STR_RETA123 coord_t x = MODEL_SETUP_2ND_COLUMN+i*FW; lcdDrawTextAtIndex(x, y, STR_RETA123, i, ((menuHorizontalPosition==i) && attr) ? BLINK|INVERS : (((g_model.beepANACenter & ((BeepANACenter)1<<i)) || (attr && CURSOR_ON_LINE())) ? INVERS : 0 ) ); } if (attr && CURSOR_ON_CELL) { if (event==EVT_KEY_BREAK(KEY_ENTER) || p1valdiff) { if (READ_ONLY_UNLOCKED()) { s_editMode = 0; g_model.beepANACenter ^= ((BeepANACenter)1<<menuHorizontalPosition); eeDirty(EE_MODEL); } } } break; case ITEM_MODEL_PPM1_PROTOCOL: lcdDrawTextLeft(y, NO_INDENT(STR_PROTO)); lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VPROTOS, protocol, menuHorizontalPosition<=0 ? attr : 0); if (IS_PPM_PROTOCOL(protocol)) { lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN+7*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, menuHorizontalPosition!=0 ? attr : 0); } else if (menuHorizontalPosition>0 && attr) { MOVE_CURSOR_FROM_HERE(); } if (attr && (editMode>0 || p1valdiff || (!IS_PPM_PROTOCOL(protocol) && !IS_DSM2_PROTOCOL(protocol)))) { switch (menuHorizontalPosition) { case 0: CHECK_INCDEC_MODELVAR_ZERO(event, g_model.protocol, PROTO_MAX-1); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, 4); g_model.ppmFrameLength = g_model.ppmNCH * 8; break; } } break; #if 0 case ITEM_MODEL_PPM2_PROTOCOL: lcdDrawTextLeft(y, PSTR("Port2")); lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VPROTOS, 0, 0); lcdDrawTextAtt(MODEL_SETUP_2ND_COLUMN+4*FW+3, y, STR_CH, menuHorizontalPosition<=0 ? attr : 0); lcdDrawNumberAttUnit(lcdLastPos, y, g_model.moduleData[1].channelsStart+1, LEFT | (menuHorizontalPosition<=0 ? attr : 0)); lcdDrawChar(lcdLastPos, y, '-'); lcdDrawNumberAttUnit(lcdLastPos + FW+1, y, g_model.moduleData[1].channelsStart+8+g_model.moduleData[1].channelsCount, LEFT | (menuHorizontalPosition!=0 ? attr : 0)); if (attr && (editMode>0 || p1valdiff)) { switch (menuHorizontalPosition) { case 0: CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[1].channelsStart, 32-8-g_model.moduleData[1].channelsCount); SET_DEFAULT_PPM_FRAME_LENGTH(1); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.moduleData[1].channelsCount, -4, min<int8_t>(8, 32-8-g_model.moduleData[1].channelsStart)); SET_DEFAULT_PPM_FRAME_LENGTH(1); break; } } break; case ITEM_MODEL_PPM2_PARAMS: lcdDrawTextLeft(y, STR_PPMFRAME); lcdDrawText(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS); lcdDrawNumberAttUnit(MODEL_SETUP_2ND_COLUMN, y, (int16_t)g_model.moduleData[1].ppmFrameLength*5 + 225, (menuHorizontalPosition<=0 ? attr : 0) | PREC1|LEFT); lcdDrawChar(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcdDrawNumberAttUnit(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (g_model.moduleData[1].ppmDelay*50)+300, (menuHorizontalPosition < 0 || menuHorizontalPosition==1) ? attr : 0); lcdDrawCharAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, g_model.moduleData[1].ppmPulsePol ? '+' : '-', (menuHorizontalPosition < 0 || menuHorizontalPosition==2) ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { switch (menuHorizontalPosition) { case 0: CHECK_INCDEC_MODELVAR(event, g_model.moduleData[1].ppmFrameLength, -20, 35); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.moduleData[1].ppmDelay, -4, 10); break; case 2: CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[1].ppmPulsePol, 1); break; } } break; #endif case ITEM_MODEL_PPM1_PARAMS: if (IS_PPM_PROTOCOL(protocol)) { lcdDrawTextLeft(y, STR_PPMFRAME); lcdDrawText(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS); lcdDrawNumberAttUnit(MODEL_SETUP_2ND_COLUMN, y, (int16_t)g_model.ppmFrameLength*5 + 225, (menuHorizontalPosition<=0 ? attr : 0) | PREC1|LEFT); lcdDrawChar(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcdDrawNumberAttUnit(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (g_model.ppmDelay*50)+300, (CURSOR_ON_LINE() || menuHorizontalPosition==1) ? attr : 0); lcdDrawCharAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, g_model.pulsePol ? '+' : '-', (CURSOR_ON_LINE() || menuHorizontalPosition==2) ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { switch (menuHorizontalPosition) { case 0: CHECK_INCDEC_MODELVAR(event, g_model.ppmFrameLength, -20, 35); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.ppmDelay, -4, 10); break; case 2: CHECK_INCDEC_MODELVAR_ZERO(event, g_model.pulsePol, 1); break; } } } #if defined(DSM2) || defined(PXX) else if (IS_DSM2_PROTOCOL(protocol) || IS_PXX_PROTOCOL(protocol)) { if (attr && menuHorizontalPosition > 1) { REPEAT_LAST_CURSOR_MOVE(); // limit 3 column row to 2 colums (Rx_Num and RANGE fields) } lcdDrawTextLeft(y, STR_RXNUM); lcdDrawNumberNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[0], (menuHorizontalPosition<=0 ? attr : 0) | LEADING0|LEFT, 2); if (attr && (menuHorizontalPosition==0 && (editMode>0 || p1valdiff))) { CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[0], 99); } #if defined(PXX) if (protocol == PROTO_PXX) { lcdDrawTextAtt(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_SYNCMENU, menuHorizontalPosition!=0 ? attr : 0); uint8_t newFlag = 0; if (attr && menuHorizontalPosition>0 && editMode>0) { // send reset code newFlag = MODULE_BIND; } moduleFlag[0] = newFlag; } #endif #if defined(DSM2) if (IS_DSM2_PROTOCOL(protocol)) { lcdDrawTextAtt(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_MODULE_RANGE, menuHorizontalPosition!=0 ? attr : 0); moduleFlag[0] = (attr && menuHorizontalPosition>0 && editMode>0) ? MODULE_RANGECHECK : 0; // [MENU] key toggles range check mode } #endif } #endif break; } }
void menuModelSetup(uint8_t event) { horzpos_t l_posHorz = menuHorizontalPosition; bool CURSOR_ON_CELL = (menuHorizontalPosition >= 0); #if defined(TARANIS_INTERNAL_PPM) MENU_TAB({ 0, 0, TIMERS_ROWS, TOPLCD_ROWS 0, 1, 0, 0, LABEL(Throttle), 0, 0, 0, LABEL(PreflightCheck), 0, 0, SW_WARN_ITEMS(), POT_WARN_ITEMS(), NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), 0, LABEL(InternalModule), INTERNAL_MODULE_MODE_ROWS, INTERNAL_MODULE_CHANNELS_ROWS, IF_INTERNAL_MODULE_ON(IS_MODULE_XJT(INTERNAL_MODULE) ? (HAS_RF_PROTOCOL_MODELINDEX(g_model.moduleData[INTERNAL_MODULE].rfProtocol) ? (uint8_t)2 : (uint8_t)1) : (IS_MODULE_PPM(INTERNAL_MODULE) ? (uint8_t)1 : HIDDEN_ROW)), IF_INTERNAL_MODULE_ON((IS_MODULE_XJT(INTERNAL_MODULE)) ? FAILSAFE_ROWS(INTERNAL_MODULE) : HIDDEN_ROW), LABEL(ExternalModule), (IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0, EXTERNAL_MODULE_CHANNELS_ROWS, (IS_MODULE_XJT(EXTERNAL_MODULE) && !HAS_RF_PROTOCOL_MODELINDEX(g_model.moduleData[EXTERNAL_MODULE].rfProtocol)) ? (uint8_t)1 : (IS_MODULE_PPM(EXTERNAL_MODULE) || IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)2 : HIDDEN_ROW, IF_EXTERNAL_MODULE_XJT(FAILSAFE_ROWS(EXTERNAL_MODULE)), LABEL(Trainer), 0, TRAINER_CHANNELS_ROWS(), IF_TRAINER_ON(2)}); #else MENU_TAB({ 0, 0, TIMERS_ROWS, TOPLCD_ROWS 0, 1, 0, 0, LABEL(Throttle), 0, 0, 0, LABEL(PreflightCheck), 0, 0, SW_WARN_ITEMS(), POT_WARN_ITEMS(), NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), 0, LABEL(InternalModule), INTERNAL_MODULE_MODE_ROWS, INTERNAL_MODULE_CHANNELS_ROWS, IF_INTERNAL_MODULE_ON(HAS_RF_PROTOCOL_MODELINDEX(g_model.moduleData[INTERNAL_MODULE].rfProtocol) ? (uint8_t)2 : (uint8_t)1), IF_INTERNAL_MODULE_ON(FAILSAFE_ROWS(INTERNAL_MODULE)), LABEL(ExternalModule), EXTERNAL_MODULE_MODE_ROWS, EXTERNAL_MODULE_CHANNELS_ROWS, (IS_MODULE_XJT(EXTERNAL_MODULE) && !HAS_RF_PROTOCOL_MODELINDEX(g_model.moduleData[EXTERNAL_MODULE].rfProtocol)) ? (uint8_t)1 : (IS_MODULE_PPM(EXTERNAL_MODULE) || IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)2 : HIDDEN_ROW, IF_EXTERNAL_MODULE_XJT(FAILSAFE_ROWS(EXTERNAL_MODULE)), LABEL(Trainer), 0, TRAINER_CHANNELS_ROWS(), IF_TRAINER_ON(2)}); #endif MENU_CHECK(STR_MENUSETUP, menuTabModel, e_ModelSetup, ITEM_MODEL_SETUP_MAX); #if (defined(DSM2) || defined(PXX)) if (menuEvent) { moduleFlag[0] = 0; moduleFlag[1] = 0; } #endif int sub = menuVerticalPosition; for (int i=0; i<NUM_BODY_LINES; ++i) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; uint8_t k = i+menuVerticalOffset; for (int j=0; j<=k; j++) { if (mstate_tab[j] == HIDDEN_ROW) k++; } LcdFlags blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); LcdFlags attr = (sub == k ? blink : 0); switch(k) { case ITEM_MODEL_NAME: editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_MODELNAME, g_model.header.name, sizeof(g_model.header.name), event, attr); memcpy(modelHeaders[g_eeGeneral.currModel].name, g_model.header.name, sizeof(g_model.header.name)); break; case ITEM_MODEL_BITMAP: lcd_putsLeft(y, STR_BITMAP); if (ZEXIST(g_model.header.bitmap)) lcd_putsnAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.bitmap, sizeof(g_model.header.bitmap), attr); else lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VCSWFUNC, 0, attr); if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && READ_ONLY_UNLOCKED()) { s_editMode = 0; if (listSdFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), g_model.header.bitmap, LIST_NONE_SD_FILE)) { popupMenuHandler = onModelSetupBitmapMenu; } else { POPUP_WARNING(STR_NO_BITMAPS_ON_SD); } } break; case ITEM_MODEL_TIMER1: editTimerMode(0, y, attr, event); break; case ITEM_MODEL_TIMER1_NAME: editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER_NAME, g_model.timers[0].name, LEN_TIMER_NAME, event, attr); break; case ITEM_MODEL_TIMER1_MINUTE_BEEP: g_model.timers[0].minuteBeep = onoffMenuItem(g_model.timers[0].minuteBeep, MODEL_SETUP_2ND_COLUMN, y, STR_MINUTEBEEP, attr, event); break; case ITEM_MODEL_TIMER1_COUNTDOWN_BEEP: g_model.timers[0].countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, STR_VBEEPCOUNTDOWN, g_model.timers[0].countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT-1, attr, event); break; case ITEM_MODEL_TIMER1_PERSISTENT: g_model.timers[0].persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, g_model.timers[0].persistent, 0, 2, attr, event); break; #if TIMERS > 1 case ITEM_MODEL_TIMER2: editTimerMode(1, y, attr, event); break; case ITEM_MODEL_TIMER2_NAME: editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER_NAME, g_model.timers[1].name, LEN_TIMER_NAME, event, attr); break; case ITEM_MODEL_TIMER2_MINUTE_BEEP: g_model.timers[1].minuteBeep = onoffMenuItem(g_model.timers[1].minuteBeep, MODEL_SETUP_2ND_COLUMN, y, STR_MINUTEBEEP, attr, event); break; case ITEM_MODEL_TIMER2_COUNTDOWN_BEEP: g_model.timers[1].countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, STR_VBEEPCOUNTDOWN, g_model.timers[1].countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT-1, attr, event); break; case ITEM_MODEL_TIMER2_PERSISTENT: g_model.timers[1].persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, g_model.timers[1].persistent, 0, 2, attr, event); break; #endif #if TIMERS > 2 case ITEM_MODEL_TIMER3: editTimerMode(2, y, attr, event); break; case ITEM_MODEL_TIMER3_NAME: editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER_NAME, g_model.timers[2].name, LEN_TIMER_NAME, event, attr); break; case ITEM_MODEL_TIMER3_MINUTE_BEEP: g_model.timers[2].minuteBeep = onoffMenuItem(g_model.timers[2].minuteBeep, MODEL_SETUP_2ND_COLUMN, y, STR_MINUTEBEEP, attr, event); break; case ITEM_MODEL_TIMER3_COUNTDOWN_BEEP: g_model.timers[2].countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, STR_VBEEPCOUNTDOWN, g_model.timers[2].countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT-1, attr, event); break; case ITEM_MODEL_TIMER3_PERSISTENT: g_model.timers[2].persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, g_model.timers[2].persistent, 0, 2, attr, event); break; #endif #if defined(REV9E) case ITEM_MODEL_TOP_LCD_TIMER: lcd_putsLeft(y, STR_TOPLCDTIMER); putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER, g_model.topLcdTimer+1, attr); if (attr) { g_model.topLcdTimer = checkIncDec(event, g_model.topLcdTimer, 0, TIMERS-1, EE_MODEL); } break; #endif case ITEM_MODEL_EXTENDED_LIMITS: ON_OFF_MENU_ITEM(g_model.extendedLimits, MODEL_SETUP_2ND_COLUMN, y, STR_ELIMITS, attr, event); break; case ITEM_MODEL_EXTENDED_TRIMS: ON_OFF_MENU_ITEM(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, menuHorizontalPosition<=0 ? attr : 0, event==EVT_KEY_BREAK(KEY_ENTER) ? event : 0); lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_RESET_BTN, (menuHorizontalPosition>0 && !NO_HIGHLIGHT()) ? attr : 0); if (attr && menuHorizontalPosition>0) { s_editMode = 0; if (event==EVT_KEY_LONG(KEY_ENTER)) { START_NO_HIGHLIGHT(); for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) { memclear(&g_model.flightModeData[i], TRIMS_ARRAY_SIZE); } eeDirty(EE_MODEL); AUDIO_WARNING1(); } } break; case ITEM_MODEL_DISPLAY_TRIMS: g_model.displayTrims = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_DISPLAY_TRIMS, STR_VDISPLAYTRIMS, g_model.displayTrims, 0, 2, attr, event); break; case ITEM_MODEL_TRIM_INC: g_model.trimInc = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_TRIMINC, STR_VTRIMINC, g_model.trimInc, -2, 2, attr, event); break; case ITEM_MODEL_THROTTLE_LABEL: lcd_putsLeft(y, STR_THROTTLE_LABEL); break; case ITEM_MODEL_THROTTLE_REVERSED: ON_OFF_MENU_ITEM(g_model.throttleReversed, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLEREVERSE, attr, event ) ; break; case ITEM_MODEL_THROTTLE_TRACE: { lcd_putsLeft(y, STR_TTRACE); if (attr) CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, g_model.thrTraceSrc, NUM_POTS+NUM_CHNOUT, isThrottleSourceAvailable); uint8_t idx = g_model.thrTraceSrc + MIXSRC_Thr; if (idx > MIXSRC_Thr) idx += 1; if (idx >= MIXSRC_FIRST_POT+NUM_POTS) idx += MIXSRC_CH1 - MIXSRC_FIRST_POT - NUM_POTS; putsMixerSource(MODEL_SETUP_2ND_COLUMN, y, idx, attr); break; } case ITEM_MODEL_THROTTLE_TRIM: ON_OFF_MENU_ITEM(g_model.thrTrim, MODEL_SETUP_2ND_COLUMN, y, STR_TTRIM, attr, event); break; case ITEM_MODEL_PREFLIGHT_LABEL: lcd_putsLeft(y, STR_PREFLIGHT); break; case ITEM_MODEL_CHECKLIST_DISPLAY: ON_OFF_MENU_ITEM(g_model.displayChecklist, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST, attr, event); break; case ITEM_MODEL_THROTTLE_WARNING: g_model.disableThrottleWarning = !onoffMenuItem(!g_model.disableThrottleWarning, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLEWARNING, attr, event); break; #if defined(REV9E) case ITEM_MODEL_SWITCHES_WARNING2: case ITEM_MODEL_SWITCHES_WARNING3: case ITEM_MODEL_POTS_WARNING2: if (i==0) { if (CURSOR_MOVED_LEFT(event)) menuVerticalOffset--; else menuVerticalOffset++; } break; #endif case ITEM_MODEL_SWITCHES_WARNING: { #if defined(REV9E) if (i>=NUM_BODY_LINES-2 && getSwitchWarningsCount() > 8*(NUM_BODY_LINES-i)) { if (CURSOR_MOVED_LEFT(event)) menuVerticalOffset--; else menuVerticalOffset++; break; } #endif lcd_putsLeft(y, STR_SWITCHWARNING); swarnstate_t states = g_model.switchWarningState; char c; if (attr) { s_editMode = 0; if (!READ_ONLY()) { switch (event) { CASE_EVT_ROTARY_BREAK case EVT_KEY_BREAK(KEY_ENTER): break; case EVT_KEY_LONG(KEY_ENTER): if (menuHorizontalPosition < 0) { START_NO_HIGHLIGHT(); getMovedSwitch(); g_model.switchWarningState = switches_states; AUDIO_WARNING1(); eeDirty(EE_MODEL); } killEvents(event); break; } } } LcdFlags line = attr; int current = 0; for (int i=0; i<NUM_SWITCHES; i++) { if (SWITCH_WARNING_ALLOWED(i)) { div_t qr = div(current, 8); if (!READ_ONLY() && event==EVT_KEY_BREAK(KEY_ENTER) && line && l_posHorz==current) { g_model.switchWarningEnable ^= (1 << i); eeDirty(EE_MODEL); } uint8_t swactive = !(g_model.switchWarningEnable & (1<<i)); c = "\300-\301"[states & 0x03]; lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+qr.rem*(2*FW+1), y+FH*qr.quot, 'A'+i, line && (menuHorizontalPosition==current) ? INVERS : 0); if (swactive) lcd_putc(lcdNextPos, y+FH*qr.quot, c); ++current; } states >>= 2; } if (attr && menuHorizontalPosition < 0) { #if defined(REV9E) drawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, 8*(2*FW+1), 1+FH*((current+7)/8)); #else drawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, current*(2*FW+1), FH+1); #endif } break; } case ITEM_MODEL_POTS_WARNING: #if defined(REV9E) if (i==NUM_BODY_LINES-1 && g_model.potsWarnMode) { if (CURSOR_MOVED_LEFT(event)) menuVerticalOffset--; else menuVerticalOffset++; break; } #endif lcd_putsLeft(y, STR_POTWARNING); lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, PSTR("\004""OFF\0""Man\0""Auto"), g_model.potsWarnMode, (menuHorizontalPosition == 0) ? attr : 0); if (attr && (menuHorizontalPosition == 0)) { CHECK_INCDEC_MODELVAR(event, g_model.potsWarnMode, POTS_WARN_OFF, POTS_WARN_AUTO); eeDirty(EE_MODEL); } if (attr) { if (menuHorizontalPosition > 0) s_editMode = 0; if (!READ_ONLY() && menuHorizontalPosition > 0) { switch (event) { case EVT_KEY_LONG(KEY_ENTER): killEvents(event); if (g_model.potsWarnMode == POTS_WARN_MANUAL) { SAVE_POT_POSITION(menuHorizontalPosition-1); AUDIO_WARNING1(); eeDirty(EE_MODEL); } break; case EVT_KEY_BREAK(KEY_ENTER): g_model.potsWarnEnabled ^= (1 << (menuHorizontalPosition-1)); eeDirty(EE_MODEL); break; } } } if (g_model.potsWarnMode) { coord_t x = MODEL_SETUP_2ND_COLUMN+28; for (int i=0; i<NUM_POTS; ++i) { if (i<NUM_XPOTS && !IS_POT_AVAILABLE(POT1+i)) { if (attr && (menuHorizontalPosition==i+1)) REPEAT_LAST_CURSOR_MOVE(); } else { #if defined(REV9E) if (i == NUM_XPOTS) { y += FH; x = MODEL_SETUP_2ND_COLUMN; } #endif LcdFlags flags = ((menuHorizontalPosition==i+1) && attr) ? BLINK : 0; if ((!attr || menuHorizontalPosition >= 0) && !(g_model.potsWarnEnabled & (1 << i))) { flags |= INVERS; } // TODO add a new function lcd_putsnAtt(x, y, STR_VSRCRAW+2+STR_VSRCRAW[0]*(NUM_STICKS+1+i), STR_VSRCRAW[0]-1, flags & ~ZCHAR); x = lcdNextPos+3; } } } if (attr && menuHorizontalPosition < 0) { #if defined(REV9E) drawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-FH-1, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH+1, 2*FH+1); #else drawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH+1, FH+1); #endif } break; case ITEM_MODEL_BEEP_CENTER: { lcd_putsLeft(y, STR_BEEPCTR); coord_t x = MODEL_SETUP_2ND_COLUMN; for (int i=0; i<NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS; i++) { if (i>=POT1 && i<POT1+NUM_XPOTS && !IS_POT_AVAILABLE(i)) { if (attr && menuHorizontalPosition == i) REPEAT_LAST_CURSOR_MOVE(); continue; } lcd_putsiAtt(x, y, STR_RETA123, i, ((menuHorizontalPosition==i) && attr) ? BLINK|INVERS : (((g_model.beepANACenter & ((BeepANACenter)1<<i)) || (attr && CURSOR_ON_LINE())) ? INVERS : 0 ) ); x += FW; } if (attr && CURSOR_ON_CELL) { if (event==EVT_KEY_BREAK(KEY_ENTER)) { if (READ_ONLY_UNLOCKED()) { s_editMode = 0; g_model.beepANACenter ^= ((BeepANACenter)1<<menuHorizontalPosition); eeDirty(EE_MODEL); } } } break; } case ITEM_MODEL_USE_GLOBAL_FUNCTIONS: lcd_putsLeft(y, STR_USE_GLOBAL_FUNCS); menu_lcd_onoff(MODEL_SETUP_2ND_COLUMN, y, !g_model.noGlobalFunctions, attr); if (attr) g_model.noGlobalFunctions = !checkIncDecModel(event, !g_model.noGlobalFunctions, 0, 1); break; case ITEM_MODEL_INTERNAL_MODULE_LABEL: lcd_putsLeft(y, TR_INTERNALRF); break; #if defined(TARANIS_INTERNAL_PPM) case ITEM_MODEL_INTERNAL_MODULE_MODE: lcd_putsLeft(y, STR_MODE); lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_TARANIS_PROTOCOLS, g_model.moduleData[INTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0); if (IS_MODULE_XJT(INTERNAL_MODULE)) lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[INTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0); if (attr && s_editMode>0) { switch (menuHorizontalPosition) { case 0: g_model.moduleData[INTERNAL_MODULE].type = checkIncDec(event, g_model.moduleData[INTERNAL_MODULE].type, MODULE_TYPE_NONE, MODULE_TYPE_COUNT-2, EE_MODEL, isModuleAvailable); if (checkIncDec_Ret) { g_model.moduleData[INTERNAL_MODULE].rfProtocol = 0; g_model.moduleData[INTERNAL_MODULE].channelsStart = 0; g_model.moduleData[INTERNAL_MODULE].channelsCount = 0; } break; case 1: g_model.moduleData[INTERNAL_MODULE].rfProtocol = checkIncDec(event, g_model.moduleData[INTERNAL_MODULE].rfProtocol, RF_PROTO_X16, RF_PROTO_LAST, EE_MODEL, isRfProtocolAvailable); if (checkIncDec_Ret) { g_model.moduleData[INTERNAL_MODULE].channelsStart = 0; g_model.moduleData[INTERNAL_MODULE].channelsCount = 0; } } } break; #else case ITEM_MODEL_INTERNAL_MODULE_MODE: lcd_putsLeft(y, STR_MODE); lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[0].rfProtocol, attr); if (attr) { g_model.moduleData[INTERNAL_MODULE].rfProtocol = checkIncDec(event, g_model.moduleData[INTERNAL_MODULE].rfProtocol, RF_PROTO_OFF, RF_PROTO_LAST, EE_MODEL, isRfProtocolAvailable); if (checkIncDec_Ret) { g_model.moduleData[0].type = MODULE_TYPE_XJT; g_model.moduleData[0].channelsStart = 0; g_model.moduleData[0].channelsCount = 0; } } break; #endif case ITEM_MODEL_TRAINER_MODE: g_model.trainerMode = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_MODE, STR_VTRAINERMODES, g_model.trainerMode, 0, HAS_WIRELESS_TRAINER_HARDWARE() ? TRAINER_MODE_MASTER_BATTERY_COMPARTMENT : TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE, attr, event); break; case ITEM_MODEL_EXTERNAL_MODULE_LABEL: lcd_putsLeft(y, TR_EXTERNALRF); break; case ITEM_MODEL_EXTERNAL_MODULE_MODE: lcd_putsLeft(y, STR_MODE); lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_TARANIS_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0); if (IS_MODULE_XJT(EXTERNAL_MODULE)) lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0); else if (IS_MODULE_DSM2(EXTERNAL_MODULE)) lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0); if (attr && s_editMode>0) { switch (menuHorizontalPosition) { case 0: g_model.moduleData[EXTERNAL_MODULE].type = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].type, MODULE_TYPE_NONE, MODULE_TYPE_COUNT-1, EE_MODEL, isModuleAvailable); if (checkIncDec_Ret) { g_model.moduleData[EXTERNAL_MODULE].rfProtocol = 0; g_model.moduleData[EXTERNAL_MODULE].channelsStart = 0; g_model.moduleData[EXTERNAL_MODULE].channelsCount = 0; } break; case 1: if (IS_MODULE_DSM2(EXTERNAL_MODULE)) CHECK_INCDEC_MODELVAR(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, DSM2_PROTO_LP45, DSM2_PROTO_DSMX); else g_model.moduleData[EXTERNAL_MODULE].rfProtocol = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, RF_PROTO_X16, RF_PROTO_LAST, EE_MODEL, isRfProtocolAvailable); if (checkIncDec_Ret) { g_model.moduleData[EXTERNAL_MODULE].channelsStart = 0; g_model.moduleData[EXTERNAL_MODULE].channelsCount = 0; } } } break; case ITEM_MODEL_TRAINER_LABEL: lcd_putsLeft(y, STR_TRAINER); break; case ITEM_MODEL_INTERNAL_MODULE_CHANNELS: case ITEM_MODEL_EXTERNAL_MODULE_CHANNELS: case ITEM_MODEL_TRAINER_CHANNELS: { uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); ModuleData & moduleData = g_model.moduleData[moduleIdx]; lcd_putsLeft(y, STR_CHANNELRANGE); if ((int8_t)PORT_CHANNELS_ROWS(moduleIdx) >= 0) { lcd_putsAtt(MODEL_SETUP_2ND_COLUMN, y, STR_CH, menuHorizontalPosition==0 ? attr : 0); lcd_outdezAtt(lcdLastPos, y, moduleData.channelsStart+1, LEFT | (menuHorizontalPosition==0 ? attr : 0)); lcd_putc(lcdLastPos, y, '-'); lcd_outdezAtt(lcdLastPos + FW+1, y, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), LEFT | (menuHorizontalPosition==1 ? attr : 0)); if (attr && s_editMode>0) { switch (menuHorizontalPosition) { case 0: CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsStart, 32-8-moduleData.channelsCount); break; case 1: CHECK_INCDEC_MODELVAR(event, moduleData.channelsCount, -4, min<int8_t>(MAX_CHANNELS(moduleIdx), 32-8-moduleData.channelsStart)); #if defined(TARANIS_INTERNAL_PPM) if ((k == ITEM_MODEL_EXTERNAL_MODULE_CHANNELS && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) || (k == ITEM_MODEL_INTERNAL_MODULE_CHANNELS && g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_PPM) || (k == ITEM_MODEL_TRAINER_CHANNELS)) { SET_DEFAULT_PPM_FRAME_LENGTH(moduleIdx); } #else if ((k == ITEM_MODEL_EXTERNAL_MODULE_CHANNELS && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) || (k == ITEM_MODEL_TRAINER_CHANNELS)) { SET_DEFAULT_PPM_FRAME_LENGTH(moduleIdx); } #endif break; } } } break; } case ITEM_MODEL_INTERNAL_MODULE_BIND: case ITEM_MODEL_EXTERNAL_MODULE_BIND: case ITEM_MODEL_TRAINER_SETTINGS: { uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); ModuleData & moduleData = g_model.moduleData[moduleIdx]; if (IS_MODULE_PPM(moduleIdx)) { lcd_putsLeft(y, STR_PPMFRAME); lcd_puts(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (menuHorizontalPosition<=0 ? attr : 0) | PREC1|LEFT); lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || menuHorizontalPosition==1) ? attr : 0); lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppmPulsePol ? '+' : '-', (CURSOR_ON_LINE() || menuHorizontalPosition==2) ? attr : 0); if (attr && s_editMode>0) { switch (menuHorizontalPosition) { case 0: CHECK_INCDEC_MODELVAR(event, moduleData.ppmFrameLength, -20, 35); break; case 1: CHECK_INCDEC_MODELVAR(event, moduleData.ppmDelay, -4, 10); break; case 2: CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.ppmPulsePol, 1); break; } } } else { horzpos_t l_posHorz = menuHorizontalPosition; coord_t xOffsetBind = MODEL_SETUP_BIND_OFS; if (IS_MODULE_XJT(moduleIdx) && g_model.moduleData[moduleIdx].rfProtocol == RF_PROTO_D8) { xOffsetBind = 0; lcd_putsLeft(y, INDENT "Receiver"); if (attr) l_posHorz += 1; } else { lcd_putsLeft(y, STR_RXNUM); } if (IS_MODULE_XJT(moduleIdx) || IS_MODULE_DSM2(moduleIdx)) { if (xOffsetBind) lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2); if (attr && l_posHorz==0) { if (s_editMode>0) { CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], IS_MODULE_DSM2(moduleIdx) ? 20 : 63); if (checkIncDec_Ret) { modelHeaders[g_eeGeneral.currModel].modelId[moduleIdx] = g_model.header.modelId[moduleIdx]; } } if (s_editMode==0 && event==EVT_KEY_BREAK(KEY_ENTER)) { checkModelIdUnique(g_eeGeneral.currModel, moduleIdx); } } lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0); uint8_t newFlag = 0; if (attr && l_posHorz>0 && s_editMode>0) { if (l_posHorz == 1) newFlag = MODULE_BIND; else if (l_posHorz == 2) { newFlag = MODULE_RANGECHECK; } } moduleFlag[moduleIdx] = newFlag; } } break; } case ITEM_MODEL_INTERNAL_MODULE_FAILSAFE: case ITEM_MODEL_EXTERNAL_MODULE_FAILSAFE: { uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); ModuleData & moduleData = g_model.moduleData[moduleIdx]; lcd_putsLeft(y, TR_FAILSAFE); if (IS_MODULE_XJT(moduleIdx)) { lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, moduleData.failsafeMode, menuHorizontalPosition==0 ? attr : 0); if (moduleData.failsafeMode == FAILSAFE_CUSTOM) lcd_putsAtt(MODEL_SETUP_2ND_COLUMN + MODEL_SETUP_SET_FAILSAFE_OFS, y, STR_SET, menuHorizontalPosition==1 ? attr : 0); if (attr) { if (moduleData.failsafeMode != FAILSAFE_CUSTOM) { menuHorizontalPosition = 0; } if (menuHorizontalPosition == 0) { if (s_editMode > 0) { CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.failsafeMode, FAILSAFE_LAST); if (checkIncDec_Ret) SEND_FAILSAFE_NOW(moduleIdx); } } else if (menuHorizontalPosition == 1) { s_editMode = 0; if (moduleData.failsafeMode==FAILSAFE_CUSTOM && event==EVT_KEY_FIRST(KEY_ENTER)) { g_moduleIdx = moduleIdx; pushMenu(menuModelFailsafe); } } else { drawFilledRect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); } } } break; } } } #if defined(PXX) if (IS_RANGECHECK_ENABLE()) { displayPopup("RSSI: "); lcd_outdezAtt(16+4*FW, 5*FH, TELEMETRY_RSSI(), BOLD); } #endif }
void menuModelMixOne(uint8_t event) { if (event == EVT_KEY_LONG(KEY_MENU)) { pushMenu(menuChannelsView); killEvents(event); } TITLE(s_currCh ? STR_INSERTMIX : STR_EDITMIX); MixData *md2 = mixAddress(s_currIdx) ; putsChn(lcdLastPos+1*FW, 0, md2->destCh+1,0); SUBMENU_NOTITLE(MIX_FIELD_COUNT, {0, 0, 0, 0, 0, CASE_CURVES(1) CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/}); #if MENU_COLUMNS > 1 lcd_vline(MENU_COLUMN2_X-4, FH+1, LCD_H-FH-1); SET_SCROLLBAR_X(0); #endif int8_t sub = m_posVert; int8_t editMode = s_editMode; for (int k=0; k<MENU_COLUMNS*(LCD_LINES-1); k++) { coord_t y; coord_t COLUMN_X; if (k >= LCD_LINES-1) { y = 1 + (k-LCD_LINES+2)*FH; COLUMN_X = MENU_COLUMN2_X; } else { y = 1 + (k+1)*FH; COLUMN_X = 0; } int8_t i = k; #if MENU_COLUMNS < 2 i = i + s_pgOfs; #endif LcdFlags attr = (sub==i ? (editMode>0 ? BLINK|INVERS : INVERS) : 0); switch(i) { case MIX_FIELD_NAME: editSingleName(COLUMN_X+MIXES_2ND_COLUMN, y, STR_MIXNAME, md2->name, sizeof(md2->name), event, attr); break; case MIX_FIELD_SOURCE: lcd_putsColumnLeft(COLUMN_X, y, NO_INDENT(STR_SOURCE)); putsMixerSource(COLUMN_X+MIXES_2ND_COLUMN, y, md2->srcRaw, STREXPANDED|attr); if (attr) CHECK_INCDEC_MODELSOURCE(event, md2->srcRaw, 1, MIXSRC_LAST); break; case MIX_FIELD_WEIGHT: lcd_putsColumnLeft(COLUMN_X, y, STR_WEIGHT); gvarWeightItem(COLUMN_X+MIXES_2ND_COLUMN, y, md2, attr|LEFT, event); break; case MIX_FIELD_OFFSET: { lcd_putsColumnLeft(COLUMN_X, y, NO_INDENT(STR_OFFSET)); u_int8int16_t offset; MD_OFFSET_TO_UNION(md2, offset); offset.word = GVAR_MENU_ITEM(COLUMN_X+MIXES_2ND_COLUMN, y, offset.word, GV_RANGELARGE_OFFSET_NEG, GV_RANGELARGE_OFFSET, attr|LEFT, 0, event); MD_UNION_TO_OFFSET(offset, md2); drawOffsetBar(COLUMN_X+MIXES_2ND_COLUMN+22, y, md2); break; } case MIX_FIELD_TRIM: lcd_putsColumnLeft(COLUMN_X, y, STR_TRIM); menu_lcd_onoff(COLUMN_X+MIXES_2ND_COLUMN, y, !md2->carryTrim, attr); if (attr) md2->carryTrim = !checkIncDecModel(event, !md2->carryTrim, 0, 1); break; #if defined(CURVES) case MIX_FIELD_CURVE: { lcd_putsColumnLeft(COLUMN_X, y, STR_CURVE); editCurveRef(COLUMN_X+MIXES_2ND_COLUMN, y, md2->curve, event, attr); break; } #endif #if defined(FLIGHT_MODES) case MIX_FIELD_FLIGHT_PHASE: md2->flightModes = editFlightModes(COLUMN_X+MIXES_2ND_COLUMN, y, event, md2->flightModes, attr); break; #endif case MIX_FIELD_SWITCH: md2->swtch = switchMenuItem(COLUMN_X+MIXES_2ND_COLUMN, y, md2->swtch, attr, event); break; case MIX_FIELD_WARNING: lcd_putsColumnLeft(COLUMN_X+MIXES_2ND_COLUMN, y, STR_MIXWARNING); if (md2->mixWarn) lcd_outdezAtt(COLUMN_X+MIXES_2ND_COLUMN, y, md2->mixWarn, attr|LEFT); else lcd_putsAtt(COLUMN_X+MIXES_2ND_COLUMN, y, STR_OFF, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, md2->mixWarn, 3); break; case MIX_FIELD_MLTPX: md2->mltpx = selectMenuItem(COLUMN_X+MIXES_2ND_COLUMN, y, STR_MULTPX, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); break; case MIX_FIELD_DELAY_UP: md2->delayUp = EDIT_DELAY(COLUMN_X, y, event, attr, STR_DELAYUP, md2->delayUp); break; case MIX_FIELD_DELAY_DOWN: md2->delayDown = EDIT_DELAY(COLUMN_X, y, event, attr, STR_DELAYDOWN, md2->delayDown); break; case MIX_FIELD_SLOW_UP: md2->speedUp = EDIT_DELAY(COLUMN_X, y, event, attr, STR_SLOWUP, md2->speedUp); break; case MIX_FIELD_SLOW_DOWN: md2->speedDown = EDIT_DELAY(COLUMN_X, y, event, attr, STR_SLOWDOWN, md2->speedDown); 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 menuModelSetup(uint8_t event) { #if defined(CPUARM) #define IF_EXTERNAL_MODULE_XJT(x) (IS_MODULE_XJT(EXTERNAL_MODULE) ? (uint8_t)x : HIDDEN_ROW) #define IF_EXTERNAL_MODULE_ON(x) (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x)) #define IS_D8_RX(x) (g_model.moduleData[x].rfProtocol == RF_PROTO_D8) #define EXTERNAL_MODULE_CHANNELS_ROWS() IF_EXTERNAL_MODULE_ON(IS_MODULE_DSM2(EXTERNAL_MODULE) ? (uint8_t)0 : (uint8_t)1) #define EXTERNAL_MODULE_SETTINGS_ROWS() (IS_MODULE_XJT(EXTERNAL_MODULE) && IS_D8_RX(EXTERNAL_MODULE)) ? (uint8_t)1 : (IS_MODULE_PPM(EXTERNAL_MODULE) || IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)2 : HIDDEN_ROW #if defined(PCBSKY9X) && defined(REVX) #define OUTPUT_TYPE_ROWS() (IS_MODULE_PPM(EXTERNAL_MODULE) ? (uint8_t)0 : HIDDEN_ROW) , #else #define OUTPUT_TYPE_ROWS() #endif #define TRAINER_CHANNELS_ROWS() (HIDDEN_ROW) #define PORT_CHANNELS_ROWS(x) (x==EXTERNAL_MODULE ? EXTERNAL_MODULE_CHANNELS_ROWS() : 0) #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) #define CURSOR_ON_CELL (true) #define MODEL_SETUP_MAX_LINES (1+ITEM_MODEL_SETUP_MAX) #define POT_WARN_ITEMS() ((g_model.nPotsToWarn >> 6) ? (uint8_t)NUM_POTS : (uint8_t)0) #define TIMER_ROWS 2, 0, CASE_PERSISTENT_TIMERS(0) 0, 0 #if (defined(PCBSKY9X) && !defined(REVA) && !defined(REVX)) #define EXTRA_MODULE_ROWS LABEL(ExtraModule), 1, 2, #else #define EXTRA_MODULE_ROWS #endif #define TRAINER_MODULE_ROWS MENU_TAB({ 0, 0, TIMER_ROWS, TIMER_ROWS, TIMER_ROWS, 0, 1, 0, 0, 0, 0, 0, CASE_CPUARM(LABEL(PreflightCheck)) CASE_CPUARM(0) 0, 6, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, 0, LABEL(ExternalModule), (IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0, EXTERNAL_MODULE_CHANNELS_ROWS(), EXTERNAL_MODULE_SETTINGS_ROWS(), OUTPUT_TYPE_ROWS() IF_EXTERNAL_MODULE_XJT(FAILSAFE_ROWS(EXTERNAL_MODULE)), EXTRA_MODULE_ROWS TRAINER_MODULE_ROWS }); #elif defined(CPUM64) #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_TAB({ 0, 0, 2, CASE_PERSISTENT_TIMERS(0) 0, 0, 2, CASE_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, 2 }); #else #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_TAB({ 0, 0, 2, CASE_PERSISTENT_TIMERS(0) 0, 0, 2, CASE_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, NUM_SWITCHES, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, 2, CASE_PCBSKY9X(1) CASE_PCBSKY9X(2) }); #endif MENU_CHECK(menuTabModel, e_ModelSetup, MODEL_SETUP_MAX_LINES); #if defined(CPUARM) && (defined(DSM2) || defined(PXX)) if (menuEvent) { moduleFlag[0] = 0; #if NUM_MODULES > 1 moduleFlag[1] = 0; #endif } #endif TITLE(STR_MENUSETUP); uint8_t sub = m_posVert - 1; int8_t editMode = s_editMode; for (uint8_t i=0; i<NUM_BODY_LINES; ++i) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; uint8_t k = i+s_pgOfs; #if defined(CPUARM) for (int j=0; j<=k; j++) { if (mstate_tab[j+1] == HIDDEN_ROW) { if (++k >= (int)DIM(mstate_tab)) { return; } } } #endif LcdFlags blink = ((editMode>0) ? BLINK|INVERS : INVERS); LcdFlags attr = (sub == k ? blink : 0); switch(k) { case ITEM_MODEL_NAME: editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_MODELNAME, g_model.header.name, sizeof(g_model.header.name), event, attr); #if defined(CPUARM) memcpy(modelHeaders[g_eeGeneral.currModel].name, g_model.header.name, sizeof(g_model.header.name)); #endif break; #if defined(CPUARM) case ITEM_MODEL_TIMER1: case ITEM_MODEL_TIMER2: case ITEM_MODEL_TIMER3: { unsigned int timerIdx = (k>=ITEM_MODEL_TIMER3 ? 2 : (k>=ITEM_MODEL_TIMER2 ? 1 : 0)); TimerData * timer = &g_model.timers[timerIdx]; putsStrIdx(0*FW, y, STR_TIMER, timerIdx+1); putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, m_posHorz==0 ? attr : 0); putsTimer(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, m_posHorz==1 ? attr : 0, m_posHorz==2 ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { div_t qr = div(timer->start, 60); switch (m_posHorz) { case 0: { int8_t timerMode = timer->mode; if (timerMode < 0) timerMode -= TMRMODE_COUNT-1; CHECK_INCDEC_MODELVAR_CHECK(event, timerMode, -TMRMODE_COUNT-SWSRC_LAST+1, TMRMODE_COUNT+SWSRC_LAST-1, isSwitchAvailableInTimers); if (timerMode < 0) timerMode += TMRMODE_COUNT-1; timer->mode = timerMode; #if defined(AUTOSWITCH) if (s_editMode>0) { int8_t val = timer->mode - (TMRMODE_COUNT-1); int8_t switchVal = checkIncDecMovedSwitch(val); if (val != switchVal) { timer->mode = switchVal + (TMRMODE_COUNT-1); eeDirty(EE_MODEL); } } #endif break; } case 1: CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59); timer->start = qr.rem + qr.quot*60; break; case 2: qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2; timer->start -= qr.rem ; if ((int16_t)timer->start < 0) timer->start=0; break; } } break; } case ITEM_MODEL_TIMER1_NAME: case ITEM_MODEL_TIMER2_NAME: case ITEM_MODEL_TIMER3_NAME: { TimerData * timer = &g_model.timers[k>=ITEM_MODEL_TIMER3 ? 2 : (k>=ITEM_MODEL_TIMER2 ? 1 : 0)]; editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER_NAME, timer->name, sizeof(timer->name), event, attr); break; } case ITEM_MODEL_TIMER1_MINUTE_BEEP: case ITEM_MODEL_TIMER2_MINUTE_BEEP: case ITEM_MODEL_TIMER3_MINUTE_BEEP: { TimerData * timer = &g_model.timers[k>=ITEM_MODEL_TIMER3 ? 2 : (k>=ITEM_MODEL_TIMER2 ? 1 : 0)]; timer->minuteBeep = onoffMenuItem(timer->minuteBeep, MODEL_SETUP_2ND_COLUMN, y, STR_MINUTEBEEP, attr, event); break; } case ITEM_MODEL_TIMER1_COUNTDOWN_BEEP: case ITEM_MODEL_TIMER2_COUNTDOWN_BEEP: case ITEM_MODEL_TIMER3_COUNTDOWN_BEEP: { TimerData * timer = &g_model.timers[k>=ITEM_MODEL_TIMER3 ? 2 : (k>=ITEM_MODEL_TIMER2 ? 1 : 0)]; timer->countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, STR_VBEEPCOUNTDOWN, timer->countdownBeep, 0, 2, attr, event); break; } case ITEM_MODEL_TIMER1_PERSISTENT: case ITEM_MODEL_TIMER2_PERSISTENT: case ITEM_MODEL_TIMER3_PERSISTENT: { TimerData * timer = &g_model.timers[k>=ITEM_MODEL_TIMER3 ? 2 : (k>=ITEM_MODEL_TIMER2 ? 1 : 0)]; timer->persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, timer->persistent, 0, 2, attr, event); break; } #else case ITEM_MODEL_TIMER1: case ITEM_MODEL_TIMER2: case ITEM_MODEL_TIMER1_MINUTE_BEEP: case ITEM_MODEL_TIMER2_MINUTE_BEEP: case ITEM_MODEL_TIMER1_COUNTDOWN_BEEP: case ITEM_MODEL_TIMER2_COUNTDOWN_BEEP: { TimerData *timer = &g_model.timers[k>=ITEM_MODEL_TIMER2 ? 1 : 0]; if (k==ITEM_MODEL_TIMER1_MINUTE_BEEP || k==ITEM_MODEL_TIMER2_MINUTE_BEEP) { timer->minuteBeep = onoffMenuItem(timer->minuteBeep, MODEL_SETUP_2ND_COLUMN, y, STR_MINUTEBEEP, attr, event); } else if (k==ITEM_MODEL_TIMER1_COUNTDOWN_BEEP || k==ITEM_MODEL_TIMER2_COUNTDOWN_BEEP) { timer->countdownBeep = onoffMenuItem(timer->countdownBeep, MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, attr, event); } else { putsStrIdx(0*FW, y, STR_TIMER, k>=ITEM_MODEL_TIMER2 ? 2 : 1); putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, m_posHorz==0 ? attr : 0); putsTimer(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, m_posHorz==1 ? attr : 0, m_posHorz==2 ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { div_t qr = div(timer->start, 60); switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR_CHECK(event, timer->mode, SWSRC_FIRST, TMRMODE_COUNT+SWSRC_LAST-1/*SWSRC_None removed*/, isSwitchAvailableInTimers); break; case 1: CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59); timer->start = qr.rem + qr.quot*60; break; case 2: qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2; timer->start -= qr.rem ; break; } } } break; } #if defined(CPUM2560) case ITEM_MODEL_TIMER1_PERSISTENT: case ITEM_MODEL_TIMER2_PERSISTENT: { TimerData &timer = g_model.timers[k==ITEM_MODEL_TIMER2_PERSISTENT]; timer.persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, timer.persistent, 0, 2, attr, event); break; } #endif #endif case ITEM_MODEL_EXTENDED_LIMITS: ON_OFF_MENU_ITEM(g_model.extendedLimits, MODEL_SETUP_2ND_COLUMN, y, STR_ELIMITS, attr, event); break; case ITEM_MODEL_EXTENDED_TRIMS: #if defined(CPUM64) ON_OFF_MENU_ITEM(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, attr, event); #else ON_OFF_MENU_ITEM(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, m_posHorz<=0 ? attr : 0, event==EVT_KEY_BREAK(KEY_ENTER) ? event : 0); lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_RESET_BTN, m_posHorz>0 && !s_noHi ? attr : 0); if (attr && m_posHorz>0) { s_editMode = 0; if (event==EVT_KEY_LONG(KEY_ENTER)) { s_noHi = NO_HI_LEN; for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) { memclear(&g_model.flightModeData[i], TRIMS_ARRAY_SIZE); } eeDirty(EE_MODEL); AUDIO_WARNING1(); } } #endif break; #if defined(CPUARM) case ITEM_MODEL_DISPLAY_TRIMS: g_model.displayTrims = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_DISPLAY_TRIMS, STR_VDISPLAYTRIMS, g_model.displayTrims, 0, 2, attr, event); break; #endif case ITEM_MODEL_TRIM_INC: g_model.trimInc = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_TRIMINC, STR_VTRIMINC, g_model.trimInc, -2, 2, attr, event); break; case ITEM_MODEL_THROTTLE_REVERSED: ON_OFF_MENU_ITEM(g_model.throttleReversed, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLEREVERSE, attr, event ) ; break; case ITEM_MODEL_THROTTLE_TRACE: { lcd_putsLeft(y, STR_TTRACE); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.thrTraceSrc, NUM_POTS+NUM_CHNOUT); uint8_t idx = g_model.thrTraceSrc + MIXSRC_Thr; if (idx > MIXSRC_Thr) idx += 1; if (idx >= MIXSRC_FIRST_POT+NUM_POTS) idx += MIXSRC_CH1 - MIXSRC_FIRST_POT - NUM_POTS; putsMixerSource(MODEL_SETUP_2ND_COLUMN, y, idx, attr); break; } case ITEM_MODEL_THROTTLE_TRIM: ON_OFF_MENU_ITEM(g_model.thrTrim, MODEL_SETUP_2ND_COLUMN, y, STR_TTRIM, attr, event); break; #if defined(CPUARM) case ITEM_MODEL_PREFLIGHT_LABEL: lcd_putsLeft(y, STR_PREFLIGHT); break; case ITEM_MODEL_CHECKLIST_DISPLAY: ON_OFF_MENU_ITEM(g_model.displayChecklist, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST, attr, event); break; #endif case ITEM_MODEL_THROTTLE_WARNING: g_model.disableThrottleWarning = !onoffMenuItem(!g_model.disableThrottleWarning, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLEWARNING, attr, event); break; case ITEM_MODEL_SWITCHES_WARNING: { lcd_putsLeft(y, STR_SWITCHWARNING); swarnstate_t states = g_model.switchWarningState; char c; if (attr) { s_editMode = 0; if (!READ_ONLY()) { switch (event) { CASE_EVT_ROTARY_BREAK case EVT_KEY_BREAK(KEY_ENTER): #if defined(CPUM64) g_model.switchWarningEnable ^= (1 << m_posHorz); eeDirty(EE_MODEL); #else if (m_posHorz < NUM_SWITCHES-1) { g_model.switchWarningEnable ^= (1 << m_posHorz); eeDirty(EE_MODEL); } #endif break; case EVT_KEY_LONG(KEY_ENTER): #if defined(CPUM64) getMovedSwitch(); g_model.switchWarningState = switches_states; AUDIO_WARNING1(); eeDirty(EE_MODEL); #else if (m_posHorz == NUM_SWITCHES-1) { s_noHi = NO_HI_LEN; getMovedSwitch(); g_model.switchWarningState = switches_states; AUDIO_WARNING1(); eeDirty(EE_MODEL); } #endif killEvents(event); break; } } } LcdFlags line = attr; for (uint8_t i=0; i<NUM_SWITCHES-1/*not on TRN switch*/; i++) { uint8_t swactive = !(g_model.switchWarningEnable & 1 << i); attr = 0; if (IS_3POS(i)) { c = '0'+(states & 0x03); states >>= 2; } else { if ((states & 0x01) && swactive) attr = INVERS; c = pgm_read_byte(STR_VSWITCHES - 2 + 9 + (3*(i+1))); states >>= 1; } if (line && (m_posHorz == i)) { attr = BLINK; if (swactive) attr |= INVERS; } lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+i*FW, y, (swactive || (attr & BLINK)) ? c : '-', attr); #if !defined(CPUM64) lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+(NUM_SWITCHES*FW), y, PSTR("<]"), (m_posHorz == NUM_SWITCHES-1 && !s_noHi) ? line : 0); #endif } break; } case ITEM_MODEL_BEEP_CENTER: lcd_putsLeft(y, STR_BEEPCTR); for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS; i++) { // TODO flash saving, \001 not needed in STR_RETA123 coord_t x = MODEL_SETUP_2ND_COLUMN+i*FW; lcd_putsiAtt(x, y, STR_RETA123, i, ((m_posHorz==i) && attr) ? BLINK|INVERS : (((g_model.beepANACenter & ((BeepANACenter)1<<i)) || (attr && CURSOR_ON_LINE())) ? INVERS : 0 ) ); } if (attr && CURSOR_ON_CELL) { if (event==EVT_KEY_BREAK(KEY_ENTER) || p1valdiff) { if (READ_ONLY_UNLOCKED()) { s_editMode = 0; g_model.beepANACenter ^= ((BeepANACenter)1<<m_posHorz); eeDirty(EE_MODEL); } } } break; #if defined(CPUARM) case ITEM_MODEL_USE_GLOBAL_FUNCTIONS: lcd_putsLeft(y, STR_USE_GLOBAL_FUNCS); menu_lcd_onoff(MODEL_SETUP_2ND_COLUMN, y, !g_model.noGlobalFunctions, attr); if (attr) g_model.noGlobalFunctions = !checkIncDecModel(event, !g_model.noGlobalFunctions, 0, 1); break; #endif #if defined(PCBSKY9X) && !defined(REVX) case ITEM_MODEL_EXTRA_MODULE_LABEL: lcd_putsLeft(y, "RF Port 2 (PPM)"); break; #endif #if defined(CPUARM) case ITEM_MODEL_EXTERNAL_MODULE_LABEL: lcd_putsLeft(y, TR_EXTERNALRF); break; case ITEM_MODEL_EXTERNAL_MODULE_MODE: lcd_putsLeft(y, STR_MODE); lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_TARANIS_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].type, m_posHorz==0 ? attr : 0); if (IS_MODULE_XJT(EXTERNAL_MODULE)) lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].rfProtocol, m_posHorz==1 ? attr : 0); else if (IS_MODULE_DSM2(EXTERNAL_MODULE)) lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, m_posHorz==1 ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: g_model.moduleData[EXTERNAL_MODULE].type = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].type, MODULE_TYPE_NONE, MODULE_TYPE_COUNT-1, EE_MODEL, isModuleAvailable); if (checkIncDec_Ret) { g_model.moduleData[EXTERNAL_MODULE].rfProtocol = 0; g_model.moduleData[EXTERNAL_MODULE].channelsStart = 0; if (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) g_model.moduleData[EXTERNAL_MODULE].channelsCount = 0; else g_model.moduleData[EXTERNAL_MODULE].channelsCount = MAX_EXTERNAL_MODULE_CHANNELS(); } break; case 1: if (IS_MODULE_DSM2(EXTERNAL_MODULE)) CHECK_INCDEC_MODELVAR(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, DSM2_PROTO_LP45, DSM2_PROTO_DSMX); else CHECK_INCDEC_MODELVAR(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, RF_PROTO_X16, RF_PROTO_LAST); if (checkIncDec_Ret) { g_model.moduleData[EXTERNAL_MODULE].channelsStart = 0; g_model.moduleData[EXTERNAL_MODULE].channelsCount = MAX_EXTERNAL_MODULE_CHANNELS(); } } } break; #endif #if defined(PCBSKY9X) && !defined(REVX) case ITEM_MODEL_EXTRA_MODULE_CHANNELS: #endif #if defined(CPUARM) case ITEM_MODEL_EXTERNAL_MODULE_CHANNELS: { uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); ModuleData & moduleData = g_model.moduleData[moduleIdx]; lcd_putsLeft(y, STR_CHANNELRANGE); if ((int8_t)PORT_CHANNELS_ROWS(moduleIdx) >= 0) { lcd_putsAtt(MODEL_SETUP_2ND_COLUMN, y, STR_CH, m_posHorz==0 ? attr : 0); lcd_outdezAtt(lcdLastPos, y, moduleData.channelsStart+1, LEFT | (m_posHorz==0 ? attr : 0)); lcd_putc(lcdLastPos, y, '-'); lcd_outdezAtt(lcdLastPos + FW+1, y, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), LEFT | (m_posHorz==1 ? attr : 0)); if (attr && (editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsStart, 32-8-moduleData.channelsCount); break; case 1: CHECK_INCDEC_MODELVAR(event, moduleData.channelsCount, -4, min<int8_t>(MAX_CHANNELS(moduleIdx), 32-8-moduleData.channelsStart)); if ((k == ITEM_MODEL_EXTERNAL_MODULE_CHANNELS && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM)) { SET_DEFAULT_PPM_FRAME_LENGTH(moduleIdx); } break; } } } break; } #endif #if defined(PCBSKY9X) && !defined(REVX) case ITEM_MODEL_EXTRA_MODULE_BIND: #endif #if defined(CPUARM) case ITEM_MODEL_EXTERNAL_MODULE_BIND: { uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); ModuleData & moduleData = g_model.moduleData[moduleIdx]; if (IS_MODULE_PPM(moduleIdx)) { lcd_putsLeft(y, STR_PPMFRAME); lcd_puts(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT); lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0); lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppmPulsePol ? '+' : '-', (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR(event, moduleData.ppmFrameLength, -20, 35); break; case 1: CHECK_INCDEC_MODELVAR(event, moduleData.ppmDelay, -4, 10); break; case 2: CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.ppmPulsePol, 1); break; } } } else { horzpos_t l_posHorz = m_posHorz; coord_t xOffsetBind = MODEL_SETUP_BIND_OFS; if (IS_MODULE_XJT(moduleIdx) && IS_D8_RX(moduleIdx)) { xOffsetBind = 0; lcd_putsLeft(y, INDENT "Receiver"); if (attr) l_posHorz += 1; } else { lcd_putsLeft(y, STR_RXNUM); } if (IS_MODULE_XJT(moduleIdx) || IS_MODULE_DSM2(moduleIdx)) { if (xOffsetBind) lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2); if (attr && l_posHorz==0) { if (editMode>0 || p1valdiff) { CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], IS_MODULE_DSM2(moduleIdx) ? 20 : 63); if (checkIncDec_Ret) { modelHeaders[g_eeGeneral.currModel].modelId[moduleIdx] = g_model.header.modelId[moduleIdx]; } } if (editMode==0 && event==EVT_KEY_BREAK(KEY_ENTER)) { checkModelIdUnique(g_eeGeneral.currModel, moduleIdx); } } lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0); uint8_t newFlag = 0; if (attr && l_posHorz>0 && s_editMode>0) { if (l_posHorz == 1) newFlag = MODULE_BIND; else if (l_posHorz == 2) { newFlag = MODULE_RANGECHECK; } } moduleFlag[moduleIdx] = newFlag; } } break; } #endif #if defined(PCBSKY9X) && defined(REVX) case ITEM_MODEL_EXTERNAL_MODULE_OUTPUT_TYPE: { uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); ModuleData & moduleData = g_model.moduleData[moduleIdx]; moduleData.ppmOutputType = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_OUTPUT_TYPE, STR_VOUTPUT_TYPE, moduleData.ppmOutputType, 0, 1, attr, event); break; } #endif #if defined(CPUARM) case ITEM_MODEL_EXTERNAL_MODULE_FAILSAFE: { uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); ModuleData & moduleData = g_model.moduleData[moduleIdx]; lcd_putsLeft(y, TR_FAILSAFE); if (IS_MODULE_XJT(moduleIdx)) { lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, moduleData.failsafeMode, m_posHorz==0 ? attr : 0); if (moduleData.failsafeMode == FAILSAFE_CUSTOM) lcd_putsAtt(MODEL_SETUP_2ND_COLUMN + MODEL_SETUP_SET_FAILSAFE_OFS, y, STR_SET, m_posHorz==1 ? attr : 0); if (attr) { if (moduleData.failsafeMode != FAILSAFE_CUSTOM) m_posHorz = 0; if (m_posHorz==0) { if (editMode>0 || p1valdiff) { CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.failsafeMode, FAILSAFE_LAST); if (checkIncDec_Ret) SEND_FAILSAFE_NOW(moduleIdx); } } else if (m_posHorz==1) { s_editMode = 0; if (moduleData.failsafeMode==FAILSAFE_CUSTOM && event==EVT_KEY_FIRST(KEY_ENTER)) { g_moduleIdx = moduleIdx; pushMenu(menuModelFailsafe); } } else { drawFilledRect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); } } } break; } #endif #if !defined(CPUARM) case ITEM_MODEL_PPM1_PROTOCOL: lcd_putsLeft(y, NO_INDENT(STR_PROTO)); lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VPROTOS, protocol, m_posHorz<=0 ? attr : 0); 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 (m_posHorz>0 && attr) { MOVE_CURSOR_FROM_HERE(); } if (attr && (editMode>0 || p1valdiff || (!IS_PPM_PROTOCOL(protocol) && !IS_DSM2_PROTOCOL(protocol)))) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR_ZERO(event, g_model.protocol, PROTO_MAX-1); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, 4); g_model.ppmFrameLength = g_model.ppmNCH * 8; break; } } break; #endif #if 0 case ITEM_MODEL_PPM2_PROTOCOL: lcd_putsLeft(y, PSTR("Port2")); lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VPROTOS, 0, 0); lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+4*FW+3, y, STR_CH, m_posHorz<=0 ? attr : 0); lcd_outdezAtt(lcdLastPos, y, g_model.moduleData[1].channelsStart+1, LEFT | (m_posHorz<=0 ? attr : 0)); lcd_putc(lcdLastPos, y, '-'); lcd_outdezAtt(lcdLastPos + FW+1, y, g_model.moduleData[1].channelsStart+8+g_model.moduleData[1].channelsCount, LEFT | (m_posHorz!=0 ? attr : 0)); if (attr && (editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[1].channelsStart, 32-8-g_model.moduleData[1].channelsCount); SET_DEFAULT_PPM_FRAME_LENGTH(1); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.moduleData[1].channelsCount, -4, min<int8_t>(8, 32-8-g_model.moduleData[1].channelsStart)); SET_DEFAULT_PPM_FRAME_LENGTH(1); break; } } break; case ITEM_MODEL_PPM2_PARAMS: lcd_putsLeft(y, STR_PPMFRAME); lcd_puts(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)g_model.moduleData[1].ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT); lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (g_model.moduleData[1].ppmDelay*50)+300, (m_posHorz < 0 || m_posHorz==1) ? attr : 0); lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, g_model.moduleData[1].ppmPulsePol ? '+' : '-', (m_posHorz < 0 || m_posHorz==2) ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR(event, g_model.moduleData[1].ppmFrameLength, -20, 35); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.moduleData[1].ppmDelay, -4, 10); break; case 2: CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[1].ppmPulsePol, 1); break; } } break; #endif #if !defined(CPUARM) case ITEM_MODEL_PPM1_PARAMS: if (IS_PPM_PROTOCOL(protocol)) { lcd_putsLeft(y, STR_PPMFRAME); lcd_puts(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)g_model.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT); lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (g_model.ppmDelay*50)+300, (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0); lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, g_model.pulsePol ? '+' : '-', (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR(event, g_model.ppmFrameLength, -20, 35); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.ppmDelay, -4, 10); break; case 2: CHECK_INCDEC_MODELVAR_ZERO(event, g_model.pulsePol, 1); break; } } } #if defined(DSM2) || defined(PXX) else if (IS_DSM2_PROTOCOL(protocol) || IS_PXX_PROTOCOL(protocol)) { if (attr && m_posHorz > 1) { REPEAT_LAST_CURSOR_MOVE(); // limit 3 column row to 2 colums (Rx_Num and RANGE fields) } lcd_putsLeft(y, STR_RXNUM); lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[0], (m_posHorz<=0 ? attr : 0) | LEADING0|LEFT, 2); if (attr && (m_posHorz==0 && (editMode>0 || p1valdiff))) { CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[0], 99); } #if defined(PXX) if (protocol == PROTO_PXX) { lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_SYNCMENU, m_posHorz!=0 ? attr : 0); uint8_t newFlag = 0; if (attr && m_posHorz>0 && editMode>0) { // send reset code newFlag = MODULE_BIND; } moduleFlag[0] = newFlag; } #endif #if defined(DSM2) if (IS_DSM2_PROTOCOL(protocol)) { lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_MODULE_RANGE, m_posHorz!=0 ? attr : 0); moduleFlag[0] = (attr && m_posHorz>0 && editMode>0) ? MODULE_RANGECHECK : 0; // [MENU] key toggles range check mode } #endif } #endif break; #endif } }