bool displayNumbersTelemetryScreen(FrSkyScreenData & screen) { // Custom Screen with numbers const coord_t pos[] = {0, 71, 143, 214}; uint8_t fields_count = 0; for (uint8_t i=0; i<4; i++) { for (uint8_t j=0; j<NUM_LINE_ITEMS; j++) { source_t field = screen.lines[i].sources[j]; if (field > 0) { fields_count++; } if (i==3) { lcd_vline(69, 8, 48); lcd_vline(141, 8, 48); if (!TELEMETRY_STREAMING()) { displayRssiLine(); return fields_count; } } if (field) { coord_t x = pos[j+1]-2; coord_t y = (i==3 ? 1+FH+2*FH*i:FH+2*FH*i); LcdFlags att = (i==3 ? NO_UNIT : DBLSIZE|NO_UNIT); if (field >= MIXSRC_FIRST_TIMER && field <= MIXSRC_LAST_TIMER && i!=3) { // there is not enough space on LCD for displaying "Tmr1" or "Tmr2" and still see the - sign, we write "T1" or "T2" instead putsStrIdx(pos[j], 1+FH+2*FH*i, "T", field-MIXSRC_FIRST_TIMER+1, 0); if (timersStates[field-MIXSRC_FIRST_TIMER].val > 3600) { att += TIMEHOUR - DBLSIZE; x -= 3*FW; y += FH/2; } } else if (field >= MIXSRC_FIRST_TELEM && isGPSSensor(1+(field-MIXSRC_FIRST_TELEM)/3) && telemetryItems[(field-MIXSRC_FIRST_TELEM)/3].isAvailable()) { // we don't display GPS name, no space for it } else { putsMixerSource(pos[j], 1+FH+2*FH*i, field, 0); } if (field >= MIXSRC_FIRST_TELEM) { TelemetryItem & telemetryItem = telemetryItems[(field-MIXSRC_FIRST_TELEM)/3]; // TODO macro to convert a source to a telemetry index if (!telemetryItem.isAvailable()) { continue; } else if (telemetryItem.isOld()) { att |= INVERS|BLINK; } } putsChannel(x, y, field, att); } } } lcd_status_line(); return fields_count; }
void displayGpsTime() { uint8_t att = (TELEMETRY_STREAMING() ? LEFT|LEADING0 : LEFT|LEADING0|BLINK); lcd_outdezNAtt(CENTER_OFS+6*FW+7, STATUS_BAR_Y, frskyData.hub.hour, att, 2); lcd_putcAtt(CENTER_OFS+8*FW+4, STATUS_BAR_Y, ':', att); lcd_outdezNAtt(CENTER_OFS+9*FW+2, STATUS_BAR_Y, frskyData.hub.min, att, 2); lcd_putcAtt(CENTER_OFS+11*FW-1, STATUS_BAR_Y, ':', att); lcd_outdezNAtt(CENTER_OFS+12*FW-3, STATUS_BAR_Y, frskyData.hub.sec, att, 2); lcd_status_line(); }
void displayRssiLine() { if (TELEMETRY_STREAMING()) { lcd_hline(0, 55, 212, 0); // separator uint8_t rssi = min((uint8_t)99, frskyData.rssi[0].value); lcd_putsn(0, STATUS_BAR_Y, STR_RX, 2); lcd_outdezNAtt(4*FW, STATUS_BAR_Y, rssi, LEADING0, 2); lcd_rect(25, 57, 78, 7); lcd_filled_rect(26, 58, 19*rssi/25, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID); } else { lcd_putsAtt(7*FW, STATUS_BAR_Y, STR_NODATA, BLINK); lcd_status_line(); } }
void displayRssiLine() { if (TELEMETRY_STREAMING()) { lcd_hline(0, 55, 128, 0); // separator uint8_t rssi = min((uint8_t)99, frskyData.rssi[1].value); lcd_putsLeft(STATUS_BAR_Y, STR_TX); lcd_outdezNAtt(4*FW+1, STATUS_BAR_Y, rssi, LEADING0, 2); lcd_rect(25, 57, 38, 7); lcd_filled_rect(26, 58, 4*rssi/11, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID); rssi = min((uint8_t)99, frskyData.rssi[0].value); lcd_puts(104, STATUS_BAR_Y, STR_RX); lcd_outdezNAtt(105+4*FW, STATUS_BAR_Y, rssi, LEADING0, 2); lcd_rect(65, 57, 38, 7); uint8_t v = 4*rssi/11; lcd_filled_rect(66+36-v, 58, v, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID); } else { lcd_putsAtt(7*FW, STATUS_BAR_Y, STR_NODATA, BLINK); lcd_status_line(); } }
void menuStatisticsDebug(uint8_t event) { TITLE(STR_MENUDEBUG); switch(event) { case EVT_KEY_LONG(KEY_ENTER): g_eeGeneral.mAhUsed = 0; g_eeGeneral.globalTimer = 0; eeDirty(EE_GENERAL); sessionTimer = 0; killEvents(event); AUDIO_KEYPAD_UP(); break; case EVT_KEY_FIRST(KEY_ENTER): #if defined(LUA) maxLuaInterval = 0; maxLuaDuration = 0; #endif maxMixerDuration = 0; AUDIO_KEYPAD_UP(); break; #if defined(DEBUG_TRACE_BUFFER) case EVT_KEY_FIRST(KEY_UP): pushMenu(menuTraceBuffer); return; #endif case EVT_KEY_FIRST(KEY_DOWN): chainMenu(menuStatisticsView); break; case EVT_KEY_FIRST(KEY_EXIT): chainMenu(menuMainView); break; } lcd_putsLeft(MENU_DEBUG_Y_FREE_RAM, "Free Mem"); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, getAvailableMemory(), LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_FREE_RAM, "b"); #if defined(LUA) lcd_putsLeft(MENU_DEBUG_Y_LUA, "Lua scripts"); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_LUA+1, "[Interval]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT); #endif lcd_putsLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_MIXMAX, "ms"); lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[M]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(0), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[X]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(1), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[A]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(2), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[I]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(255), UNSIGN|LEFT); lcd_puts(3*FW, 7*FH+1, STR_MENUTORESET); lcd_status_line(); }
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 menuTelemetryFrsky(uint8_t event) { if (event == EVT_KEY_FIRST(KEY_EXIT)) { killEvents(event); chainMenu(menuMainView); return; } switch (event) { case EVT_KEY_BREAK(KEY_UP): if (s_frsky_view-- == 0) s_frsky_view = FRSKY_VIEW_MAX; break; #if defined(PCBTARANIS) case EVT_KEY_BREAK(KEY_PAGE): #endif case EVT_KEY_BREAK(KEY_DOWN): if (s_frsky_view++ == FRSKY_VIEW_MAX) s_frsky_view = 0; break; #if defined(PCBTARANIS) case EVT_KEY_LONG(KEY_ENTER): killEvents(event); MENU_ADD_ITEM(STR_RESET_TELEMETRY); MENU_ADD_ITEM(STR_RESET_FLIGHT); menuHandler = onMainViewMenu; break; #else case EVT_KEY_FIRST(KEY_ENTER): telemetryReset(); break; #endif } lcdDrawTelemetryTopBar(); if (s_frsky_view < MAX_FRSKY_SCREENS) { FrSkyScreenData & screen = g_model.frsky.screens[s_frsky_view]; #if defined(GAUGES) if (g_model.frsky.screensType & (1<<s_frsky_view)) { // Custom Screen with gauges uint8_t barHeight = 5; for (int8_t i=3; i>=0; i--) { FrSkyBarData & bar = screen.bars[i]; uint8_t source = bar.source; getvalue_t barMin = convertBarTelemValue(source, bar.barMin); getvalue_t barMax = convertBarTelemValue(source, 255-bar.barMax); if (source && barMax > barMin) { uint8_t y = barHeight+6+i*(barHeight+6); lcd_putsiAtt(0, y+barHeight-5, STR_VTELEMCHNS, source, 0); lcd_rect(25, y, BAR_WIDTH+1, barHeight+2); getvalue_t value = getValue(MIXSRC_FIRST_TELEM+source-1); #if LCD_W >= 212 putsTelemetryChannel(27+BAR_WIDTH, y+barHeight-6, source-1, value, LEFT); #endif getvalue_t threshold = 0; uint8_t thresholdX = 0; if (source <= TELEM_TM2) threshold = 0; else if (source <= TELEM_RSSI_RX) threshold = getRssiAlarmValue(source-TELEM_RSSI_TX); else if (source <= TELEM_A2) threshold = g_model.frsky.channels[source-TELEM_A1].alarms_value[0]; #if defined(FRSKY_HUB) else threshold = convertBarTelemValue(source, barsThresholds[source-TELEM_ALT]); #endif if (threshold) { thresholdX = barCoord(threshold, barMin, barMax); if (thresholdX == 100) thresholdX = 0; } uint8_t width = barCoord(value, barMin, barMax); // reversed barshade for T1/T2 uint8_t barShade = ((threshold > value) ? DOTTED : SOLID); if (source == TELEM_T1 || source == TELEM_T2) barShade = -barShade; lcd_filled_rect(26, y+1, width, barHeight, barShade); for (uint8_t j=24; j<99; j+=25) if (j>thresholdX || j>width) lcd_vline(j*BAR_WIDTH/100+26, y+1, barHeight); if (thresholdX) { lcd_vlineStip(26+thresholdX, y-2, barHeight+3, DOTTED); lcd_hline(25+thresholdX, y-2, 3); } } else { barHeight += 2; } } displayRssiLine(); } else #endif { // Custom Screen with numbers uint8_t fields_count = 0; for (uint8_t i=0; i<4; i++) { for (uint8_t j=0; j<NUM_LINE_ITEMS; j++) { uint8_t field = screen.lines[i].sources[j]; if (i==3 && j==0) { #if LCD_W >= 212 lcd_vline(69, 8, 48); lcd_vline(141, 8, 48); #else lcd_vline(63, 8, 48); #endif if (TELEMETRY_STREAMING()) { #if defined(FRSKY_HUB) if (field == TELEM_ACC) { lcd_putsLeft(STATUS_BAR_Y, STR_ACCEL); lcd_outdezNAtt(4*FW, STATUS_BAR_Y, frskyData.hub.accelX, LEFT|PREC2); lcd_outdezNAtt(10*FW, STATUS_BAR_Y, frskyData.hub.accelY, LEFT|PREC2); lcd_outdezNAtt(16*FW, STATUS_BAR_Y, frskyData.hub.accelZ, LEFT|PREC2); break; } #if defined(GPS) else if (field == TELEM_GPS_TIME) { displayGpsTime(); return; } #endif #endif } else { displayRssiLine(); return; } } if (field) { fields_count++; getvalue_t value = getValue(MIXSRC_FIRST_TELEM+field-1); uint8_t att = (i==3 ? NO_UNIT : DBLSIZE|NO_UNIT); #if LCD_W >= 212 xcoord_t pos[] = {0, 71, 143, 214}; #else xcoord_t pos[] = {0, 65, 130}; #endif putsTelemetryChannel(pos[j+1]-2, 1+FH+2*FH*i, field-1, value, att); if (field >= TELEM_TM1 && field <= TELEM_TM2 && i!=3) { // there is not enough space on LCD for displaying "Tmr1" or "Tmr2" and still see the - sign, we write "T1" or "T2" instead field = field-TELEM_TM1+TELEM_T1; } lcd_putsiAtt(pos[j], 1+FH+2*FH*i, STR_VTELEMCHNS, field, 0); } } } lcd_status_line(); if (fields_count == 0) putEvent(event == EVT_KEY_BREAK(KEY_UP) ? event : EVT_KEY_BREAK(KEY_DOWN)); } } else if (s_frsky_view == e_frsky_voltages) { // Volts / Amps / Watts / mAh uint8_t analog = 0; #if defined(CPUARM) lcd_putsiAtt(0, 2*FH, STR_VOLTSRC, g_model.frsky.voltsSource, 0); #else lcd_putsiAtt(0, 2*FH, STR_AMPSRC, g_model.frsky.voltsSource+1, 0); #endif switch (g_model.frsky.voltsSource) { #if defined(CPUARM) case FRSKY_VOLTS_SOURCE_RXBATT: putsTelemetryChannel(3*FW+6*FW+4, FH+1, TELEM_RXBATT-1, frskyData.analog[TELEM_ANA_RXBATT].value, DBLSIZE); break; #endif case FRSKY_VOLTS_SOURCE_A1: case FRSKY_VOLTS_SOURCE_A2: #if defined(CPUARM) case FRSKY_VOLTS_SOURCE_A3: case FRSKY_VOLTS_SOURCE_A4: #endif displayVoltageScreenLine(2*FH, g_model.frsky.voltsSource); analog = 1+g_model.frsky.voltsSource; break; #if defined(FRSKY_HUB) case FRSKY_VOLTS_SOURCE_FAS: putsTelemetryChannel(3*FW+6*FW+4, FH+1, TELEM_VFAS-1, frskyData.hub.vfas, DBLSIZE); break; case FRSKY_VOLTS_SOURCE_CELLS: putsTelemetryChannel(3*FW+6*FW+4, FH+1, TELEM_CELLS_SUM-1, frskyData.hub.cellsSum, DBLSIZE); break; #endif } if (g_model.frsky.currentSource) { lcd_putsiAtt(0, 4*FH, STR_AMPSRC, g_model.frsky.currentSource, 0); switch(g_model.frsky.currentSource) { case FRSKY_CURRENT_SOURCE_A1: case FRSKY_CURRENT_SOURCE_A2: #if defined(CPUARM) case FRSKY_CURRENT_SOURCE_A3: case FRSKY_CURRENT_SOURCE_A4: #endif displayVoltageScreenLine(4*FH, g_model.frsky.currentSource-1); break; #if defined(FRSKY_HUB) case FRSKY_CURRENT_SOURCE_FAS: putsTelemetryChannel(3*FW+6*FW+4, 3*FH+1, TELEM_CURRENT-1, frskyData.hub.current, DBLSIZE); break; #endif } putsTelemetryChannel(4, 5*FH+1, TELEM_POWER-1, frskyData.hub.power, LEFT|DBLSIZE); putsTelemetryChannel(3*FW+4+4*FW+6*FW+FW, 5*FH+1, TELEM_CONSUMPTION-1, frskyData.hub.currentConsumption, DBLSIZE); } else { displayVoltageScreenLine(analog > 0 ? 5*FH : 4*FH, analog ? 2-analog : 0); if (analog == 0) displayVoltageScreenLine(6*FH, 1); } #if defined(FRSKY_HUB) // Cells voltage if (frskyData.hub.cellsCount > 0) { uint8_t y = 1*FH; for (uint8_t k=0; k<frskyData.hub.cellsCount && k<6; k++) { #if defined(GAUGES) uint8_t attr = (barsThresholds[THLD_CELL] && frskyData.hub.cellVolts[k] < barsThresholds[THLD_CELL]) ? BLINK|PREC2 : PREC2; #else uint8_t attr = PREC2; #endif lcd_outdezNAtt(LCD_W, y, TELEMETRY_CELL_VOLTAGE(k), attr, 4); y += 1*FH; } #if defined(PCBTARANIS) if (frskyData.hub.cellsCount > 6) { y = 1*FH; for (uint8_t k=6; k<frskyData.hub.cellsCount && k<12; k++) { #if defined(GAUGES) uint8_t attr = (barsThresholds[THLD_CELL] && frskyData.hub.cellVolts[k] < barsThresholds[THLD_CELL]) ? BLINK|PREC2 : PREC2; #else uint8_t attr = PREC2; #endif lcd_outdezNAtt(LCD_W-3*FW-2, y, TELEMETRY_CELL_VOLTAGE(k), attr, 4); y += 1*FH; } lcd_vline(LCD_W-6*FW-4, 8, 47); } else #endif lcd_vline(LCD_W-3*FW-2, 8, 47); } #endif displayRssiLine(); } #if defined(FRSKY_HUB) else if (s_frsky_view == e_frsky_after_flight) { uint8_t line=1*FH+1; if (IS_GPS_AVAILABLE()) { // Latitude lcd_putsLeft(line, STR_LATITUDE); displayGpsCoord(line, frskyData.hub.gpsLatitudeNS, frskyData.hub.gpsLatitude_bp, frskyData.hub.gpsLatitude_ap); // Longitude line+=1*FH+1; lcd_putsLeft(line, STR_LONGITUDE); displayGpsCoord(line, frskyData.hub.gpsLongitudeEW, frskyData.hub.gpsLongitude_bp, frskyData.hub.gpsLongitude_ap); displayGpsTime(); line+=1*FH+1; } // Rssi lcd_putsLeft(line, STR_MINRSSI); #if defined(PCBTARANIS) lcd_outdezNAtt(TELEM_2ND_COLUMN, line, frskyData.rssi[0].min, LEFT|LEADING0, 2); #else lcd_puts(TELEM_2ND_COLUMN, line, STR_TX); lcd_outdezNAtt(TELEM_2ND_COLUMN+3*FW, line, frskyData.rssi[1].min, LEFT|LEADING0, 2); lcd_puts(TELEM_2ND_COLUMN+6*FW, line, STR_RX); lcd_outdezNAtt(TELEM_2ND_COLUMN+9*FW, line, frskyData.rssi[0].min, LEFT|LEADING0, 2); #endif } #endif }
void menuModelFlightModesAll(uint8_t event) { MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, MAX_FLIGHT_MODES+1, { NAVIGATION_LINE_BY_LINE|(ITEM_FLIGHT_MODES_LAST-1), NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, 0 }); int8_t sub = menuVerticalPosition; horzpos_t posHorz = menuHorizontalPosition; if (sub==0 && posHorz > 0) { posHorz += 1; } if (sub<MAX_FLIGHT_MODES && posHorz>=0) { displayColumnHeader(STR_PHASES_HEADERS, posHorz); } for (uint8_t i=0; i<LCD_LINES-1; i++) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; uint8_t k = i+menuVerticalOffset; if (k==MAX_FLIGHT_MODES) { // last line available - add the "check trims" line lcd_putsLeft((LCD_LINES-1)*FH+1, STR_CHECKTRIMS); putsFlightMode(OFS_CHECKTRIMS, (LCD_LINES-1)*FH+1, mixerCurrentFlightMode+1); if (sub==MAX_FLIGHT_MODES) { if (!trimsCheckTimer) { if (event == EVT_KEY_FIRST(KEY_ENTER)) { trimsCheckTimer = 200; // 2 seconds trims cancelled s_editMode = 1; killEvents(event); } else { lcd_status_line(); s_editMode = 0; } } else { if (event == EVT_KEY_FIRST(KEY_EXIT)) { trimsCheckTimer = 0; s_editMode = 0; killEvents(event); } } } return; } FlightModeData *p = flightModeAddress(k); putsFlightMode(0, y, k+1, (getFlightMode()==k ? BOLD : 0) | ((sub==k && menuHorizontalPosition<0) ? INVERS : 0)); for (uint8_t j=0; j<ITEM_FLIGHT_MODES_COUNT; j++) { uint8_t attr = ((sub==k && posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t active = (attr && s_editMode>0) ; switch (j) { case ITEM_FLIGHT_MODES_NAME: editName(4*FW-1, y, p->name, sizeof(p->name), event, attr); break; case ITEM_FLIGHT_MODES_SWITCH: if (k>0) { putsSwitches((4+LEN_FLIGHT_MODE_NAME)*FW+FW/2, y, p->swtch, attr); if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes); } break; case ITEM_FLIGHT_MODES_TRIM_RUD: case ITEM_FLIGHT_MODES_TRIM_ELE: case ITEM_FLIGHT_MODES_TRIM_THR: case ITEM_FLIGHT_MODES_TRIM_AIL: { uint8_t t = j-ITEM_FLIGHT_MODES_TRIM_RUD; putsTrimMode((4+LEN_FLIGHT_MODE_NAME)*FW+j*(5*FW/2), y, k, t, attr); if (active) { trim_t & v = p->trim[t]; v.mode = checkIncDec(event, v.mode==TRIM_MODE_NONE ? -1 : v.mode, -1, k==0 ? 0 : 2*MAX_FLIGHT_MODES-1, EE_MODEL, isTrimModeAvailable); } break; } case ITEM_FLIGHT_MODES_FADE_IN: lcd_outdezAtt(32*FW-2, y, (10/DELAY_STEP)*p->fadeIn, attr|PREC1); if (active) p->fadeIn = checkIncDec(event, p->fadeIn, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS); break; case ITEM_FLIGHT_MODES_FADE_OUT: lcd_outdezAtt(35*FW, y, (10/DELAY_STEP)*p->fadeOut, attr|PREC1); if (active) p->fadeOut = checkIncDec(event, p->fadeOut, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS); break; } } } }
void menuStatisticsDebug(uint8_t event) { TITLE(STR_MENUDEBUG); #if defined(WATCHDOG_TEST) if (warningResult) { warningResult = 0; // do a user requested watchdog test TRACE("Performing watchdog test"); pausePulses(); } #endif switch(event) { case EVT_KEY_LONG(KEY_ENTER): g_eeGeneral.mAhUsed = 0; g_eeGeneral.globalTimer = 0; eeDirty(EE_GENERAL); sessionTimer = 0; killEvents(event); AUDIO_KEYPAD_UP(); break; case EVT_KEY_FIRST(KEY_ENTER): #if defined(LUA) maxLuaInterval = 0; maxLuaDuration = 0; #endif maxMixerDuration = 0; AUDIO_KEYPAD_UP(); break; #if defined(DEBUG_TRACE_BUFFER) case EVT_KEY_FIRST(KEY_UP): pushMenu(menuTraceBuffer); return; #endif case EVT_KEY_FIRST(KEY_DOWN): chainMenu(menuStatisticsView); break; case EVT_KEY_FIRST(KEY_EXIT): chainMenu(menuMainView); break; #if defined(WATCHDOG_TEST) case EVT_KEY_LONG(KEY_MENU): { POPUP_CONFIRMATION("Test the watchdog?"); const char * w = "The radio will reset!"; SET_WARNING_INFO(w, strlen(w), 0); } break; #endif } lcd_putsLeft(MENU_DEBUG_Y_FREE_RAM, "Free Mem"); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, availableMemory(), LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_FREE_RAM, "b"); #if defined(LUA) lcd_putsLeft(MENU_DEBUG_Y_LUA, "Lua scripts"); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_LUA+1, "[Interval]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT); #endif lcd_putsLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_MIXMAX, "ms"); #if defined(USB_SERIAL) lcd_putsLeft(MENU_DEBUG_Y_USB, "Usb"); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_USB, charsWritten, LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_USB, " "); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_USB, APP_Rx_ptr_in, LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_USB, " "); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_USB, usbWraps, LEFT); #endif lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[M]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, menusStack.available(), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[X]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, mixerStack.available(), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[A]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, audioStack.available(), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[I]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stackAvailable(), UNSIGN|LEFT); lcd_puts(3*FW, 7*FH+1, STR_MENUTORESET); lcd_status_line(); }
void menuStatisticsDebug(uint8_t event) { TITLE(STR_MENUDEBUG); switch(event) { #if defined(CPUARM) case EVT_KEY_LONG(KEY_ENTER): g_eeGeneral.mAhUsed = 0; g_eeGeneral.globalTimer = 0; eeDirty(EE_GENERAL); #if defined(PCBSKY9X) Current_used = 0; #endif sessionTimer = 0; killEvents(event); AUDIO_KEYPAD_UP(); break; #endif case EVT_KEY_FIRST(KEY_ENTER): #if !defined(CPUARM) g_tmr1Latency_min = 0xff; g_tmr1Latency_max = 0; #endif #if defined(LUA) maxLuaInterval = 0; maxLuaDuration = 0; #endif maxMixerDuration = 0; AUDIO_KEYPAD_UP(); break; case EVT_KEY_FIRST(KEY_DOWN): chainMenu(menuStatisticsView); return; case EVT_KEY_FIRST(KEY_EXIT): chainMenu(menuMainView); return; } #if defined(PCBSKY9X) if ((ResetReason&RSTC_SR_RSTTYP) == (2<<8)) { lcd_puts(LCD_W-8*FW, 0*FH, "WATCHDOG"); } else if (unexpectedShutdown) { lcd_puts(LCD_W-13*FW, 0*FH, "UNEXP.SHTDOWN"); } #endif #if defined(PCBSKY9X) && !defined(REVA) // current lcd_putsLeft(1*FH, STR_CPU_CURRENT); putsTelemetryValue(MENU_DEBUG_COL1_OFS, 1*FH, getCurrent(), UNIT_MILLIAMPS, LEFT); uint32_t current_scale = 488 + g_eeGeneral.currentCalib; lcd_putc(MENU_DEBUG_COL2_OFS, 1*FH, '>'); putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, 1*FH, Current_max*10*current_scale/8192, UNIT_RAW, LEFT); // consumption lcd_putsLeft(2*FH, STR_CPU_MAH); putsTelemetryValue(MENU_DEBUG_COL1_OFS, 2*FH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1); putsTimer(MENU_DEBUG_COL2_OFS, 2*FH, g_eeGeneral.globalTimer + sessionTimer, LEFT, 0); #endif #if defined(PCBSKY9X) lcd_putsLeft(3*FH, STR_CPU_TEMP); putsTelemetryValue(MENU_DEBUG_COL1_OFS, 3*FH, getTemperature(), UNIT_TEMPERATURE, LEFT); lcd_putc(MENU_DEBUG_COL2_OFS, 3*FH, '>'); putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, 3*FH, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT); #endif #if defined(COPROCESSOR) lcd_putsLeft(4*FH, STR_COPROC_TEMP); if (Coproc_read==0) { lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH, PSTR("Co Proc NACK"),INVERS); } else if (Coproc_read==0x81) { lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH, PSTR("Inst.TinyApp"),INVERS); } else if (Coproc_read<3) { lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH, PSTR("Upgr.TinyApp"),INVERS); } else { putsTelemetryValue(MENU_DEBUG_COL1_OFS, 4*FH, Coproc_temp, UNIT_TEMPERATURE, LEFT); putsTelemetryValue(MENU_DEBUG_COL2_OFS, 4*FH, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT); } #endif #if defined(PCBTARANIS) && !defined(SIMU) lcd_putsLeft(3*FH, "Free Mem"); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 3*FH, 0x20020000 - (unsigned int)heap, LEFT); #endif #if defined(LUA) lcd_putsLeft(4*FH, "Lua scripts"); lcd_putsAtt(MENU_DEBUG_COL1_OFS-1, 4*FH+1, "[Duration]", SMLSIZE); lcd_outdezAtt(lcdLastPos, 4*FH, 10*maxLuaDuration, LEFT); lcd_putsAtt(lcdLastPos+2, 4*FH+1, "[Interval]", SMLSIZE); lcd_outdezAtt(lcdLastPos, 4*FH, 10*maxLuaInterval, LEFT); #endif #if defined(CPUARM) lcd_putsLeft(5*FH, STR_TMIXMAXMS); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 5*FH, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT); lcd_puts(lcdLastPos, 5*FH, "ms"); lcd_putsLeft(6*FH, STR_FREESTACKMINB); #if LCD_W >= 212 lcd_putsAtt(MENU_DEBUG_COL1_OFS-1, 6*FH+1, "[Main]", SMLSIZE); lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(0), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, 6*FH+1, "[Mix]", SMLSIZE); lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(1), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, 6*FH+1, "[Audio]", SMLSIZE); lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(2), UNSIGN|LEFT); #else lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 6*FH, stack_free(0), UNSIGN|LEFT); lcd_puts(lcdLastPos, 6*FH, "/"); lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(1), UNSIGN|LEFT); lcd_puts(lcdLastPos, 6*FH, "/"); lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(2), UNSIGN|LEFT); #endif #else lcd_putsLeft(1*FH, STR_TMR1LATMAXUS); lcd_outdez8(MENU_DEBUG_COL1_OFS , 1*FH, g_tmr1Latency_max/2 ); lcd_putsLeft(2*FH, STR_TMR1LATMINUS); lcd_outdez8(MENU_DEBUG_COL1_OFS , 2*FH, g_tmr1Latency_min/2 ); lcd_putsLeft(3*FH, STR_TMR1JITTERUS); lcd_outdez8(MENU_DEBUG_COL1_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 ); lcd_putsLeft(4*FH, STR_TMIXMAXMS); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 4*FH, DURATION_MS_PREC2(maxMixerDuration), PREC2); lcd_putsLeft(5*FH, STR_FREESTACKMINB); lcd_outdezAtt(14*FW, 5*FH, stack_free(), UNSIGN) ; #endif lcd_puts(3*FW, 7*FH+1, STR_MENUTORESET); lcd_status_line(); }