int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event) #endif { uint16_t delta = GV_GET_GV1_VALUE(max); bool invers = (attr & INVERS); // TRACE("gvarMenuItem(val=%d min=%d max=%d)", value, min, max); if (invers && event == EVT_KEY_LONG(KEY_ENTER)) { s_editMode = !s_editMode; #if defined(CPUARM) if (attr & PREC1) value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode)*10 : delta); else value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode) : delta); #else value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode) : delta); #endif eeDirty(EE_MODEL); } if (GV_IS_GV_VALUE(value, min, max)) { if (attr & LEFT) attr -= LEFT; /* because of ZCHAR */ else x -= 2*FW+FWNUM; #if defined(CPUARM) attr &= ~PREC1; #endif int8_t idx = (int16_t) GV_INDEX_CALC_DELTA(value, delta); if (invers) { CHECK_INCDEC_MODELVAR(event, idx, -MAX_GVARS, MAX_GVARS-1); } if (idx < 0) { value = (int16_t) GV_CALC_VALUE_IDX_NEG(idx, delta); idx = -idx; lcd_putcAtt(x-6, y, '-', attr); } else { value = (int16_t) GV_CALC_VALUE_IDX_POS(idx, delta); idx++; } putsStrIdx(x, y, STR_GV, idx, attr); } else { lcd_outdezAtt(x, y, value, attr); #if defined(CPUARM) if (invers) value = checkIncDec(event, value, min, max, EE_MODEL | editflags); #else if (invers) value = checkIncDec(event, value, min, max, EE_MODEL); #endif } return value; }
//! \brief Display one byte as hex. void lcd_outhex2(uint8_t x, uint8_t y, uint8_t val) { x += FWNUM * 2; for (int i = 0; i < 2; i++) { x -= FWNUM; char c = val & 0xf; c = c > 9 ? c + 'A' - 10 : c + '0'; lcd_putcAtt(x, y, c, c >= 'A' ? CONDENSED : 0); val >>= 4; } }
//=============================================================================== void title(char x) { #if defined(HUB) lcd_putsAtt (0*FW, 0*FH, PSTR(" GPS NMEA data ?/5 "), INVERS); #else lcd_putsAtt (0*FW, 0*FH, PSTR(" GPS NMEA data ?/4 "), INVERS); #endif lcd_putcAtt(16*FW, 0*FH, x, INVERS); }
void lcd_putsnAtt0(uint8_t x,uint8_t y, const char * s,uint8_t len,uint8_t mode) { register char c ; while(len!=0) { c = *s++ ; if ( c == 0 ) { break ; } x = lcd_putcAtt(x,y,c,mode); len--; } }
void lcd_outhex4(uint8_t x,uint8_t y,uint16_t val) { uint8_t i ; x+=FWNUM*4; for(i=0; i<4; i++) { x-=FWNUM; char c = val & 0xf; c = c>9 ? c+'A'-10 : c+'0'; lcd_putcAtt(x,y,c,c>='A'?CONDENSED:0); val>>=4; } }
void menuProcJeti(uint8_t event) { TITLE("JETI"); switch(event) { //case EVT_KEY_FIRST(KEY_MENU): // break; case EVT_KEY_FIRST(KEY_EXIT): JETI_DisableRXD(); chainMenu(menuProc0); break; } for (uint8_t i = 0; i < 16; i++) { lcd_putcAtt((i+2)*FW, 3*FH, JetiBuffer[i], BSS); lcd_putcAtt((i+2)*FW, 4*FH, JetiBuffer[i+16], BSS); } if (JetiBufferReady) { JETI_EnableTXD(); if (keyState((EnumKeys)(KEY_UP))) jeti_keys &= JETI_KEY_UP; if (keyState((EnumKeys)(KEY_DOWN))) jeti_keys &= JETI_KEY_DOWN; if (keyState((EnumKeys)(KEY_LEFT))) jeti_keys &= JETI_KEY_LEFT; if (keyState((EnumKeys)(KEY_RIGHT))) jeti_keys &= JETI_KEY_RIGHT; JetiBufferReady = 0; // invalidate buffer JETI_putw((uint16_t) jeti_keys); _delay_ms (1); JETI_DisableTXD(); jeti_keys = JETI_KEY_NOCHANGE; } }
void putsControlMode(uint8_t x, uint8_t y, uint8_t idx, uint8_t attr, uint8_t len) { if (idx < ACM_NUM_MODES) { lcd_putsnAtt(x, y, PSTR(CONROL_MODE_STR) + 6 * idx, len, attr); } else if (idx < NUM_MODES) { idx -= ACM_NUM_MODES; lcd_putsnAtt(x, y, PSTR(CONROL_MODE_STR_APM) + 6 * idx, len, attr); } else if (idx < NUM_MODES_ALL) { idx -= NUM_MODES; lcd_putsnAtt(x, y, PSTR(DISPLAY_ONLY_STR) + 6 * idx, len, attr); } else { for (uint8_t i = 0; i < len; i++) { lcd_putcAtt(x, y, '-', attr); } } }
int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event) { uint16_t delta = GV_GET_GV1_VALUE(max); bool invers = (attr & INVERS); // TRACE("gvarMenuItem(val=%d min=%d max=%d)", value, min, max); if (invers && event == EVT_KEY_LONG(KEY_ENTER)) { s_editMode = !s_editMode; if (attr & PREC1) value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode)*10 : delta); else value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode) : delta); eeDirty(EE_MODEL); } if (GV_IS_GV_VALUE(value, min, max)) { if (attr & LEFT) attr -= LEFT; /* because of ZCHAR */ else x -= 2*FW+FWNUM; attr &= ~PREC1; int8_t idx = (int16_t) GV_INDEX_CALC_DELTA(value, delta); if (idx >= 0) ++idx; // transform form idx=0=GV1 to idx=1=GV1 in order to handle double keys invert if (invers) { CHECK_INCDEC_MODELVAR_CHECK(event, idx, -MAX_GVARS, MAX_GVARS, noZero); if (idx == 0) idx = 1; // handle reset to zero, map to GV1 } if (idx < 0) { value = (int16_t) GV_CALC_VALUE_IDX_NEG(idx, delta); idx = -idx; lcd_putcAtt(x-6, y, '-', attr); } else { value = (int16_t) GV_CALC_VALUE_IDX_POS(idx-1, delta); } putsStrIdx(x, y, STR_GV, idx, attr); } else { lcd_outdezAtt(x, y, value, attr); if (invers) value = checkIncDec(event, value, min, max, EE_MODEL | editflags); } return value; }
void menuProcNMEA3(uint8_t event) { switch(event) { case EVT_KEY_BREAK(KEY_LEFT): chainMenu(menuProcNMEA2); break; case EVT_KEY_BREAK(KEY_RIGHT): chainMenu(menuProcNMEA4); break; case EVT_KEY_LONG(KEY_UP): NMEA_DisableRXD(); chainMenu(menuProcStatistic); break; case EVT_KEY_LONG(KEY_DOWN): NMEA_DisableRXD(); chainMenu(menuProc0); break; } initval (LONG_BUF(0), PACK_RMC, SOG); initval (LONG_BUF(1), PACK_RMC, COG); initval (SHORT_BUF(2), PACK_GGA, SAT); // -> sbuf[2] title ('3'); lcd_puts_P ( 0*FW, 1*FH, PSTR("GrndSpeed[knt] Sat")); if (rbuf[0][0]) // if first position is 00, buffer is empty, taken as false { // any other value is true uint8_t i = 0; while (rbuf[0][i]) { if (rbuf[0][i] == '.') // find decimal point and insert End of String 3 positions higher { rbuf[0][i+3] = 0; break; } i++; } lcd_putsAtt ( 2*FW, 2*FH, VALSTR(0), APSIZE); // speed over ground } else lcd_putsAtt ( 2*FW, 2*FH, val_unknown, APSIZE); lcd_putcAtt ( 19*FW, 1*FH, sbuf[2], 0); // satellites in view lcd_puts_P ( 1*FW, 4*FH, PSTR("Course over ground") ); lcd_putsAtt ( 2*FW, 5*FH, VALSTR(1), APSIZE); // course over ground }
//uint8_t lcd_putsnAtt(uint8_t x,uint8_t y,const prog_char * s,uint8_t len,uint8_t mode) void lcd_putsnAtt(uint8_t x,uint8_t y,const prog_char * s,uint8_t len,uint8_t mode) { uint8_t source ; source = mode & BSS ; // size = mode & DBLSIZE ; while(len!=0) { char c = (source) ? *s++ : pgm_read_byte(s++); if ( c == 0 ) { return ; } x = lcd_putcAtt(x,y,c,mode); // x+=FW; // if ((size)&& (c!=0x2E)) x+=FW; //check for decimal point len--; } }
void menuMainView(uint8_t event) { STICK_SCROLL_DISABLE(); uint8_t view = g_eeGeneral.view; uint8_t view_base = view & 0x0f; switch(event) { case EVT_ENTRY: killEvents(KEY_EXIT); killEvents(KEY_UP); killEvents(KEY_DOWN); break; /* TODO if timer2 is OFF, it's possible to use this timer2 as in er9x... case EVT_KEY_BREAK(KEY_MENU): if (view_base == VIEW_TIMER2) { Timer2_running = !Timer2_running; AUDIO_KEYPAD_UP(); } break; */ case EVT_KEY_BREAK(KEY_RIGHT): case EVT_KEY_BREAK(KEY_LEFT): if (view_base <= VIEW_INPUTS) { #if defined(PCBSKY9X) if (view_base == VIEW_INPUTS) g_eeGeneral.view ^= ALTERNATE_VIEW; else g_eeGeneral.view = (g_eeGeneral.view + (4*ALTERNATE_VIEW) + ((event==EVT_KEY_BREAK(KEY_LEFT)) ? -ALTERNATE_VIEW : ALTERNATE_VIEW)) % (4*ALTERNATE_VIEW); #else g_eeGeneral.view ^= ALTERNATE_VIEW; #endif eeDirty(EE_GENERAL); AUDIO_KEYPAD_UP(); } break; #if defined(NAVIGATION_MENUS) case EVT_KEY_CONTEXT_MENU: killEvents(event); #if defined(CPUARM) if (modelHasNotes()) { MENU_ADD_ITEM(STR_VIEW_NOTES); } #endif #if defined(CPUARM) MENU_ADD_ITEM(STR_RESET_SUBMENU); #else MENU_ADD_ITEM(STR_RESET_TIMER1); MENU_ADD_ITEM(STR_RESET_TIMER2); #if defined(FRSKY) MENU_ADD_ITEM(STR_RESET_TELEMETRY); #endif MENU_ADD_ITEM(STR_RESET_FLIGHT); #endif MENU_ADD_ITEM(STR_STATISTICS); #if defined(CPUARM) MENU_ADD_ITEM(STR_ABOUT_US); #endif menuHandler = onMainViewMenu; break; #endif #if MENUS_LOCK != 2 /*no menus*/ case EVT_KEY_LONG(KEY_MENU):// go to last menu pushMenu(lastPopMenu()); killEvents(event); break; CASE_EVT_ROTARY_BREAK case EVT_KEY_MODEL_MENU: pushMenu(menuModelSelect); killEvents(event); break; CASE_EVT_ROTARY_LONG case EVT_KEY_GENERAL_MENU: pushMenu(menuGeneralSetup); killEvents(event); break; #endif case EVT_KEY_BREAK(KEY_UP): case EVT_KEY_BREAK(KEY_DOWN): g_eeGeneral.view = (event == EVT_KEY_BREAK(KEY_UP) ? (view_base == VIEW_COUNT-1 ? 0 : view_base+1) : (view_base == 0 ? VIEW_COUNT-1 : view_base-1)); eeDirty(EE_GENERAL); AUDIO_KEYPAD_UP(); break; case EVT_KEY_STATISTICS: chainMenu(menuStatisticsView); killEvents(event); break; case EVT_KEY_TELEMETRY: #if defined(FRSKY) if (!IS_FAI_ENABLED()) chainMenu(menuTelemetryFrsky); #elif defined(JETI) JETI_EnableRXD(); // enable JETI-Telemetry reception chainMenu(menuTelemetryJeti); #elif defined(ARDUPILOT) ARDUPILOT_EnableRXD(); // enable ArduPilot-Telemetry reception chainMenu(menuTelemetryArduPilot); #elif defined(NMEA) NMEA_EnableRXD(); // enable NMEA-Telemetry reception chainMenu(menuTelemetryNMEA); #elif defined(MAVLINK) chainMenu(menuTelemetryMavlink); #else chainMenu(menuStatisticsDebug); #endif killEvents(event); break; case EVT_KEY_FIRST(KEY_EXIT): #if defined(GVARS) && !defined(PCBSTD) if (s_gvar_timer > 0) { s_gvar_timer = 0; } #endif if (view == VIEW_TIMER2) { timerReset(1); } AUDIO_KEYPAD_UP(); break; #if !defined(NAVIGATION_MENUS) case EVT_KEY_LONG(KEY_EXIT): flightReset(); AUDIO_KEYPAD_UP(); break; #endif } { // Flight Mode Name uint8_t mode = mixerCurrentFlightMode; lcd_putsnAtt(PHASE_X, PHASE_Y, g_model.flightModeData[mode].name, sizeof(g_model.flightModeData[mode].name), ZCHAR|PHASE_FLAGS); // Model Name putsModelName(MODELNAME_X, MODELNAME_Y, g_model.header.name, g_eeGeneral.currModel, BIGSIZE); // Main Voltage (or alarm if any) displayVoltageOrAlarm(); // Timers displayTimers(); // Trims sliders displayTrims(mode); } if (view_base < VIEW_INPUTS) { // scroll bar lcd_hlineStip(38, 34, 54, DOTTED); #if defined(PCBSKY9X) lcd_hline(38 + (g_eeGeneral.view / ALTERNATE_VIEW) * 13, 34, 13, SOLID); #else lcd_hline((g_eeGeneral.view & ALTERNATE_VIEW) ? 64 : 38, 34, 26, SOLID); #endif for (uint8_t i=0; i<8; i++) { uint8_t x0,y0; #if defined(PCBSKY9X) uint8_t chan = 8*(g_eeGeneral.view / ALTERNATE_VIEW) + i; #else uint8_t chan = (g_eeGeneral.view & ALTERNATE_VIEW) ? 8+i : i; #endif int16_t val = channelOutputs[chan]; switch(view_base) { case VIEW_OUTPUTS_VALUES: x0 = (i%4*9+3)*FW/2; y0 = i/4*FH+40; #if defined(PPM_UNIT_US) lcd_outdezAtt(x0+4*FW , y0, PPM_CH_CENTER(chan)+val/2, 0); #elif defined(PPM_UNIT_PERCENT_PREC1) lcd_outdezAtt(x0+4*FW , y0, calcRESXto1000(val), PREC1); #else lcd_outdezAtt(x0+4*FW , y0, calcRESXto1000(val)/10, 0); // G: Don't like the decimal part* #endif break; case VIEW_OUTPUTS_BARS: #define WBAR2 (50/2) x0 = i<4 ? LCD_W/4+2 : LCD_W*3/4-2; y0 = 38+(i%4)*5; uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2; int8_t len = (abs(val) * WBAR2 + lim/2) / lim; if(len>WBAR2) len = WBAR2; // prevent bars from going over the end - comment for debugging lcd_hlineStip(x0-WBAR2, y0, WBAR2*2+1, DOTTED); lcd_vline(x0,y0-2,5); if (val>0) x0+=1; else x0-=len; lcd_hline(x0,y0+1,len); lcd_hline(x0,y0-1,len); break; } } } else if (view_base == VIEW_INPUTS) { if (view == VIEW_INPUTS) { // Sticks + Pots doMainScreenGraphics(); // Switches for (uint8_t i=SWSRC_THR; i<=SWSRC_TRN; i++) { int8_t sw = (i == SWSRC_TRN ? (switchState(SW_ID0) ? SWSRC_ID0 : (switchState(SW_ID1) ? SWSRC_ID1 : SWSRC_ID2)) : i); uint8_t x = 2*FW-2, y = i*FH+1; if (i>=SWSRC_AIL) { x = 17*FW-1; y -= 3*FH; } putsSwitches(x, y, sw, getSwitch(i) ? INVERS : 0); } } else { #if defined(PCBMEGA2560) && defined(ROTARY_ENCODERS) for (uint8_t i=0; i<NUM_ROTARY_ENCODERS; i++) { int16_t val = getRotaryEncoder(i); int8_t len = limit((int16_t)0, (int16_t)(((val+1024) * BAR_HEIGHT) / 2048), (int16_t)BAR_HEIGHT); #if ROTARY_ENCODERS > 2 #define V_BAR_W 5 V_BAR(LCD_W/2-8+V_BAR_W*i, LCD_H-8, len); #else #define V_BAR_W 5 V_BAR(LCD_W/2-3+V_BAR_W*i, LCD_H-8, len); #endif } #endif // PCBGRUVIN9X && ROTARY_ENCODERS // Logical Switches #if defined(PCBSKY9X) for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++) { int8_t len = getSwitch(SWSRC_SW1+i) ? BAR_HEIGHT : 1; uint8_t x = VSWITCH_X(i); lcd_vline(x-1, VSWITCH_Y-len, len); lcd_vline(x, VSWITCH_Y-len, len); } #elif defined(CPUM2560) for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++) putsSwitches(2*FW-3 + (i/3)*(i/3>2 ? 3*FW+2 : (3*FW-1)) + (i/3>2 ? 2*FW : 0), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i) ? INVERS : 0); #elif !defined(PCBSTD) for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++) putsSwitches(2*FW-2 + (i/3)*(4*FW-1), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i) ? INVERS : 0); #else for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++) putsSwitches(2*FW-3 + (i/3)*(4*FW), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i) ? INVERS : 0); #endif } } else { // timer2 #if defined(TRANSLATIONS_CZ) #define TMR2_LBL_COL (20-FW/2+1) #else #define TMR2_LBL_COL (20-FW/2+5) #endif putsTimer(33+FW+2+10*FWNUM-4, FH*5, timersStates[1].val, DBLSIZE, DBLSIZE); putsTimerMode(timersStates[1].val >= 0 ? TMR2_LBL_COL : TMR2_LBL_COL-7, FH*6, g_model.timers[1].mode); // lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s } // And ! in case of unexpected shutdown if (unexpectedShutdown) { lcd_putcAtt(REBOOT_X, 0*FH, '!', INVERS); } #if defined(GVARS) && !defined(PCBSTD) if (s_gvar_timer > 0) { s_gvar_timer--; s_warning = STR_GLOBAL_VAR; displayBox(); lcd_putsnAtt(16, 5*FH, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR); lcd_putsAtt(16+7*FW, 5*FH, PSTR("[\010]"), BOLD); lcd_outdezAtt(16+7*FW+4*FW+FW/2, 5*FH, GVAR_VALUE(s_gvar_last, getGVarFlightPhase(mixerCurrentFlightMode, s_gvar_last)), BOLD); s_warning = NULL; } #endif #if defined(DSM2) if (moduleFlag[0] == MODULE_BIND) { // Issue 98 lcd_putsAtt(15*FW, 0, PSTR("BIND"), 0); } #endif }
void menuProcNMEA1(uint8_t event) { if (rmcreceived) initval (LONG_BUF(0), PACK_RMC, TIM); // sets rbuf[0][.] passes +=1; count=0; switch(event) // new event received, branch accordingly { case EVT_KEY_BREAK(KEY_LEFT): #if defined(HUB) chainMenu(menuProcNMEA5); #else chainMenu(menuProcNMEA4); #endif break; case EVT_KEY_BREAK(KEY_RIGHT): chainMenu(menuProcNMEA2); break; case EVT_KEY_LONG(KEY_UP): NMEA_DisableRXD(); chainMenu(menuProcStatistic); break; case EVT_KEY_LONG(KEY_DOWN): NMEA_DisableRXD(); #if defined(OPEN9X) chainMenu(menuMainView); #else chainMenu(menuProc0); #endif break; case EVT_KEY_FIRST(KEY_MENU): if (show_timer == 0) { show_timer = 1; if (gpstimer <= 0) gpstimer = bintime(rbuf[0]); } else show_timer = 0; break; case EVT_KEY_FIRST(KEY_EXIT): if ((show_timer == 1) &&(rbuf[0][0])) { gpstimer = bintime(rbuf[0]); // get actual GPS time ->resets timer to 00:00 } break; } /* How to use: You choose the values to be displayed using the function: initval(<number>, <packet>, <value>); ------------------------------------- That means that "<value>" of "<packet>" is stored in the <number> buffer. The first <number> is 0. $GPGGA,125109.272,5014.7262,N,01123.9966,E,2,07,1.2,624.7,M,47.7,M,1.9,0000*77 $GPRMC,125109.272,A,5014.7262,N,01123.9966,E,33.439922,47.98,230711,,*09 Here are the packet names and the associated value names: Position packet (beginning with "GGA"): "PACK_GGA" value names: "TIM", "LAT", "NOS", "LON", "EOW", "FIX", "SAT", "DIL", "ALT", "MTR", "GEO", "MET", "AGE", "DIF", Required minimum packet (beginning with "RMC"): "PACK_RMC" value names: "TIM", "NRW", "LT1", "NSO", "LN1", "EWE", "SOG", "COG", "DAT", "MAG", "EAW" The buffers are accessed using the macro "VALSTR(<n>)", where "<n>" is "0" for the first buffer, and "1" for the second buffer. sbuf is a single character buffer and contains the last value of a field ???? rbuf[x][y] contains the full field When a value is missing, it is replaced by the contents of val_unknown ("?"). */ title ('1'); my_lcd_puts ( 2*FW, 1*FH, PSTR("UTC-Time Sat")); if (ggareceived) { ggareceived=0; passes=0; initval (SHORT_BUF(1), PACK_GGA, FIX); // -> sbuf[1] fixed=(sbuf[1]>0x30) ? ATTRIB : 0 ; } if (rmcreceived) { rmcreceived=0; initval (LONG_BUF(1), PACK_RMC, DAT); // sets rbuf[1][.] gpstime=bintime(rbuf[0]); } if (rbuf[0][0]) { // show always if RMC data have been received initval (LONG_BUF(4), PACK_GGA, SAT); // -> rbuf[4] lcd_putsnAtt ( 19*FW, 1*FH, &rbuf[4][0], 2, 16+fixed); // satellites in view, invers if Fixed lcd_putsnAtt ( 2*FW, 2*FH, &rbuf[0][0], 2, APSIZE); // hours lcd_putcAtt ( 6*FW, 2*FH, ':', DBLSIZE); // ":" lcd_putsnAtt ( 8*FW, 2*FH, &rbuf[0][2], 2, APSIZE); // minutes lcd_putcAtt ( 12*FW, 2*FH, ':', DBLSIZE); // ":" lcd_putsnAtt ( 14*FW, 2*FH, &rbuf[0][4], 2, APSIZE); // seconds } else lcd_putsAtt ( 2*FW, 2*FH, val_unknown, APSIZE); // "?" if (show_timer) { // show the Timer when data have been received my_lcd_puts ( 2*FW, 4*FH, PSTR("Timer")); // display "Timer" putsTime ( 5*FW, 5*FH, (gpstime-gpstimer), DBLSIZE, DBLSIZE); // display difference as mm:ss } else { my_lcd_puts ( 2*FW, 4*FH, PSTR("Date")); // show the UTC Date if (rbuf[1][0]) { lcd_putsnAtt( 2*FW, 5*FH, &rbuf[1][0], 2, APSIZE); // year lcd_putcAtt ( 6*FW, 5*FH, '/', DBLSIZE); // "/" lcd_putsnAtt( 8*FW, 5*FH, &rbuf[1][2], 2, APSIZE); // month lcd_putcAtt (12*FW, 5*FH, '/', DBLSIZE); // "/" lcd_putsnAtt(14*FW, 5*FH, &rbuf[1][4], 2, APSIZE); // day } } question(9,3); // large blinking Questionmark in case of timeout }
void putsRotarySwPos(uint8_t x, uint8_t y, uint8_t idx, uint8_t att) { lcd_putcAtt(x, y, 'P', att); lcd_putcAtt(x + FW, y, '1' + idx, att); }
//============================================================================== void menuProcNMEA2(uint8_t event) { static int8_t set_home; passes +=1; switch(event) { // Menu navigation case EVT_KEY_BREAK(KEY_LEFT): chainMenu(menuProcNMEA1); break; case EVT_KEY_BREAK(KEY_RIGHT): chainMenu(menuProcNMEA3); break; //Beep setting case EVT_KEY_BREAK(KEY_UP): killEvents(event); beep_on = beep_on ^ 1; // toggle Beep ON/OFF audioDefevent(AU_MENUS); // short blip break; case EVT_KEY_LONG(KEY_UP): NMEA_DisableRXD(); chainMenu(menuProcStatistic); break; //Voice setting case EVT_KEY_BREAK(KEY_DOWN): // Switch Voice on/off killEvents(event); beep_on = beep_on ^ 2; // toggle Voice ON/OFF audioDefevent(AU_MENUS); // short blip v_prev_alt=0; prev_dist=0; break; case EVT_KEY_LONG(KEY_DOWN): NMEA_DisableRXD(); #if defined(OPEN9X) chainMenu(menuMainView); #else chainMenu(menuProc0); #endif /* break; //Beep setting case EVT_KEY_FIRST(KEY_UP): killEvents(event); beep_on = beep_on ^ 1; // toggle Beep ON/OFF audioDefevent(AU_MENUS); // short blip break; //Voice setting case EVT_KEY_FIRST(KEY_DOWN): // Switch Voice on/off killEvents(event); beep_on = beep_on ^ 2; // toggle Voice ON/OFF audioDefevent(AU_MENUS); // short blip v_prev_alt=0; prev_dist=0; break; */ /* Altitude setting: Set a home position for altitude. Normally used before starting the model when GPS has got a fix. MENU[short] --> alternating relative and absolute altitudes MENU[long] --> set home altitude to current altitude EXIT[long] --> reset max altitude to 0 Switch ON / OFF short beep with positive lift DOWN[short] --> Toggle Positive lift Beep on/off Switch ON / OFF voice for altitude and distance UP[short] --> Toggle voice message of altitude and distance on/off */ case EVT_KEY_BREAK(KEY_MENU): // Menu short if (!home_alt) // umschalten zwischen absoluter und relativer Höhe home_alt = save_alt; else home_alt=0; if (save_alt==0) // wenn noch keine Home Höhe gesetzt war, wird sie es jetzt, weil sonst // das Umschalten keine Wirkung zeigt save_alt = home_alt = abs_alt; // absolute altitude audioDefevent(AU_MENUS); // short blip for non negative lift break; case EVT_KEY_LONG(KEY_MENU): // Menu long, set home position killEvents(event); set_home=1; save_alt = home_alt =abs_alt ; // Home altitude auf aktuelle absolute Höhe setzen max_alt=0; // es ist irritierend, wenn max_alt bestehen bliebe d_pass = max_pass>>1; audioDefevent(AU_MENUS); // short blip break; case EVT_KEY_BREAK(KEY_EXIT): // Exit short resets max_alt and MaxDistance MaxDistance = max_alt = 0; audioDefevent(AU_MENUS); // short blip break; case EVT_KEY_LONG(KEY_EXIT): // Exit long resets all distance and altitude values killEvents(event); pilotLatitude=pilotLongitude=LastDistance=MaxDistance=save_alt = home_alt = abs_alt=max_alt=increasing=decreasing=0; audioDefevent(AU_MENUS); // short blip break; } title ('2'); my_lcd_puts ( 1*FW, 1*FH, PSTR("Altitude Sat Max")); my_lcd_puts ( 16*FW, 3*FH, PSTR("Home")); my_lcd_puts ( 1*FW, 4*FH, PSTR("Lift") ); lcd_putsAtt (16*FW, 5*FH, PSTR("Beep"), ((beep_on==1)|(beep_on==3))); lcd_putsAtt (16*FW, 6*FH, PSTR("Voice"), (beep_on >=2)); /* lcd_putcAtt( 16*FW, 5*FH, 'B', ((beep_on==1)|(beep_on==3))); //first letter inverted if active my_lcd_puts( 17*FW, 5*FH, PSTR("eep") ); lcd_putcAtt( 16*FW, 6*FH, 'V', (beep_on>=2)) ; //first letter inverted if active my_lcd_puts( 17*FW, 6*FH, PSTR("oice") ); */ lcd_outdezNAtt( 20*FW, 4*FH, home_alt, PREC1, 6); // display home_alt, small characters rmcreceived=0; // RMC Pack not used //---------------------------------------- if (ggareceived) // at least one second has elapsed { ggareceived = 0; passes=0; if (count < MaxCount) count +=1; initval (LONG_BUF(0), PACK_GGA, ALT); // -> rbuf[0] initval (LONG_BUF(1), PACK_GGA, GEO); // -> rbuf[1] initval (SHORT_BUF(0), PACK_GGA, MTR); // -> sbuf[0] initval (SHORT_BUF(1), PACK_GGA, FIX); // -> sbuf[1] initval (SHORT_BUF(2), PACK_GGA, SAT); // -> sbuf[2] fixed=(sbuf[1]>0x30) ? ATTRIB : 0 ; satellites=sbuf[2]; /* ALT and GEO have one single digit following the decimal point e.g. ALT=359.7 GEO=47.7 The altitude over mean sea level is to be calculated as: altitude minus geoidal separation */ abs_alt = binary(rbuf[0]) - binary(rbuf[1]); // alt - geo that is absolute altitude if (abs_alt> max_alt) max_alt=abs_alt; // hold max altitude relative to 0 m rel_alt=abs_alt - home_alt; // alt - geo - home altitude relative to home initval (LONG_BUF(2), PACK_GGA, LAT); // -> rbuf[2] gpsLatitude_bp=split((rbuf[2]),DP); // Latitude before decimal point gpsLatitude_ap=split((rbuf[2]),EOS); // Latitude after decimal point initval (LONG_BUF(3), PACK_GGA, LON); // -> rbuf[3] gpsLongitude_bp=split((rbuf[3]),DP); // Longitude before decimal point gpsLongitude_ap=split((rbuf[3]),EOS); // Longitude after decimal point if ((a_pass >= max_pass) | ((a_pass + d_pass) > max2_pass)) { // Höhe ändert sich uint16_t alt_diff = (rel_alt > v_prev_alt) ? rel_alt - v_prev_alt: v_prev_alt - rel_alt ; if ((fixed) && (beep_on & 0x2) && (alt_diff >= 100)) // diff of 10 m { v_prev_alt = rel_alt; // kann auch negativ sein if (rel_alt > 0) // nur positive Werte ansagen. voice kann nicht negative { a_pass = 0; putVoiceQueue(V_ALTITUDE) ; //!!!!!!!!!!!!!!!! voice_numeric(rel_alt/10, 0,V_METRES); //!!!!!!!!!!!!!!!! } } } lift_alt = rel_alt - prev_alt; prev_alt = rel_alt; //!!!!!!!!!!!!!! if ((lift_alt >= 0) && (fixed) && (beep_on & 0x1)) // GGA record must have Fix> 0 audioDefevent(AU_MENUS); // short blip for non negative lift //!!!!!!!!!!!!!!!!! } //---------------------------------------- // Shown value depends on home_alt. // For home_alt=0 this is altitude relativeto sea level // For home_alt > 0 this is altitude relative to home level lcd_outdezNAtt( 20*FW, 2*FH, (max_alt-home_alt), PREC1, 6); // max_altitude rel 0 or home //---------------------------------------- if (pilotLatitude | (set_home)) // show distance only, when home position has been set { my_lcd_puts ( 11*FW, 4*FH, PSTR("Dist") ); GpsDistance=getGpsDistance(); if ((d_pass >= max_pass) | ((a_pass + d_pass) > max2_pass)) { uint16_t dist_diff = (GpsDistance > prev_dist) ? GpsDistance - prev_dist: prev_dist - GpsDistance ; if ( (fixed) && (beep_on & 0x2) && (dist_diff >= 500) ) // diff of 50 m { prev_dist=GpsDistance ; putVoiceQueue(V_DISTANCE) ; voice_numeric(GpsDistance/10, 0, V_METRES) ; d_pass = 0; } } // GetGpsDistance intermittently returns a wrong, much to high value (e.g.3284.2 instead of 15.3) // Try to catch it and avoid MaxDistance to go incorrectly high // MaxDistance is only set, if two consecutive values are greater than MaxDistance if (count==MaxCount) { if (set_home) { LastDistance=MaxDistance=increasing=decreasing=0; getGpsPilotPosition(); pilotAltitude = abs_alt; set_home=0; } if (GpsDistance > MaxDistance) { if (increasing) { MaxDistance=LastDistance; increasing=0; } else { increasing=1; } } else increasing=0; LastDistance=GpsDistance; lcd_outdezNAtt( 15*FW, 5*FH, MaxDistance, PREC1, 6); // Distance lcd_outdezNAtt( 15*FW, 6*FH, GpsDistance, PREC1, 6); // Distance } // on a communication loss, after a delay of some seconds, the last values are displayed else if (passes > 300) { lcd_outdezNAtt( 15*FW, 5*FH, MaxDistance, PREC1, 6); // show last MaxDistance lcd_outdezNAtt( 15*FW, 6*FH, LastDistance, PREC1, 6); // show LastDistance lcd_putsAtt ( 12*FW, 2*FH, val_unknown, 22); // large blinking Questionmark above Dist. } } //--------for Test only -------------------------------- /* initval (LONG_BUF(4), PACK_GGA, SAT); // -> rbuf[4] ER9X open9x lcd_putsnAtt ( 12*FW, 2*FH, &rbuf[4][0], 2, 16); // small normal lcd_putsnAtt ( 12*FW, 3*FH, &rbuf[4][0], 2, 17); // invers BLINK lcd_putsnAtt ( 12*FW, 4*FH, &rbuf[4][0], 2, 18); // blink INVERS lcd_putsnAtt ( 12*FW, 5*FH, &rbuf[4][0], 2, 20); // big normal */ //---------------------------------------- #if defined(HUB) initval (LONG_BUF(5), PACK_LCL, RSSI); // -> rbuf[4] lcd_putsnAtt ( 12*FW, 3*FH, &rbuf[5][0], 3, 16); // small normal my_lcd_puts ( 14*FW, 3*FH, PSTR("%") ); #endif if (rbuf[0][0]) { initval (LONG_BUF(4), PACK_GGA, SAT); // -> rbuf[4] lcd_putsnAtt (13*FW, 1*FH, &rbuf[4][0], 2, 16+fixed); // satellites in view, //invers if Fixed if (sbuf[1]>0x30) { // & GGA has FIX > "0" lcd_outdezNAtt( 10*FW, 2*FH, rel_alt, DBLSIZE|PREC1, 7); // actual altitude lcd_putcAtt ( 10*FW, 3*FH, sbuf[0]+0x20, 0); // dimension [m] as lower case lcd_outdezNAtt( 8*FW, 5*FH, lift_alt, DBLSIZE|PREC1, 6); // lift my_lcd_puts ( 5*FW, 4*FH, PSTR("[ /s]") ); lcd_putcAtt ( 6*FW, 4*FH, sbuf[0]+0x20, 0); // dimension [m/s] as lower case } } //---------------------------------------- // in case we do not receive GGA packages(due to poor receiption) the passes count will increase accordingly. question(12,2); // large blinking Questionmark in case of timeout }
void menuProcNMEA1(uint8_t event) { switch(event) // new event received, branch accordingly { case EVT_KEY_BREAK(KEY_LEFT): chainMenu(menuProcNMEA4); break; case EVT_KEY_BREAK(KEY_RIGHT): chainMenu(menuProcNMEA2); break; case EVT_KEY_LONG(KEY_UP): NMEA_DisableRXD(); chainMenu(menuProcStatistic); break; case EVT_KEY_LONG(KEY_DOWN): NMEA_DisableRXD(); chainMenu(menuProc0); break; case EVT_KEY_FIRST(KEY_MENU): if (show_timer == 0) { show_timer = 1; if (gpstimer <= 0) gpstimer = bintime(rbuf[2]); } else show_timer = 0; break; case EVT_KEY_FIRST(KEY_EXIT): if ((show_timer == 1) &&(rbuf[2][0])) gpstimer = bintime(rbuf[2]); // get actual GPS time ->resets timer to 00:00 break; } /* How to use: You choose the values to be displayed using the function: initval(<number>, <packet>, <value>); ------------------------------------- That means that "<value>" of "<packet>" is stored in the <number> buffer. The first <number> is 0. Here are the packet names and the associated value names: Position packet (beginning with "GGA"): "PACK_GGA" value names: "TIM", "LAT", "NOS", "LON", "EOW", "FIX", "SAT", "DIL", "ALT", "MTR", "GEO", "MET", "AGE", "DIF", Required minimum packet (beginning with "RMC"): "PACK_RMC" value names: "TIM", "NRW", "LT1", "NSO", "LN1", "EWE", "SOG", "COG", "DAT", "MAG", "EAW" The buffers are accessed using the macro "VALSTR(<n>)", where "<n>" is "0" for the first buffer, and "1" for the second buffer. When a value is missing, it is replaced by the contents of val_unknown ("?"). */ if (ggareceived) { gpstime=bintime(rbuf[2]); ggareceived=0; } initval (LONG_BUF(0), PACK_RMC, TIM); // sets rbuf[0][.] initval (LONG_BUF(1), PACK_RMC, DAT); // sets rbuf[1][.] initval (SHORT_BUF(0), PACK_RMC, NRW); // sets sbuf[0] initval (SHORT_BUF(2), PACK_GGA, SAT); // -> sbuf[2] title ('1'); lcd_puts_P ( 2*FW, 1*FH, PSTR("UTC-Time Sat")); if (rbuf[0][0]) { // show always if data have been received lcd_putcAtt ( 19*FW, 1*FH, sbuf[2], 0); // satellites in view lcd_putsnAtt ( 2*FW, 2*FH, &rbuf[0][0], 2, APSIZE); // hours lcd_putcAtt ( 6*FW, 2*FH, ':', DBLSIZE); // ":" lcd_putsnAtt ( 8*FW, 2*FH, &rbuf[0][2], 2, APSIZE); // minutes lcd_putcAtt ( 12*FW, 2*FH, ':', DBLSIZE); // ":" lcd_putsnAtt ( 14*FW, 2*FH, &rbuf[0][4], 2, APSIZE); // seconds } else lcd_putsAtt ( 2*FW, 2*FH, val_unknown, APSIZE); // "?" if ((show_timer == 1) && rbuf[0][0]) { // show the Timer when data have been received lcd_puts_P ( 2*FW, 4*FH, PSTR("Timer")); // display "Timer" putsTime ( 5*FW, 5*FH, (gpstime-gpstimer), DBLSIZE, DBLSIZE); // display difference as mm:ss } else { lcd_puts_P ( 2*FW, 4*FH, PSTR("Date")); // show the UTC Date if (rbuf[1][0]) { lcd_putsnAtt( 2*FW, 5*FH, &rbuf[1][0], 2, APSIZE); // year lcd_putcAtt ( 6*FW, 5*FH, '/', DBLSIZE); // "/" lcd_putsnAtt( 8*FW, 5*FH, &rbuf[1][2], 2, APSIZE); // month lcd_putcAtt (12*FW, 5*FH, '/', DBLSIZE); // "/" lcd_putsnAtt(14*FW, 5*FH, &rbuf[1][4], 2, APSIZE); // day } else lcd_putsAtt ( 2*FW, 5*FH, val_unknown, APSIZE); // "?" } }
void putsVBat(uint8_t x,uint8_t y,uint8_t att) { //att |= g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0; lcd_outdezAtt( x+ 3*FW, y, g_vbat100mV,att|PREC1); lcd_putcAtt( x+ 3*FW, y, 'V',att); }
void putsVolts(uint8_t x,uint8_t y, uint8_t volts, uint8_t att) { lcd_outdezAtt(x, y, volts, att|PREC1); if(!(att&NO_UNIT)) lcd_putcAtt(Lcd_lastPos, y, 'v', att); }
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; } } }
uint8_t lcd_outdezNAtt( uint8_t x, uint8_t y, int32_t val, uint8_t mode, int8_t len ) { uint8_t fw = FWNUM; uint8_t prec = PREC(mode); uint8_t negative = 0 ; uint8_t xn = 0; uint8_t ln = 2; char c; uint8_t xinc ; uint8_t fullwidth = 0 ; mode &= ~NO_UNIT ; if ( len < 0 ) { fullwidth = 1 ; len = -len ; } if ( val < 0 ) { val = -val ; negative = 1 ; } if (mode & DBLSIZE) { fw += FWNUM ; xinc = 2*FWNUM; lcd_lastPos = 2*FW; } else { xinc = FWNUM ; lcd_lastPos = FW; } if (mode & LEFT) { // if (val >= 10000) // x += fw; if(negative) { x += fw; } if (val >= 1000) x += fw; if (val >= 100) x += fw; if (val >= 10) x += fw; if ( prec ) { if ( prec == 2 ) { if ( val < 100 ) { x += fw; } } if ( val < 10 ) { x+= fw; } } } else { x -= xinc; } lcd_lastPos += x ; if ( prec == 2 ) { mode -= LEADING0; // Can't have PREC2 and LEADING0 } for (uint8_t i=1; i<=len; i++) { div_t qr ; qr = div( val, 10 ) ; c = (qr.rem) + '0'; lcd_putcAtt(x, y, c, mode); if (prec==i) { if (mode & DBLSIZE) { xn = x; if( c<='3' && c>='1') ln++; uint8_t tn = (qr.quot) % 10; if(tn==2 || tn==4) { if (c=='4') { xn++; } else { xn--; ln++; } } } else { x -= 2; if (mode & INVERS) lcd_vline(x+1, y, 7); else lcd_plot(x+1, y+6); } if (qr.quot) prec = 0; } val = qr.quot ; if (!val) { if (prec) { if ( prec == 2 ) { if ( i > 1 ) { prec = 0 ; } } else { prec = 0 ; } } else if (mode & LEADING0) { if ( fullwidth == 0 ) { mode -= LEADING0; } } else break; } x-=fw; } if (xn) { lcd_hline(xn, y+2*FH-4, ln); lcd_hline(xn, y+2*FH-3, ln); } if(negative) lcd_putcAtt(x-fw,y,'-',mode); asm("") ; return 0 ; // Stops compiler creating two sets of POPS, saves flash }
void menuGeneralSetup(uint8_t event) { #if defined(RTCLOCK) struct gtm t; gettime(&t); if ((menuVerticalPosition==ITEM_SETUP_DATE || menuVerticalPosition==ITEM_SETUP_TIME) && (s_editMode>0) && (event==EVT_KEY_FIRST(KEY_ENTER) || event==EVT_KEY_FIRST(KEY_EXIT) || IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event))) { // set the date and time into RTC chip rtcSetTime(&t); } #endif #if defined(FAI_CHOICE) if (warningResult) { warningResult = 0; g_eeGeneral.fai = true; eeDirty(EE_GENERAL); } #endif MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, { 2, 2, 1, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO_CPUARM(LABEL(VARIO)) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, 0, CASE_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, IF_FAI_CHOICE(0) CASE_MAVLINK(0) 0, 0, LABEL(TX_MODE), 0, 1/*to force edit mode*/ }); int sub = menuVerticalPosition; for (unsigned int i=0; i<NUM_BODY_LINES; i++) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; uint8_t k = i+menuVerticalOffset; uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); uint8_t attr = (sub == k ? blink : 0); switch(k) { case ITEM_SETUP_DATE: lcd_putsLeft(y, STR_DATE); lcd_putc(RADIO_SETUP_DATE_COLUMN, y, '-'); lcd_putc(RADIO_SETUP_DATE_COLUMN+3*FW-2, y, '-'); for (uint8_t j=0; j<3; j++) { uint8_t rowattr = (menuHorizontalPosition==j ? attr : 0); switch (j) { case 0: lcd_outdezAtt(RADIO_SETUP_DATE_COLUMN, y, t.tm_year+1900, rowattr); if (rowattr && s_editMode>0) t.tm_year = checkIncDec(event, t.tm_year, 112, 200, 0); break; case 1: lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+3*FW-2, y, t.tm_mon+1, rowattr|LEADING0, 2); if (rowattr && s_editMode>0) t.tm_mon = checkIncDec(event, t.tm_mon, 0, 11, 0); break; case 2: { int16_t year = 1900 + t.tm_year; int8_t dlim = (((((year%4==0) && (year%100!=0)) || (year%400==0)) && (t.tm_mon==1)) ? 1 : 0); static const pm_uint8_t dmon[] PROGMEM = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; dlim += pgm_read_byte(&dmon[t.tm_mon]); lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+6*FW-4, y, t.tm_mday, rowattr|LEADING0, 2); if (rowattr && s_editMode>0) t.tm_mday = checkIncDec(event, t.tm_mday, 1, dlim, 0); break; } } } if (attr && menuHorizontalPosition < 0) drawFilledRect(RADIO_SETUP_2ND_COLUMN, y, LCD_W-RADIO_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); if (attr && checkIncDec_Ret) { g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated } break; case ITEM_SETUP_TIME: lcd_putsLeft(y, STR_TIME); lcd_putc(RADIO_SETUP_TIME_COLUMN+1, y, ':'); lcd_putc(RADIO_SETUP_TIME_COLUMN+3*FW-2, y, ':'); for (uint8_t j=0; j<3; j++) { uint8_t rowattr = (menuHorizontalPosition==j ? attr : 0); switch (j) { case 0: lcd_outdezNAtt(RADIO_SETUP_TIME_COLUMN, y, t.tm_hour, rowattr|LEADING0, 2); if (rowattr && s_editMode>0) t.tm_hour = checkIncDec(event, t.tm_hour, 0, 23, 0); break; case 1: lcd_outdezNAtt(RADIO_SETUP_TIME_COLUMN+3*FWNUM, y, t.tm_min, rowattr|LEADING0, 2); if (rowattr && s_editMode>0) t.tm_min = checkIncDec(event, t.tm_min, 0, 59, 0); break; case 2: lcd_outdezNAtt(RADIO_SETUP_TIME_COLUMN+6*FWNUM, y, t.tm_sec, rowattr|LEADING0, 2); if (rowattr && s_editMode>0) t.tm_sec = checkIncDec(event, t.tm_sec, 0, 59, 0); break; } } if (attr && menuHorizontalPosition < 0) drawFilledRect(RADIO_SETUP_2ND_COLUMN, y, LCD_W-RADIO_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); if (attr && checkIncDec_Ret) g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated break; case ITEM_SETUP_BATT_RANGE: lcd_putsLeft(y, STR_BATTERY_RANGE); putsVolts(RADIO_SETUP_2ND_COLUMN, y, 90+g_eeGeneral.vBatMin, (menuHorizontalPosition==0 ? attr : 0)|LEFT|NO_UNIT); lcd_putc(lcdLastPos, y, '-'); putsVolts(lcdLastPos+FW, y, 120+g_eeGeneral.vBatMax, (menuHorizontalPosition>0 ? attr : 0)|LEFT|NO_UNIT); if (attr && menuHorizontalPosition < 0) drawFilledRect(RADIO_SETUP_2ND_COLUMN, y, LCD_W-RADIO_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); if (attr && s_editMode>0) { if (menuHorizontalPosition==0) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatMin, -50, g_eeGeneral.vBatMax+29); // min=4.0V else CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatMax, g_eeGeneral.vBatMin-29, +40); // max=16.0V } break; case ITEM_SETUP_SOUND_LABEL: lcd_putsLeft(y, STR_SOUND_LABEL); break; case ITEM_SETUP_BEEP_MODE: g_eeGeneral.beepMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_SPEAKER, STR_VBEEPMODE, g_eeGeneral.beepMode, -2, 1, attr, event); #if defined(FRSKY) if (attr && checkIncDec_Ret) frskySendAlarms(); #endif break; case ITEM_SETUP_SPEAKER_VOLUME: { lcd_putsLeft(y, STR_SPEAKER_VOLUME); uint8_t b = g_eeGeneral.speakerVolume+VOLUME_LEVEL_DEF; displaySlider(RADIO_SETUP_2ND_COLUMN, y, b, VOLUME_LEVEL_MAX, attr); if (attr) { CHECK_INCDEC_GENVAR(event, b, 0, VOLUME_LEVEL_MAX); if (checkIncDec_Ret) { g_eeGeneral.speakerVolume = (int8_t)b-VOLUME_LEVEL_DEF; } } break; } case ITEM_SETUP_BEEP_VOLUME: SLIDER_5POS(y, g_eeGeneral.beepVolume, STR_BEEP_VOLUME, event, attr); break; case ITEM_SETUP_WAV_VOLUME: SLIDER_5POS(y, g_eeGeneral.wavVolume, STR_WAV_VOLUME, event, attr); break; case ITEM_SETUP_BACKGROUND_VOLUME: SLIDER_5POS(y, g_eeGeneral.backgroundVolume, STR_BG_VOLUME, event, attr); break; case ITEM_SETUP_BEEP_LENGTH: SLIDER_5POS(y, g_eeGeneral.beepLength, STR_BEEP_LENGTH, event, attr); break; case ITEM_SETUP_SPEAKER_PITCH: lcd_putsLeft( y, STR_SPKRPITCH); lcd_putcAtt(RADIO_SETUP_2ND_COLUMN, y, '+', attr); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN+FW, y, g_eeGeneral.speakerPitch*15, attr|LEFT); lcd_putsAtt(lcdLastPos, y, "Hz", attr); if (attr) { CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerPitch, 0, 20); } break; #if defined(VARIO) case ITEM_SETUP_VARIO_LABEL: lcd_putsLeft(y, STR_VARIO); break; case ITEM_SETUP_VARIO_VOLUME: SLIDER_5POS(y, g_eeGeneral.varioVolume, TR_SPEAKER_VOLUME, event, attr); break; case ITEM_SETUP_VARIO_PITCH: lcd_putsLeft(y, STR_PITCH_AT_ZERO); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10), attr|LEFT); lcd_putsAtt(lcdLastPos, y, "Hz", attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioPitch, -40, 40); break; case ITEM_SETUP_VARIO_RANGE: lcd_putsLeft(y, STR_PITCH_AT_MAX); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10)+VARIO_FREQUENCY_RANGE+(g_eeGeneral.varioRange*10), attr|LEFT); lcd_putsAtt(lcdLastPos, y, "Hz", attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRange, -80, 80); break; case ITEM_SETUP_VARIO_REPEAT: lcd_putsLeft(y, STR_REPEAT_AT_ZERO); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_REPEAT_ZERO+(g_eeGeneral.varioRepeat*10), attr|LEFT); lcd_putsAtt(lcdLastPos, y, STR_MS, attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRepeat, -30, 50); break; #endif #if defined(HAPTIC) case ITEM_SETUP_HAPTIC_LABEL: lcd_putsLeft(y, STR_HAPTIC_LABEL); break; case ITEM_SETUP_HAPTIC_MODE: g_eeGeneral.hapticMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_MODE, STR_VBEEPMODE, g_eeGeneral.hapticMode, -2, 1, attr, event); break; case ITEM_SETUP_HAPTIC_LENGTH: SLIDER_5POS(y, g_eeGeneral.hapticLength, STR_LENGTH, event, attr); break; case ITEM_SETUP_HAPTIC_STRENGTH: SLIDER_5POS(y, g_eeGeneral.hapticStrength, STR_HAPTICSTRENGTH, event, attr); break; #endif case ITEM_SETUP_CONTRAST: lcd_putsLeft(y, STR_CONTRAST); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.contrast, attr|LEFT); if (attr) { CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, CONTRAST_MIN, CONTRAST_MAX); lcdSetContrast(); } break; case ITEM_SETUP_ALARMS_LABEL: lcd_putsLeft(y, STR_ALARMS_LABEL); break; case ITEM_SETUP_BATTERY_WARNING: lcd_putsLeft(y, STR_BATTERYWARNING); putsVolts(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.vBatWarn, attr|LEFT); if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatWarn, 40, 120); //4-12V break; case ITEM_SETUP_MEMORY_WARNING: { uint8_t b = 1-g_eeGeneral.disableMemoryWarning; g_eeGeneral.disableMemoryWarning = 1 - onoffMenuItem(b, RADIO_SETUP_2ND_COLUMN, y, STR_MEMORYWARNING, attr, event); break; } case ITEM_SETUP_ALARM_WARNING: { uint8_t b = 1-g_eeGeneral.disableAlarmWarning; g_eeGeneral.disableAlarmWarning = 1 - onoffMenuItem(b, RADIO_SETUP_2ND_COLUMN, y, STR_ALARMWARNING, attr, event); break; } case ITEM_SETUP_INACTIVITY_ALARM: lcd_putsLeft(y, STR_INACTIVITYALARM); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.inactivityTimer, attr|LEFT); lcd_putc(lcdLastPos, y, 'm'); if(attr) g_eeGeneral.inactivityTimer = checkIncDec(event, g_eeGeneral.inactivityTimer, 0, 250, EE_GENERAL); //0..250minutes break; case ITEM_SETUP_BACKLIGHT_LABEL: lcd_putsLeft(y, STR_BACKLIGHT_LABEL); break; case ITEM_SETUP_BACKLIGHT_MODE: g_eeGeneral.backlightMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_MODE, STR_VBLMODE, g_eeGeneral.backlightMode, e_backlight_mode_off, e_backlight_mode_on, attr, event); break; case ITEM_SETUP_FLASH_BEEP: g_eeGeneral.alarmsFlash = onoffMenuItem(g_eeGeneral.alarmsFlash, RADIO_SETUP_2ND_COLUMN, y, STR_ALARM, attr, event ) ; break; case ITEM_SETUP_BACKLIGHT_DELAY: lcd_putsLeft(y, STR_BLDELAY); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.lightAutoOff*5, attr|LEFT); lcd_putc(lcdLastPos, y, 's'); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.lightAutoOff, 0, 600/5); break; case ITEM_SETUP_BRIGHTNESS: lcd_putsLeft(y, STR_BRIGHTNESS); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 100-g_eeGeneral.backlightBright, attr|LEFT) ; if (attr) { uint8_t b = 100 - g_eeGeneral.backlightBright; CHECK_INCDEC_GENVAR(event, b, 0, 100); g_eeGeneral.backlightBright = 100 - b; } break; #if defined(REVPLUS) case ITEM_SETUP_BACKLIGHT_COLOR: lcd_putsLeft(y, STR_BLCOLOR); displaySlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 20, attr); if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 20, EE_GENERAL | NO_INCDEC_MARKS); break; #endif #if defined(SPLASH) && !defined(FSPLASH) case ITEM_SETUP_DISABLE_SPLASH: { lcd_putsLeft(y, STR_SPLASHSCREEN); if (SPLASH_NEEDED()) { lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, SPLASH_TIMEOUT/100, attr|LEFT); lcd_putc(lcdLastPos, y, 's'); } else { lcd_putsiAtt(RADIO_SETUP_2ND_COLUMN, y, STR_MMMINV, 0, attr); // TODO define } if (attr) g_eeGeneral.splashMode = -checkIncDecGen(event, -g_eeGeneral.splashMode, -3, 4); break; } #endif #if defined(FRSKY) && defined(FRSKY_HUB) && defined(GPS) case ITEM_SETUP_LABEL_GPS: lcd_putsLeft(y, STR_GPS); break; case ITEM_SETUP_TIMEZONE: lcd_putsLeft(y, STR_TIMEZONE); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.timezone, attr|LEFT); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.timezone, -12, 12); break; case ITEM_SETUP_ADJUST_RTC: g_eeGeneral.adjustRTC = onoffMenuItem(g_eeGeneral.adjustRTC, RADIO_SETUP_2ND_COLUMN, y, STR_ADJUST_RTC, attr, event); break; case ITEM_SETUP_GPSFORMAT: g_eeGeneral.gpsFormat = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_GPSCOORD, STR_GPSFORMAT, g_eeGeneral.gpsFormat, 0, 1, attr, event); break; #endif #if defined(PXX) case ITEM_SETUP_COUNTRYCODE: g_eeGeneral.countryCode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_COUNTRYCODE, STR_COUNTRYCODES, g_eeGeneral.countryCode, 0, 2, attr, event); break; #endif case ITEM_SETUP_LANGUAGE: lcd_putsLeft(y, STR_VOICELANG); lcd_putsAtt(RADIO_SETUP_2ND_COLUMN, y, currentLanguagePack->name, attr); if (attr) { currentLanguagePackIdx = checkIncDec(event, currentLanguagePackIdx, 0, DIM(languagePacks)-2, EE_GENERAL); if (checkIncDec_Ret) { currentLanguagePack = languagePacks[currentLanguagePackIdx]; strncpy(g_eeGeneral.ttsLanguage, currentLanguagePack->id, 2); } } break; case ITEM_SETUP_IMPERIAL: g_eeGeneral.imperial = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_UNITSSYSTEM, STR_VUNITSSYSTEM, g_eeGeneral.imperial, 0, 1, attr, event); break; #if defined(FAI_CHOICE) case ITEM_SETUP_FAI: onoffMenuItem(g_eeGeneral.fai, RADIO_SETUP_2ND_COLUMN, y, PSTR("FAI Mode"), attr, event); if (attr && checkIncDec_Ret) { if (g_eeGeneral.fai) POPUP_WARNING(PSTR("FAI\001mode blocked!")); else POPUP_CONFIRMATION(PSTR("FAI mode?")); } break; #endif #if defined(MAVLINK) case ITEM_MAVLINK_BAUD: g_eeGeneral.mavbaud = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_MAVLINK_BAUD_LABEL, STR_MAVLINK_BAUDS, g_eeGeneral.mavbaud, 0, 7, attr, event); break; #endif case ITEM_SETUP_SWITCHES_DELAY: lcd_putsLeft(y, STR_SWITCHES_DELAY); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 10*SWITCHES_DELAY(), attr|LEFT); lcd_putsAtt(lcdLastPos, y, STR_MS, attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, -15, 100-15); break; case ITEM_SETUP_RX_CHANNEL_ORD: lcd_putsLeft(y, STR_RXCHANNELORD); // RAET->AETR for (uint8_t i=1; i<=4; i++) { putsChnLetter(RADIO_SETUP_2ND_COLUMN - FW + i*FW, y, channel_order(i), attr); } if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23); break; case ITEM_SETUP_STICK_MODE_LABELS: lcd_putsLeft(y, NO_INDENT(STR_MODE)); for (uint8_t i=0; i<4; i++) { lcd_img((6+4*i)*FW, y, sticks, i, 0); #if defined(FRSKY_STICKS) if (g_eeGeneral.stickReverse & (1<<i)) { drawFilledRect((6+4*i)*FW, y, 3*FW, FH-1); } #endif } #if defined(FRSKY_STICKS) if (attr) { s_editMode = 0; CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickReverse, 0, 15); lcd_rect(6*FW-1, y-1, 15*FW+2, 9); } #endif break; case ITEM_SETUP_STICK_MODE: lcd_putcAtt(2*FW, y, '1'+g_eeGeneral.stickMode, attr); for (uint8_t i=0; i<4; i++) { putsStickName((6+4*i)*FW, y, pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i), 0); } if (attr && s_editMode>0) { CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickMode, 0, 3); } else if (stickMode != g_eeGeneral.stickMode) { pausePulses(); stickMode = g_eeGeneral.stickMode; checkTHR(); resumePulses(); clearKeyEvents(); } break; } } }
void menuModelTelemetry(uint8_t event) { MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, TELEMETRY_TYPE_ROWS CHANNELS_ROWS RSSI_ROWS SENSORS_ROWS USRDATA_ROWS CASE_VARIO(LABEL(Vario)) CASE_VARIO(0) CASE_VARIO(VARIO_RANGE_ROWS) TELEMETRY_SCREEN_ROWS(0), TELEMETRY_SCREEN_ROWS(1), CASE_CPUARM(TELEMETRY_SCREEN_ROWS(2)) CASE_CPUARM(TELEMETRY_SCREEN_ROWS(3))}); uint8_t sub = m_posVert - 1; switch (event) { case EVT_KEY_BREAK(KEY_DOWN): case EVT_KEY_BREAK(KEY_UP): case EVT_KEY_BREAK(KEY_LEFT): case EVT_KEY_BREAK(KEY_RIGHT): if (s_editMode>0 && sub<=ITEM_TELEMETRY_RSSI_ALARM2) frskySendAlarms(); // update FrSky module when edit mode exited break; } 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; #if defined(CPUARM) for (int j=0; j<=k; j++) { if (mstate_tab[j+1] == HIDDEN_ROW) k++; } #endif uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); uint8_t attr = (sub == k ? blink : 0); #if !defined(CPUARM) uint8_t ch = TELEMETRY_CURRENT_EDIT_CHANNEL(k); FrSkyChannelData & channel = g_model.frsky.channels[ch]; uint8_t dest = TELEM_A1-1+ch; #endif #if defined(CPUARM) if (k>=ITEM_TELEMETRY_SENSOR1 && k<ITEM_TELEMETRY_SENSOR1+MAX_SENSORS) { int index = k-ITEM_TELEMETRY_SENSOR1; lcd_outdezAtt(INDENT_WIDTH, y, index+1, LEFT|attr); lcd_putcAtt(lcdLastPos, y, ':', attr); lcd_putsnAtt(3*FW, y, g_model.telemetrySensors[index].label, TELEM_LABEL_LEN, ZCHAR); if (telemetryItems[index].isFresh()) { lcd_putc(16*FW, y, '*'); } TelemetryItem & telemetryItem = telemetryItems[index]; if (telemetryItem.isAvailable()) { bool isOld = telemetryItem.isOld(); lcdNextPos = TELEM_COL2; if (isOld) lcd_putc(lcdNextPos, y, '['); putsTelemetryChannelValue(lcdNextPos, y, index, getValue(MIXSRC_FIRST_TELEM+3*index), LEFT); if (isOld) lcd_putc(lcdLastPos, y, ']'); } else { lcd_putsAtt(TELEM_COL2, y, "---", 0); // TODO shortcut } if (attr) { s_editMode = 0; s_currIdx = index; if (event == EVT_KEY_LONG(KEY_ENTER)) { killEvents(event); MENU_ADD_ITEM(STR_EDIT); MENU_ADD_ITEM(STR_COPY); MENU_ADD_ITEM(STR_DELETE); menuHandler = onSensorMenu; } else if (event == EVT_KEY_BREAK(KEY_ENTER)) { pushMenu(menuModelSensor); } } } else #endif switch (k) { #if defined(CPUARM) case ITEM_TELEMETRY_PROTOCOL_TYPE: g_model.telemetryProtocol = selectMenuItem(TELEM_COL2, y, STR_TELEMETRY_TYPE, "\017FrSky S.PORT\0 FrSky D\0 FrSky D (cable)", g_model.telemetryProtocol, PROTOCOL_TELEMETRY_FIRST, CASE_PCBSKY9X(PROTOCOL_FRSKY_D_SECONDARY) attr, event); break; #endif #if defined(CPUARM) case ITEM_TELEMETRY_SENSORS_LABEL: lcd_putsLeft(y, STR_TELEMETRY_SENSORS); break; case ITEM_TELEMETRY_NEWSENSOR: lcd_putsAtt(0, y, STR_TELEMETRY_NEWSENSOR, attr); if (attr && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; int res = availableTelemetryIndex(); if (res >= 0) { s_currIdx = res; pushMenu(menuModelSensor); } else { POPUP_WARNING(STR_TELEMETRYFULL); } } break; case ITEM_TELEMETRY_IGNORE_SENSORID: ON_OFF_MENU_ITEM(g_model.ignoreSensorIds, TELEM_COL2, y, STR_IGNOREIDS, attr, event); break; #endif #if !defined(CPUARM) case ITEM_TELEMETRY_A1_LABEL: case ITEM_TELEMETRY_A2_LABEL: lcd_putsLeft(y, STR_ACHANNEL); lcd_outdezAtt(2*FW, y, ch+1, 0); putsTelemetryChannelValue(TELEM_COL2+6*FW, y, dest, frskyData.analog[ch].value, LEFT); break; case ITEM_TELEMETRY_A1_RANGE: case ITEM_TELEMETRY_A2_RANGE: lcd_putsLeft(y, STR_RANGE); putsTelemetryChannelValue(TELEM_COL2, y, dest, 255-channel.offset, (m_posHorz<=0 ? attr : 0)|NO_UNIT|LEFT); lcd_putsiAtt(lcdLastPos, y, STR_VTELEMUNIT, channel.type, m_posHorz!=0 ? attr : 0); if (attr && (s_editMode>0 || p1valdiff)) { if (m_posHorz == 0) { uint16_t ratio = checkIncDec(event, channel.ratio, 0, 256, EE_MODEL); if (checkIncDec_Ret) { if (ratio == 127 && channel.multiplier > 0) { channel.multiplier--; channel.ratio = 255; } else if (ratio == 256) { if (channel.multiplier < FRSKY_MULTIPLIER_MAX) { channel.multiplier++; channel.ratio = 128; } } else { channel.ratio = ratio; } } } else { CHECK_INCDEC_MODELVAR_ZERO(event, channel.type, UNIT_A1A2_MAX); } } break; case ITEM_TELEMETRY_A1_OFFSET: case ITEM_TELEMETRY_A2_OFFSET: lcd_putsLeft(y, STR_OFFSET); putsTelemetryChannelValue(TELEM_COL2, y, dest, 0, LEFT|attr); if (attr) channel.offset = checkIncDec(event, channel.offset, -256, 256, EE_MODEL); break; case ITEM_TELEMETRY_A1_ALARM1: case ITEM_TELEMETRY_A1_ALARM2: case ITEM_TELEMETRY_A2_ALARM1: case ITEM_TELEMETRY_A2_ALARM2: { uint8_t alarm = ((k==ITEM_TELEMETRY_A1_ALARM1 || k==ITEM_TELEMETRY_A2_ALARM1) ? 0 : 1); lcd_putsLeft(y, STR_ALARM); lcd_putsiAtt(TELEM_COL2, y, STR_VALARM, ALARM_LEVEL(ch, alarm), m_posHorz<=0 ? attr : 0); lcd_putsiAtt(TELEM_COL2+4*FW, y, STR_VALARMFN, ALARM_GREATER(ch, alarm), (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0); putsTelemetryChannelValue(TELEM_COL2+6*FW, y, dest, channel.alarms_value[alarm], ((CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0) | LEFT); if (attr && (s_editMode>0 || p1valdiff)) { uint8_t t; switch (m_posHorz) { case 0: t = ALARM_LEVEL(ch, alarm); channel.alarms_level = (channel.alarms_level & ~(3<<(2*alarm))) + (checkIncDecModel(event, t, 0, 3) << (2*alarm)); break; case 1: t = ALARM_GREATER(ch, alarm); if (t != checkIncDecModel(event, t, 0, 1)) { channel.alarms_greater ^= (1 << alarm); frskySendAlarms(); } break; case 2: channel.alarms_value[alarm] = checkIncDec(event, channel.alarms_value[alarm], 0, 255, EE_MODEL); break; } } break; } #endif case ITEM_TELEMETRY_RSSI_LABEL: lcd_putsLeft(y, PSTR("RSSI")); break; case ITEM_TELEMETRY_RSSI_ALARM1: case ITEM_TELEMETRY_RSSI_ALARM2: { uint8_t alarm = k-ITEM_TELEMETRY_RSSI_ALARM1; lcd_putsLeft(y, STR_ALARM); lcd_putsiAtt(TELEM_COL2, y, STR_VALARM, ((2+alarm+g_model.frsky.rssiAlarms[alarm].level)%4), m_posHorz<=0 ? attr : 0); lcd_putc(TELEM_COL2+4*FW, y, '<'); lcd_outdezNAtt(TELEM_COL2+6*FW, y, getRssiAlarmValue(alarm), LEFT|(m_posHorz!=0 ? attr : 0), 3); if (attr && (s_editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR(event, g_model.frsky.rssiAlarms[alarm].level, -3, 2); // circular (saves flash) break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.frsky.rssiAlarms[alarm].value, -30, 30); break; } } break; } #if !defined(CPUARM) #if defined(FRSKY_HUB) || defined(WS_HOW_HIGH) case ITEM_TELEMETRY_USR_LABEL: lcd_putsLeft(y, STR_USRDATA); break; case ITEM_TELEMETRY_USR_PROTO: lcd_putsLeft(y, STR_PROTO); lcd_putsiAtt(TELEM_COL2, y, STR_VTELPROTO, g_model.frsky.usrProto, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.frsky.usrProto, USR_PROTO_LAST); break; case ITEM_TELEMETRY_USR_BLADES: lcd_putsLeft(y, STR_BLADES); lcd_outdezAtt(TELEM_COL2+FWNUM, y, 2+g_model.frsky.blades, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.frsky.blades, MAX_BLADES); break; #endif case ITEM_TELEMETRY_USR_VOLTAGE_SOURCE: lcd_putsLeft(y, STR_VOLTAGE); lcd_putsiAtt(TELEM_COL2, y, STR_AMPSRC, g_model.frsky.voltsSource+1, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.frsky.voltsSource, FRSKY_VOLTS_SOURCE_LAST); break; case ITEM_TELEMETRY_USR_CURRENT_SOURCE: lcd_putsLeft(y, STR_CURRENT); lcd_putsiAtt(TELEM_COL2, y, STR_AMPSRC, g_model.frsky.currentSource, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.frsky.currentSource, FRSKY_CURRENT_SOURCE_LAST); break; #if defined(FAS_OFFSET) || !defined(CPUM64) case ITEM_TELEMETRY_FAS_OFFSET: lcd_putsLeft(y, STR_FAS_OFFSET); lcd_outdezAtt(TELEM_COL2, y, g_model.frsky.fasOffset, attr|LEFT|PREC1); lcd_outdezAtt(TELEM_COL2+6*FW, y, frskyData.hub.current, LEFT|PREC1); lcd_putc(TELEM_COL2+8*FW, y, 'A'); if (attr) g_model.frsky.fasOffset = checkIncDec(event, g_model.frsky.fasOffset, -120, 120, EE_MODEL); break; #endif #endif #if defined(VARIO) case ITEM_TELEMETRY_VARIO_LABEL: lcd_putsLeft(y, STR_VARIO); break; case ITEM_TELEMETRY_VARIO_SOURCE: lcd_putsLeft(y, STR_SOURCE); #if defined(CPUARM) putsMixerSource(TELEM_COL2, y, g_model.frsky.varioSource ? MIXSRC_FIRST_TELEM+3*(g_model.frsky.varioSource-1) : 0, attr); if (attr) { g_model.frsky.varioSource = checkIncDec(event, g_model.frsky.varioSource, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable); } #else lcd_putsiAtt(TELEM_COL2, y, STR_VARIOSRC, g_model.frsky.varioSource, attr); if (attr) CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioSource, 0, VARIO_SOURCE_LAST); #endif break; case ITEM_TELEMETRY_VARIO_RANGE: lcd_putsLeft(y, STR_LIMIT); #if defined(PCBSTD) lcd_outdezAtt(TELEM_COL2, y, 5+g_model.frsky.varioCenterMax, (m_posHorz==0 ? attr : 0)|PREC1|LEFT); lcd_outdezAtt(TELEM_COL2+8*FW, y, 10+g_model.frsky.varioMax, (m_posHorz==1 ? attr : 0)); if (attr && (s_editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioCenterMax, -15, +15); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioMax, -7, 7); break; } } #else lcd_outdezAtt(TELEM_COL2, y, -10+g_model.frsky.varioMin, (m_posHorz<=0 ? attr : 0)|LEFT); lcd_outdezAtt(TELEM_COL2+7*FW-2, y, -5+g_model.frsky.varioCenterMin, ((CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0)|PREC1); lcd_outdezAtt(TELEM_COL2+10*FW, y, 5+g_model.frsky.varioCenterMax, ((CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0)|PREC1); lcd_outdezAtt(TELEM_COL2+13*FW+2, y, 10+g_model.frsky.varioMax, ((CURSOR_ON_LINE() || m_posHorz==3) ? attr : 0)); if (attr && (s_editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioMin, -7, 7); break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioCenterMin, -16, 5+min<int8_t>(10, g_model.frsky.varioCenterMax+5)); break; case 2: CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioCenterMax, -5+max<int8_t>(-10, g_model.frsky.varioCenterMin-5), +15); break; case 3: CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioMax, -7, 7); break; } } #endif break; #endif case ITEM_TELEMETRY_SCREEN_LABEL1: case ITEM_TELEMETRY_SCREEN_LABEL2: #if defined(CPUARM) case ITEM_TELEMETRY_SCREEN_LABEL3: case ITEM_TELEMETRY_SCREEN_LABEL4: { uint8_t screenIndex = TELEMETRY_CURRENT_EDIT_SCREEN(k); putsStrIdx(0*FW, y, STR_SCREEN, screenIndex+1); TelemetryScreenType oldScreenType = TELEMETRY_SCREEN_TYPE(screenIndex); TelemetryScreenType newScreenType = (TelemetryScreenType)selectMenuItem(TELEM_SCRTYPE_COL, y, PSTR(""), STR_VTELEMSCREENTYPE, oldScreenType, 0, TELEMETRY_SCREEN_TYPE_MAX, (m_posHorz==0 ? attr : 0), event); if (newScreenType != oldScreenType) { g_model.frsky.screensType = (g_model.frsky.screensType & (~(0x03 << (2*screenIndex)))) | (newScreenType << (2*screenIndex)); memset(&g_model.frsky.screens[screenIndex], 0, sizeof(g_model.frsky.screens[screenIndex])); } break; } #else { uint8_t screenIndex = (k < ITEM_TELEMETRY_SCREEN_LABEL2 ? 1 : 2); putsStrIdx(0*FW, y, STR_SCREEN, screenIndex); #if defined(GAUGES) bool screenType = g_model.frsky.screensType & screenIndex; if (screenType != (bool)selectMenuItem(TELEM_SCRTYPE_COL, y, PSTR(""), STR_VTELEMSCREENTYPE, screenType, 0, 1, attr, event)) g_model.frsky.screensType ^= screenIndex; #endif break; } #endif case ITEM_TELEMETRY_SCREEN_LINE1: case ITEM_TELEMETRY_SCREEN_LINE2: case ITEM_TELEMETRY_SCREEN_LINE3: case ITEM_TELEMETRY_SCREEN_LINE4: case ITEM_TELEMETRY_SCREEN_LINE5: case ITEM_TELEMETRY_SCREEN_LINE6: case ITEM_TELEMETRY_SCREEN_LINE7: case ITEM_TELEMETRY_SCREEN_LINE8: #if defined(CPUARM) case ITEM_TELEMETRY_SCREEN_LINE9: case ITEM_TELEMETRY_SCREEN_LINE10: case ITEM_TELEMETRY_SCREEN_LINE11: case ITEM_TELEMETRY_SCREEN_LINE12: case ITEM_TELEMETRY_SCREEN_LINE13: case ITEM_TELEMETRY_SCREEN_LINE14: case ITEM_TELEMETRY_SCREEN_LINE15: case ITEM_TELEMETRY_SCREEN_LINE16: #endif { uint8_t screenIndex, lineIndex; if (k < ITEM_TELEMETRY_SCREEN_LABEL2) { screenIndex = 0; lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE1; } #if defined(CPUARM) else if (k >= ITEM_TELEMETRY_SCREEN_LABEL4) { screenIndex = 3; lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE13; } else if (k >= ITEM_TELEMETRY_SCREEN_LABEL3) { screenIndex = 2; lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE9; } #endif else { screenIndex = 1; lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE5; } #if defined(GAUGES) if (IS_BARS_SCREEN(screenIndex)) { FrSkyBarData & bar = g_model.frsky.screens[screenIndex].bars[lineIndex]; source_t barSource = bar.source; #if defined(CPUARM) putsMixerSource(TELEM_COL1, y, barSource, m_posHorz==0 ? attr : 0); if (barSource) { putsChannelValue(TELEM_BARS_COLMIN, y, barSource, bar.barMin, (m_posHorz==1 ? attr : 0) | LEFT); putsChannelValue(TELEM_BARS_COLMAX, y, barSource, bar.barMax, (m_posHorz==2 ? attr : 0) | LEFT); } #else lcd_putsiAtt(TELEM_COL1, y, STR_VTELEMCHNS, barSource, m_posHorz==0 ? attr : 0); if (barSource) { putsTelemetryChannelValue(TELEM_BARS_COLMIN, y, barSource-1, convertBarTelemValue(barSource, bar.barMin), (m_posHorz==1 ? attr : 0) | LEFT); putsTelemetryChannelValue(TELEM_BARS_COLMAX, y, barSource-1, convertBarTelemValue(barSource, 255-bar.barMax), (m_posHorz==2 ? attr : 0) | LEFT); } #endif else if (attr) { MOVE_CURSOR_FROM_HERE(); } if (attr && (s_editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: #if defined(CPUARM) bar.source = CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, barSource, MIXSRC_LAST_TELEM, isSourceAvailable); #else bar.source = CHECK_INCDEC_MODELVAR_ZERO(event, barSource, TELEM_DISPLAY_MAX); #endif if (checkIncDec_Ret) { bar.barMin = 0; #if defined(CPUARM) bar.barMax = 0; #else bar.barMax = 255 - maxBarTelemValue(bar.source); #endif } break; case 1: #if defined(CPUARM) bar.barMin = checkIncDec(event, bar.barMin, -30000, bar.barMax, EE_MODEL|NO_INCDEC_MARKS); #else bar.barMin = checkIncDec(event, bar.barMin, 0, 254-bar.barMax, EE_MODEL|NO_INCDEC_MARKS); #endif break; case 2: #if defined(CPUARM) bar.barMax = checkIncDec(event, bar.barMax, bar.barMin, 30000, EE_MODEL|NO_INCDEC_MARKS); #else bar.barMax = 255 - checkIncDec(event, 255-bar.barMax, bar.barMin+1, maxBarTelemValue(barSource), EE_MODEL|NO_INCDEC_MARKS); #endif break; } } } else #endif { for (uint8_t c=0; c<NUM_LINE_ITEMS; c++) { uint8_t cellAttr = (m_posHorz==c ? attr : 0); source_t & value = g_model.frsky.screens[screenIndex].lines[lineIndex].sources[c]; uint8_t pos[] = {INDENT_WIDTH, TELEM_COL2}; #if defined(CPUARM) putsMixerSource(pos[c], y, value, cellAttr); if (cellAttr && (s_editMode>0 || p1valdiff)) { CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, value, MIXSRC_LAST_TELEM, isSourceAvailable); } #else lcd_putsiAtt(pos[c], y, STR_VTELEMCHNS, value, cellAttr); if (cellAttr && (s_editMode>0 || p1valdiff)) { CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, value, (lineIndex==3 && c==0) ? TELEM_STATUS_MAX : TELEM_DISPLAY_MAX, isTelemetrySourceAvailable); } #endif } if (attr && m_posHorz == NUM_LINE_ITEMS) { REPEAT_LAST_CURSOR_MOVE(); } } 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 }
uint8_t lcd_putc(uint8_t x,uint8_t y,const char c ) { return lcd_putcAtt(x,y,c,0); }
void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext) { int8_t sub = menuVerticalPosition - 1; #if defined(CPUARM) uint8_t eeFlags = (functions == g_model.customFn) ? EE_MODEL : EE_GENERAL; #elif !defined(CPUM64) || defined(AUTOSWITCH) uint8_t eeFlags = EE_MODEL; #endif for (uint8_t i=0; i<LCD_LINES-1; i++) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; uint8_t k = i+menuVerticalOffset; CustomFunctionData *cfn = &functions[k]; uint8_t func = CFN_FUNC(cfn); for (uint8_t j=0; j<5; j++) { uint8_t attr = ((sub==k && menuHorizontalPosition==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t active = (attr && (s_editMode>0 || p1valdiff)); switch (j) { case 0: putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | ((functionsContext->activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_SWITCH(event, CFN_SWITCH(cfn), SWSRC_FIRST, SWSRC_LAST, eeFlags, isSwitchAvailableInCustomFunctions); #if defined(CPUARM) if (func == FUNC_OVERRIDE_CHANNEL && functions != g_model.customFn) { func = CFN_FUNC(cfn) = func+1; } #endif break; case 1: if (CFN_SWITCH(cfn)) { lcd_putsiAtt(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr); if (active) { #if defined(CPUARM) CFN_FUNC(cfn) = checkIncDec(event, CFN_FUNC(cfn), 0, FUNC_MAX-1, eeFlags, isAssignableFunctionAvailable); #else CHECK_INCDEC_MODELVAR_ZERO(event, CFN_FUNC(cfn), FUNC_MAX-1); #endif if (checkIncDec_Ret) CFN_RESET(cfn); } } else { j = 4; // skip other fields if (sub==k && menuHorizontalPosition > 0) { REPEAT_LAST_CURSOR_MOVE(); } } break; case 2: { int8_t maxParam = NUM_CHNOUT-1; #if defined(OVERRIDE_CHANNEL_FUNCTION) if (func == FUNC_OVERRIDE_CHANNEL) { putsChn(lcdNextPos, y, CFN_CH_INDEX(cfn)+1, attr); } else #endif if (func == FUNC_TRAINER) { maxParam = 4; #if defined(CPUARM) putsMixerSource(lcdNextPos, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr); #else putsMixerSource(lcdNextPos, y, MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr); #endif } #if defined(GVARS) else if (func == FUNC_ADJUST_GVAR) { maxParam = MAX_GVARS-1; putsStrIdx(lcdNextPos, y, STR_GV, CFN_GVAR_INDEX(cfn)+1, attr); #if defined(CPUARM) if (active) CFN_GVAR_INDEX(cfn) = checkIncDec(event, CFN_GVAR_INDEX(cfn), 0, maxParam, eeFlags); #else if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_GVAR_INDEX(cfn), maxParam); #endif break; } #endif #if defined(CPUARM) else if (func == FUNC_SET_TIMER) { maxParam = MAX_TIMERS-1; lcd_putsiAtt(lcdNextPos, y, STR_VFSWRESET, CFN_TIMER_INDEX(cfn), attr); if (active) CFN_TIMER_INDEX(cfn) = checkIncDec(event, CFN_TIMER_INDEX(cfn), 0, maxParam, eeFlags); break; } #endif else if (attr) { REPEAT_LAST_CURSOR_MOVE(); } if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_INDEX(cfn), maxParam); break; } case 3: { INCDEC_DECLARE_VARS(eeFlags); int16_t val_displayed = CFN_PARAM(cfn); #if defined(CPUARM) int16_t val_min = 0; int16_t val_max = 255; #else int8_t val_min = 0; uint8_t val_max = 255; #endif if (func == FUNC_RESET) { val_max = FUNC_RESET_PARAM_LAST; lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, CFN_PARAM(cfn), attr); } #if defined(OVERRIDE_CHANNEL_FUNCTION) else if (func == FUNC_OVERRIDE_CHANNEL) { #if !defined(CPUARM) val_displayed = (int8_t)CFN_PARAM(cfn); #endif val_min = -LIMIT_EXT_PERCENT; val_max = +LIMIT_EXT_PERCENT; lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); } #endif #if defined(CPUARM) else if (func >= FUNC_SET_FAILSAFE && func <= FUNC_BIND) { val_max = NUM_MODULES-1; lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "\004Int.Ext.", CFN_PARAM(cfn), attr); } #endif #if defined(CPUARM) else if (func == FUNC_SET_TIMER) { val_max = 539*60+59; putsTimer(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT, attr); } #endif #if defined(AUDIO) else if (func == FUNC_PLAY_SOUND) { val_max = AU_FRSKY_LAST-AU_FRSKY_FIRST-1; lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_FUNCSOUNDS, val_displayed, attr); } #endif #if defined(HAPTIC) else if (func == FUNC_HAPTIC) { val_max = 3; lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); } #endif #if defined(CPUARM) && defined(SDCARD) else if (func == FUNC_PLAY_TRACK || func == FUNC_BACKGND_MUSIC || func == FUNC_PLAY_SCRIPT) { coord_t x = (func == FUNC_PLAY_TRACK ? MODEL_CUSTOM_FUNC_2ND_COLUMN + FW + FW*strlen(TR_PLAY_TRACK) : MODEL_CUSTOM_FUNC_3RD_COLUMN); if (ZEXIST(cfn->play.name)) lcd_putsnAtt(x, y, cfn->play.name, sizeof(cfn->play.name), attr); else lcd_putsiAtt(x, y, STR_VCSWFUNC, 0, attr); if (active && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; char directory[256]; if (func==FUNC_PLAY_SCRIPT) { strcpy(directory, SCRIPTS_FUNCS_PATH); } else { strcpy(directory, SOUNDS_PATH); strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); } if (listSdFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) { popupMenuHandler = onCustomFunctionsFileSelectionMenu; } else { POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD); popupMenuFlags = 0; } } break; } else if (func == FUNC_PLAY_VALUE) { val_max = MIXSRC_LAST_TELEM; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); INCDEC_ENABLE_CHECK(isSourceAvailable); } #endif #if defined(CPUARM) else if (func == FUNC_VOLUME) { val_max = MIXSRC_LAST_CH; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); } #elif defined(VOICE) else if (func == FUNC_PLAY_TRACK) { #if defined(GVARS) if (attr && event==EVT_KEY_LONG(KEY_ENTER)) { killEvents(event); s_editMode = !s_editMode; active = true; val_displayed = (val_displayed > 250 ? 0 : 251); } if (val_displayed > 250) { putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed-250, attr); } else { lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT); } #else lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT); #endif } else if (func == FUNC_PLAY_BOTH) { lcd_putcAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, '|', attr); lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, val_displayed+PROMPT_CUSTOM_BASE, attr); lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+2+3*FWNUM, y, (val_displayed+PROMPT_CUSTOM_BASE+1)%10, attr|LEFT); } else if (func == FUNC_PLAY_VALUE) { val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable); } #endif #if defined(SDCARD) else if (func == FUNC_LOGS) { if (val_displayed) { lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT); lcd_putc(lcdLastPos, y, 's'); } else { lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); } } #endif #if defined(GVARS) else if (func == FUNC_ADJUST_GVAR) { switch (CFN_GVAR_MODE(cfn)) { case FUNC_ADJUST_GVAR_CONSTANT: val_displayed = (int16_t)CFN_PARAM(cfn); val_min = -CFN_GVAR_CST_MAX; val_max = +CFN_GVAR_CST_MAX; lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); break; case FUNC_ADJUST_GVAR_SOURCE: val_max = MIXSRC_LAST_CH; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); break; case FUNC_ADJUST_GVAR_GVAR: val_max = MAX_GVARS-1; putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr); break; default: // FUNC_ADJUST_GVAR_INC val_max = 1; lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\003-=1+=1"), val_displayed, attr); break; } if (attr && event==EVT_KEY_LONG(KEY_ENTER)) { killEvents(event); s_editMode = !s_editMode; active = true; CFN_GVAR_MODE(cfn) += 1; #if defined(CPUARM) CFN_GVAR_MODE(cfn) &= 0x03; #endif val_displayed = 0; } } #endif else if (attr) { REPEAT_LAST_CURSOR_MOVE(); } if (active) { CFN_PARAM(cfn) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max); } break; } case 4: if (HAS_ENABLE_PARAM(func)) { menu_lcd_onoff(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, CFN_ACTIVE(cfn), attr); #if defined(CPUARM) if (active) CFN_ACTIVE(cfn) = checkIncDec(event, CFN_ACTIVE(cfn), 0, 1, eeFlags); #else if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_ACTIVE(cfn), 1); #endif } else if (HAS_REPEAT_PARAM(func)) { if (CFN_PLAY_REPEAT(cfn) == 0) { lcd_putcAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF+3, y, '-', attr); } #if defined(CPUARM) else if (CFN_PLAY_REPEAT(cfn) == CFN_PLAY_REPEAT_NOSTART) { lcd_putsAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, "!-", attr); } #endif else { lcd_outdezAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2+FW, y, CFN_PLAY_REPEAT(cfn)*CFN_PLAY_REPEAT_MUL, attr); } #if defined(CPUARM) if (active) CFN_PLAY_REPEAT(cfn) = checkIncDec(event, CFN_PLAY_REPEAT(cfn)==CFN_PLAY_REPEAT_NOSTART?-1:CFN_PLAY_REPEAT(cfn), -1, 60/CFN_PLAY_REPEAT_MUL, eeFlags); #else if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_PLAY_REPEAT(cfn), 60/CFN_PLAY_REPEAT_MUL); #endif } else if (attr) { REPEAT_LAST_CURSOR_MOVE(); } break; } } } }
void title(char x) { lcd_putsAtt (0, 0, PSTR(" ARDU PILOT Mega ?/8 "), INVERS); lcd_putcAtt(17*FW, 0*FH, x, INVERS); }
void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext) { int sub = menuVerticalPosition; uint8_t eeFlags = (functions == g_model.customFn) ? EE_MODEL : EE_GENERAL; if (menuHorizontalPosition<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { killEvents(event); CustomFunctionData *cfn = &functions[sub]; if (!CFN_EMPTY(cfn)) POPUP_MENU_ADD_ITEM(STR_COPY); if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_FUNCTION) POPUP_MENU_ADD_ITEM(STR_PASTE); if (!CFN_EMPTY(cfn) && CFN_EMPTY(&functions[NUM_CFN-1])) POPUP_MENU_ADD_ITEM(STR_INSERT); if (!CFN_EMPTY(cfn)) POPUP_MENU_ADD_ITEM(STR_CLEAR); for (int i=sub+1; i<NUM_CFN; i++) { if (!CFN_EMPTY(&functions[i])) { POPUP_MENU_ADD_ITEM(STR_DELETE); break; } } popupMenuHandler = onCustomFunctionsMenu; } for (int i=0; i<NUM_BODY_LINES; i++) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; int k = i+menuVerticalOffset; putsStrIdx(0, y, functions == g_model.customFn ? STR_SF : STR_GF, k+1, (sub==k && menuHorizontalPosition<0) ? INVERS : 0); CustomFunctionData *cfn = &functions[k]; uint8_t func = CFN_FUNC(cfn); for (uint8_t j=0; j<5; j++) { uint8_t attr = ((sub==k && menuHorizontalPosition==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t active = (attr && s_editMode>0); switch (j) { case 0: putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | ((functionsContext->activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_SWITCH(event, CFN_SWITCH(cfn), SWSRC_FIRST, SWSRC_LAST, eeFlags, isSwitchAvailableInCustomFunctions); if (func == FUNC_OVERRIDE_CHANNEL && functions != g_model.customFn) { func = CFN_FUNC(cfn) = func+1; } break; case 1: if (CFN_SWITCH(cfn)) { lcd_putsiAtt(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr); if (active) { func = CFN_FUNC(cfn) = checkIncDec(event, CFN_FUNC(cfn), 0, FUNC_MAX-1, eeFlags, isAssignableFunctionAvailable); if (checkIncDec_Ret) CFN_RESET(cfn); } } else { j = 4; // skip other fields if (sub==k && menuHorizontalPosition > 0) { REPEAT_LAST_CURSOR_MOVE(); } } break; case 2: { int8_t maxParam = NUM_CHNOUT-1; #if defined(OVERRIDE_CHANNEL_FUNCTION) if (func == FUNC_OVERRIDE_CHANNEL) { putsChn(lcdNextPos, y, CFN_CH_INDEX(cfn)+1, attr); } else #endif if (func == FUNC_TRAINER) { maxParam = 4; putsMixerSource(lcdNextPos, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr); } #if defined(GVARS) else if (func == FUNC_ADJUST_GVAR) { maxParam = MAX_GVARS-1; putsStrIdx(lcdNextPos, y, STR_GV, CFN_GVAR_INDEX(cfn)+1, attr); if (active) CFN_GVAR_INDEX(cfn) = checkIncDec(event, CFN_GVAR_INDEX(cfn), 0, maxParam, eeFlags); break; } #endif else if (func == FUNC_SET_TIMER) { maxParam = TIMERS-1; putsStrIdx(lcdNextPos, y, STR_TIMER, CFN_TIMER_INDEX(cfn)+1, attr); if (active) CFN_TIMER_INDEX(cfn) = checkIncDec(event, CFN_TIMER_INDEX(cfn), 0, maxParam, eeFlags); break; } else if (attr) { REPEAT_LAST_CURSOR_MOVE(); } if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_INDEX(cfn), maxParam); break; } case 3: { INCDEC_DECLARE_VARS(eeFlags); int16_t val_displayed = CFN_PARAM(cfn); int16_t val_min = 0; int16_t val_max = 255; if (func == FUNC_RESET) { val_max = FUNC_RESET_PARAM_FIRST_TELEM+lastUsedTelemetryIndex(); int param = CFN_PARAM(cfn); if (param < FUNC_RESET_PARAM_FIRST_TELEM) { lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, param, attr); } else { TelemetrySensor * sensor = & g_model.telemetrySensors[param-FUNC_RESET_PARAM_FIRST_TELEM]; lcd_putsnAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, sensor->label, TELEM_LABEL_LEN, attr|ZCHAR); } if (active) INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalResetSpecialFunction : isSourceAvailableInResetSpecialFunction); } #if defined(OVERRIDE_CHANNEL_FUNCTION) else if (func == FUNC_OVERRIDE_CHANNEL) { val_min = -LIMIT_EXT_PERCENT; val_max = +LIMIT_EXT_PERCENT; lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); } #endif else if (func >= FUNC_SET_FAILSAFE && func <= FUNC_BIND) { val_max = NUM_MODULES-1; lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "\004Int.Ext.", CFN_PARAM(cfn), attr); } else if (func == FUNC_SET_TIMER) { val_max = 59*60+59; putsTimer(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT, attr); } else if (func == FUNC_PLAY_SOUND) { val_max = AU_FRSKY_LAST-AU_FRSKY_FIRST-1; lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_FUNCSOUNDS, val_displayed, attr); } #if defined(HAPTIC) else if (func == FUNC_HAPTIC) { val_max = 3; lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); } #endif #if defined(SDCARD) else if (func == FUNC_PLAY_TRACK || func == FUNC_BACKGND_MUSIC || func == FUNC_PLAY_SCRIPT) { coord_t x = MODEL_CUSTOM_FUNC_3RD_COLUMN; if (ZEXIST(cfn->play.name)) lcd_putsnAtt(x, y, cfn->play.name, sizeof(cfn->play.name), attr); else lcd_putsiAtt(x, y, STR_VCSWFUNC, 0, attr); if (active && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; char directory[256]; if (func==FUNC_PLAY_SCRIPT) { strcpy(directory, SCRIPTS_FUNCS_PATH); } else { strcpy(directory, SOUNDS_PATH); strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); } if (listSdFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) { popupMenuHandler = onCustomFunctionsFileSelectionMenu; } else { POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD); } } break; } else if (func == FUNC_PLAY_VALUE) { val_max = MIXSRC_LAST_TELEM; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); if (active) { INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable); } } #endif else if (func == FUNC_VOLUME) { val_max = MIXSRC_LAST_CH; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); if (active) { INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); } } else if (func == FUNC_LOGS) { if (val_displayed) { lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT); lcd_putc(lcdLastPos, y, 's'); } else { lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); } } #if defined(REVPLUS) else if (func == FUNC_BACKLIGHT) { displaySlider(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, CFN_PARAM(cfn), 100, attr); if (active) INCDEC_SET_FLAG(eeFlags | NO_INCDEC_MARKS); val_min = 0; val_max = 100; } #endif #if defined(GVARS) else if (func == FUNC_ADJUST_GVAR) { switch (CFN_GVAR_MODE(cfn)) { case FUNC_ADJUST_GVAR_CONSTANT: val_displayed = (int16_t)CFN_PARAM(cfn); val_min = -CFN_GVAR_CST_MAX; val_max = +CFN_GVAR_CST_MAX; lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); break; case FUNC_ADJUST_GVAR_SOURCE: val_max = MIXSRC_LAST_CH; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); if (active) { INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); } break; case FUNC_ADJUST_GVAR_GVAR: val_max = MAX_GVARS-1; putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr); break; default: // FUNC_ADJUST_GVAR_INC #if 0 // TODO 2.2.X val_min = -100; val_max = +100; if (val_displayed < 0) lcd_putsAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "-=", attr); else lcd_putsAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "+=", attr); lcd_outdezAtt(lcdNextPos, y, abs(val_displayed), attr|LEFT); #endif val_max = 1; lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\003-=1+=1"), val_displayed, attr); break; } } #endif else if (attr) { REPEAT_LAST_CURSOR_MOVE(); } if (active || event==EVT_KEY_LONG(KEY_ENTER)) { CFN_PARAM(cfn) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max); if (func == FUNC_ADJUST_GVAR && attr && event==EVT_KEY_LONG(KEY_ENTER)) { killEvents(event); if (CFN_GVAR_MODE(cfn) != FUNC_ADJUST_GVAR_CONSTANT) POPUP_MENU_ADD_ITEM(STR_CONSTANT); if (CFN_GVAR_MODE(cfn) != FUNC_ADJUST_GVAR_SOURCE) POPUP_MENU_ADD_ITEM(STR_MIXSOURCE); if (CFN_GVAR_MODE(cfn) != FUNC_ADJUST_GVAR_GVAR) POPUP_MENU_ADD_ITEM(STR_GLOBALVAR); if (CFN_GVAR_MODE(cfn) != FUNC_ADJUST_GVAR_INC) POPUP_MENU_ADD_ITEM(STR_INCDEC); popupMenuHandler = onAdjustGvarSourceLongEnterPress; s_editMode = EDIT_MODIFY_FIELD; } } break; } case 4: if (HAS_ENABLE_PARAM(func)) { menu_lcd_onoff(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, CFN_ACTIVE(cfn), attr); if (active) CFN_ACTIVE(cfn) = checkIncDec(event, CFN_ACTIVE(cfn), 0, 1, eeFlags); } else if (HAS_REPEAT_PARAM(func)) { if (CFN_PLAY_REPEAT(cfn) == 0) { lcd_putsAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr); } else if (CFN_PLAY_REPEAT(cfn) == CFN_PLAY_REPEAT_NOSTART) { lcd_putcAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN-1, y, '!', attr); lcd_putsAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr); } else { lcd_outdezAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2+FW, y, CFN_PLAY_REPEAT(cfn)*CFN_PLAY_REPEAT_MUL, attr); lcd_putcAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2+FW, y, 's', attr); } if (active) CFN_PLAY_REPEAT(cfn) = checkIncDec(event, CFN_PLAY_REPEAT(cfn)==CFN_PLAY_REPEAT_NOSTART?-1:CFN_PLAY_REPEAT(cfn), -1, 60/CFN_PLAY_REPEAT_MUL, eeFlags); } else if (attr) { REPEAT_LAST_CURSOR_MOVE(); } break; } } } }
void menuProcNMEA2(uint8_t event) { static uint8_t ignore_break; switch(event) { // Menu navigation case EVT_KEY_BREAK(KEY_LEFT): if (ignore_break==1) { ignore_break=0; break;} chainMenu(menuProcNMEA1); break; case EVT_KEY_BREAK(KEY_RIGHT): if (ignore_break==1) { ignore_break=0; break;} chainMenu(menuProcNMEA3); break; case EVT_KEY_LONG(KEY_UP): NMEA_DisableRXD(); chainMenu(menuProcStatistic); break; case EVT_KEY_LONG(KEY_DOWN): NMEA_DisableRXD(); chainMenu(menuProc0); break; //Beep setting case EVT_KEY_LONG(KEY_LEFT): ignore_break = 1; beep_on=0; audioDefevent(AU_MENUS); // short blip break; case EVT_KEY_LONG(KEY_RIGHT): ignore_break = 1; beep_on=1; audioDefevent(AU_MENUS); // short blip break; //Altitude setting /* Set a home position for altitude. Normally used before starting the model when GPS has got a fix. MENU[short] --> alternating relative and absolute altitudes MENU[long] --> set home altitude to current EXIT[long] --> reset max altitude to 0 Switch ON / OFF short beep with positive lift LEFT[long] --> Positive lift Beep off RIGHT[long] --> Positive lift Beep on */ case EVT_KEY_BREAK(KEY_MENU): if (ignore_break==1) { ignore_break=0; break;} if (!home_alt) // umschalten zwischen absoluter und relativer Höhe home_alt = save_alt; else home_alt=0; if (save_alt==0) // wenn noch keine Home Höhe gesetzt war, wird sie es jetzt, weil sonst // das Umschalten keine Wirkung zeigt save_alt = home_alt = abs_alt; // absolute altitude audioDefevent(AU_MENUS); // short blip for non negative lift break; case EVT_KEY_LONG(KEY_MENU): ignore_break = 1; save_alt = home_alt = abs_alt; // Home altitude auf aktuelle absolute Höhe setzen audioDefevent(AU_MENUS); // short blip for non negative lift break; case EVT_KEY_LONG(KEY_EXIT): // Max Altitude auf 0 zurücksetzen max_alt=0; audioDefevent(AU_MENUS); // short blip for non negative lift break; } title ('2'); lcd_puts_P ( 1*FW, 1*FH, PSTR("Altitude Sat Max")); lcd_puts_P ( 16*FW, 3*FH, PSTR("Home")); lcd_puts_P ( 2*FW, 4*FH, PSTR("Lift") ); lcd_puts_P ( 16*FW, 5*FH, PSTR("Beep") ); if (beep_on==1) lcd_puts_P ( 18*FW, 6*FH, PSTR("ON") ); else lcd_puts_P ( 17*FW, 6*FH, PSTR("OFF") ); lcd_outdezNAtt( 20*FW, 4*FH, home_alt, PREC1, 6); // display home_alt, small characters if (xpack[0] != PACK_GGA) ggareceived = 0; initval (LONG_BUF(0), PACK_GGA, ALT); // -> rbuf[0] initval (LONG_BUF(1), PACK_GGA, GEO); // -> rbuf[1] initval (SHORT_BUF(0), PACK_GGA, MTR); // -> sbuf[0] initval (SHORT_BUF(1), PACK_GGA, FIX); // -> sbuf[1] initval (SHORT_BUF(2), PACK_GGA, SAT); // -> sbuf[2] if (ggareceived) // at least one second has elapsed { ggareceived = 0; /* ALT and GEO have one single digit following the decimal point e.g. ALT=359.7 GEO=47.7 The altitude over mean sea level is to be calculated as: altitude minus geoidal separation */ abs_alt = binary(rbuf[0]) - binary(rbuf[1]); // alt - geo that is absolute altitude if (abs_alt> max_alt) max_alt=abs_alt; // hold max altitude relative to 0 m rel_alt=abs_alt - home_alt; // alt - geo - home altitude relative to home lift_alt = rel_alt - prev_alt; prev_alt = rel_alt; if ((lift_alt >= 0) && (sbuf[1]>0x30) && beep_on) // GGA record must have Fix> 0 audioDefevent(AU_MENUS); // short blip for non negative lift } if (rbuf[0][0]) { lcd_putcAtt ( 13*FW, 1*FH, sbuf[2], 0); // satellites in view if (sbuf[1]>0x30) { // & GGA has FIX > 0 lcd_outdezNAtt( 10*FW, 2*FH, rel_alt, DBLSIZE|PREC1, 7); // altitude if (home_alt >= 0) lcd_outdezNAtt( 20*FW, 2*FH, (max_alt-home_alt), PREC1, 6); // display small characters else lcd_outdezNAtt( 20*FW, 2*FH, max_alt, PREC1, 6); // display small characters lcd_putcAtt ( 11*FW, 3*FH, sbuf[0], 0); // dimension [m] lcd_outdezNAtt( 10*FW, 5*FH, lift_alt, DBLSIZE|PREC1, 6); // lift lcd_putcAtt ( 11*FW, 6*FH, sbuf[0], 0); // dimension [m/S] lcd_puts_P ( 12*FW, 6*FH, PSTR("/S") ); } } else { lcd_putsAtt ( 2*FW, 2*FH, val_unknown, APSIZE); lcd_putsAtt ( 2*FW, 5*FH, val_unknown, APSIZE); } }
void menuModelLimits(uint8_t event) { int sub = menuVerticalPosition; if (sub < NUM_CHNOUT) { #if defined(PPM_CENTER_ADJUSTABLE) || defined(PPM_UNIT_US) lcd_outdezAtt(13*FW, 0, PPM_CH_CENTER(sub)+channelOutputs[sub]/2, 0); lcd_puts(13*FW, 0, STR_US); #else lcd_outdezAtt(13*FW, 0, calcRESXto1000(channelOutputs[sub]), PREC1); #endif } MENU(STR_MENULIMITS, menuTabModel, e_Limits, NUM_CHNOUT+1, { NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, 0 }); if (sub<NUM_CHNOUT && menuHorizontalPosition>=0) { displayColumnHeader(STR_LIMITS_HEADERS, menuHorizontalPosition); } if (warningResult) { warningResult = 0; LimitData *ld = limitAddress(sub); ld->revert = !ld->revert; eeDirty(EE_MODEL); } for (int i=0; i<NUM_BODY_LINES; i++) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; uint8_t k = i+menuVerticalOffset; if (k==NUM_CHNOUT) { // last line available - add the "copy trim menu" line uint8_t attr = (sub==NUM_CHNOUT) ? INVERS : 0; lcd_putsAtt(CENTER_OFS, y, STR_TRIMS2OFFSETS, NO_HIGHLIGHT() ? 0 : attr); if (attr) { s_editMode = 0; if (event==EVT_KEY_LONG(KEY_ENTER)) { START_NO_HIGHLIGHT(); killEvents(event); moveTrimsToOffsets(); // if highlighted and menu pressed - move trims to offsets } } return; } LimitData *ld = limitAddress(k); int16_t v = (ld->revert) ? -LIMIT_OFS(ld) : LIMIT_OFS(ld); char swVal = '-'; // '-', '<', '>' if ((channelOutputs[k] - v) > 50) swVal = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim! if ((channelOutputs[k] - v) < -50) swVal = (ld->revert ? 126 : 127); lcd_putc(LIMITS_DIRECTION_POS, y, swVal); int limit = (g_model.extendedLimits ? LIMIT_EXT_MAX : 1000); putsChn(0, y, k+1, (sub==k && menuHorizontalPosition < 0) ? INVERS : 0); if (sub==k && menuHorizontalPosition < 0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { killEvents(event); POPUP_MENU_ADD_ITEM(STR_RESET); POPUP_MENU_ADD_ITEM(STR_COPY_TRIMS_TO_OFS); POPUP_MENU_ADD_ITEM(STR_COPY_STICKS_TO_OFS); popupMenuHandler = onLimitsMenu; } for (int j=0; j<ITEM_LIMITS_COUNT; j++) { LcdFlags attr = ((sub==k && menuHorizontalPosition==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t active = (attr && s_editMode>0) ; if (active) STICK_SCROLL_DISABLE(); switch(j) { case ITEM_LIMITS_CH_NAME: editName(LIMITS_NAME_POS, y, ld->name, sizeof(ld->name), event, attr); break; case ITEM_LIMITS_OFFSET: if (GV_IS_GV_VALUE(ld->offset, -1000, 1000) || (attr && event == EVT_KEY_LONG(KEY_ENTER))) { ld->offset = GVAR_MENU_ITEM(LIMITS_OFFSET_POS, y, ld->offset, -1000, 1000, attr|PREC1, 0, event); break; } #if defined(PPM_UNIT_US) lcd_outdezAtt(LIMITS_OFFSET_POS, y, ((int32_t)ld->offset*128) / 25, attr|PREC1); #else lcd_outdezAtt(LIMITS_OFFSET_POS, y, ld->offset, attr|PREC1); #endif if (active) { ld->offset = checkIncDec(event, ld->offset, -1000, 1000, EE_MODEL, NULL, stops1000); } else if (attr && event==EVT_KEY_LONG(KEY_MENU)) { copySticksToOffset(k); s_editMode = 0; } break; case ITEM_LIMITS_MIN: if (GV_IS_GV_VALUE(ld->min, -GV_RANGELARGE, GV_RANGELARGE) || (attr && event == EVT_KEY_LONG(KEY_ENTER))) { ld->min = GVAR_MENU_ITEM(LIMITS_MIN_POS, y, ld->min, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, MIN_MAX_ATTR, 0, event); break; } lcd_outdezAtt(LIMITS_MIN_POS, y, MIN_MAX_DISPLAY(ld->min-LIMITS_MIN_MAX_OFFSET), MIN_MAX_ATTR); if (active) ld->min = LIMITS_MIN_MAX_OFFSET + checkIncDec(event, ld->min-LIMITS_MIN_MAX_OFFSET, -limit, 0, EE_MODEL, NULL, stops1000); break; case ITEM_LIMITS_MAX: if (GV_IS_GV_VALUE(ld->max, -GV_RANGELARGE, GV_RANGELARGE) || (attr && event == EVT_KEY_LONG(KEY_ENTER))) { ld->max = GVAR_MENU_ITEM(LIMITS_MAX_POS, y, ld->max, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, MIN_MAX_ATTR, 0, event); break; } lcd_outdezAtt(LIMITS_MAX_POS, y, MIN_MAX_DISPLAY(ld->max+LIMITS_MIN_MAX_OFFSET), MIN_MAX_ATTR); if (active) ld->max = -LIMITS_MIN_MAX_OFFSET + checkIncDec(event, ld->max+LIMITS_MIN_MAX_OFFSET, 0, +limit, EE_MODEL, NULL, stops1000); break; case ITEM_LIMITS_DIRECTION: { uint8_t revert = ld->revert; #if defined(PPM_CENTER_ADJUSTABLE) lcd_putcAtt(LIMITS_REVERT_POS, y, revert ? 127 : 126, attr); #else lcd_putsiAtt(LIMITS_REVERT_POS, y, STR_MMMINV, revert, attr); #endif if (active) { uint8_t revert_new = checkIncDecModel(event, revert, 0, 1); if (checkIncDec_Ret && isThrottleOutput(k)) { POPUP_CONFIRMATION(STR_INVERT_THR); } else { ld->revert = revert_new; } } break; } #if defined(CURVES) case ITEM_LIMITS_CURVE: putsCurve(LIMITS_CURVE_POS, y, ld->curve, attr); if (attr && event==EVT_KEY_LONG(KEY_ENTER) && ld->curve>0) { s_curveChan = (ld->curve<0 ? -ld->curve-1 : ld->curve-1); pushMenu(menuModelCurveOne); } if (active) { CHECK_INCDEC_MODELVAR(event, ld->curve, -MAX_CURVES, +MAX_CURVES); } break; #endif #if defined(PPM_CENTER_ADJUSTABLE) case ITEM_LIMITS_PPM_CENTER: lcd_outdezAtt(LIMITS_PPM_CENTER_POS, y, PPM_CENTER+ld->ppmCenter, attr); if (active) { CHECK_INCDEC_MODELVAR(event, ld->ppmCenter, -PPM_CENTER_MAX, +PPM_CENTER_MAX); } break; #endif #if defined(PPM_LIMITS_SYMETRICAL) case ITEM_LIMITS_SYMETRICAL: lcd_putcAtt(LCD_W-FW-MENUS_SCROLLBAR_WIDTH, y, ld->symetrical ? '=' : '\306', attr); if (active) { CHECK_INCDEC_MODELVAR_ZERO(event, ld->symetrical, 1); } break; #endif } } } }
void title(char x) { lcd_putsAtt (0*FW, 0*FH, PSTR(" GPS NMEA data ?/4 "), INVERS); lcd_putcAtt(16*FW, 0*FH, x, INVERS); }
void menuGeneralSdManager(uint8_t _event) { if (s_warning_result) { s_warning_result = 0; displayPopup(STR_FORMATTING); closeLogs(); audioQueue.stopSD(); if (f_mkfs(0, 1, 0) == FR_OK) { f_chdir("/"); REFRESH_FILES(); } else { POPUP_WARNING(STR_SDCARD_ERROR); } } int lastPos = m_posVert; uint8_t event = (EVT_KEY_MASK(_event) == KEY_ENTER ? 0 : _event); SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, menuTabGeneral, e_Sd, reusableBuffer.sdmanager.count); int index = m_posVert-s_pgOfs; switch(_event) { case EVT_ENTRY: f_chdir(ROOT_PATH); REFRESH_FILES(); lastPos = -1; break; case EVT_KEY_LONG(KEY_MENU): if (!READ_ONLY() && s_editMode == 0) { killEvents(_event); MENU_ADD_ITEM(STR_SD_INFO); MENU_ADD_ITEM(STR_SD_FORMAT); menuHandler = onSdManagerMenu; } break; case EVT_KEY_BREAK(KEY_EXIT): REFRESH_FILES(); break; case EVT_KEY_BREAK(KEY_ENTER): if (s_editMode > 0) { break; } else { if (!reusableBuffer.sdmanager.lines[index][SD_SCREEN_FILE_LENGTH+1]) { f_chdir(reusableBuffer.sdmanager.lines[index]); s_pgOfs = 0; m_posVert = 1; index = 1; REFRESH_FILES(); killEvents(_event); return; } } // no break case EVT_KEY_LONG(KEY_ENTER): if (s_editMode == 0) { killEvents(_event); char *line = reusableBuffer.sdmanager.lines[index]; char *ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1); if (ext) { if (!strcasecmp(ext, SOUNDS_EXT)) { MENU_ADD_ITEM(STR_PLAY_FILE); } else if (!strcasecmp(ext, BITMAPS_EXT)) { if (!READ_ONLY() && (ext-line) <= (int)sizeof(g_model.header.bitmap)) { MENU_ADD_ITEM(STR_ASSIGN_BITMAP); } } else if (!strcasecmp(ext, TEXT_EXT)) { MENU_ADD_ITEM(STR_VIEW_TEXT); } #if defined(LUA) else if (!strcasecmp(ext, SCRIPTS_EXT)) { MENU_ADD_ITEM(STR_EXECUTE_FILE); } #endif else if (!READ_ONLY() && !strcasecmp(ext, FIRMWARE_EXT)) { TCHAR lfn[_MAX_LFN + 1]; getSelectionFullPath(lfn); if (isBootloader(lfn)) { MENU_ADD_ITEM(STR_FLASH_BOOTLOADER); } } else if (!READ_ONLY() && !strcasecmp(ext, SPORT_FIRMWARE_EXT)) { MENU_ADD_ITEM(STR_FLASH_EXTERNAL_DEVICE); MENU_ADD_ITEM(STR_FLASH_INTERNAL_MODULE); } } if (!READ_ONLY()) { if (line[SD_SCREEN_FILE_LENGTH+1]) // it's a file MENU_ADD_ITEM(STR_COPY_FILE); if (clipboard.type == CLIPBOARD_TYPE_SD_FILE) MENU_ADD_ITEM(STR_PASTE); MENU_ADD_ITEM(STR_RENAME_FILE); MENU_ADD_ITEM(STR_DELETE_FILE); } menuHandler = onSdManagerMenu; } break; } if (reusableBuffer.sdmanager.offset != s_pgOfs) { FILINFO fno; DIR dir; char *fn; /* This function is assuming non-Unicode cfg. */ TCHAR lfn[_MAX_LFN + 1]; fno.lfname = lfn; fno.lfsize = sizeof(lfn); if (s_pgOfs == 0) { reusableBuffer.sdmanager.offset = 0; memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); } else if (s_pgOfs == reusableBuffer.sdmanager.count-7) { reusableBuffer.sdmanager.offset = s_pgOfs; memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); } else if (s_pgOfs > reusableBuffer.sdmanager.offset) { memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], 6*sizeof(reusableBuffer.sdmanager.lines[0])); memset(reusableBuffer.sdmanager.lines[6], 0xff, SD_SCREEN_FILE_LENGTH); reusableBuffer.sdmanager.lines[6][SD_SCREEN_FILE_LENGTH+1] = 1; } else { memmove(reusableBuffer.sdmanager.lines[1], reusableBuffer.sdmanager.lines[0], 6*sizeof(reusableBuffer.sdmanager.lines[0])); memset(reusableBuffer.sdmanager.lines[0], 0, sizeof(reusableBuffer.sdmanager.lines[0])); } reusableBuffer.sdmanager.count = 0; FRESULT res = f_opendir(&dir, "."); /* Open the directory */ if (res == FR_OK) { for (;;) { res = f_readdir(&dir, &fno); /* Read a directory item */ if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */ if (fno.fname[0] == '.' && fno.fname[1] == '\0') continue; /* Ignore dot entry */ #if _USE_LFN fn = *fno.lfname ? fno.lfname : fno.fname; #else fn = fno.fname; #endif if (strlen(fn) > SD_SCREEN_FILE_LENGTH) continue; reusableBuffer.sdmanager.count++; bool isfile = !(fno.fattrib & AM_DIR); if (s_pgOfs == 0) { for (int i=0; i<NUM_BODY_LINES; i++) { char *line = reusableBuffer.sdmanager.lines[i]; if (line[0] == '\0' || isFilenameLower(isfile, fn, line)) { if (i < 6) memmove(reusableBuffer.sdmanager.lines[i+1], line, sizeof(reusableBuffer.sdmanager.lines[i]) * (6-i)); memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[i])); strcpy(line, fn); line[SD_SCREEN_FILE_LENGTH+1] = isfile; break; } } } else if (reusableBuffer.sdmanager.offset == s_pgOfs) { for (int8_t i=6; i>=0; i--) { char *line = reusableBuffer.sdmanager.lines[i]; if (line[0] == '\0' || isFilenameGreater(isfile, fn, line)) { if (i > 0) memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], sizeof(reusableBuffer.sdmanager.lines[0]) * i); memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[i])); strcpy(line, fn); line[SD_SCREEN_FILE_LENGTH+1] = isfile; break; } } } else if (s_pgOfs > reusableBuffer.sdmanager.offset) { if (isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[5]) && isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[6])) { memset(reusableBuffer.sdmanager.lines[6], 0, sizeof(reusableBuffer.sdmanager.lines[0])); strcpy(reusableBuffer.sdmanager.lines[6], fn); reusableBuffer.sdmanager.lines[6][SD_SCREEN_FILE_LENGTH+1] = isfile; } } else { if (isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[1]) && isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[0])) { memset(reusableBuffer.sdmanager.lines[0], 0, sizeof(reusableBuffer.sdmanager.lines[0])); strcpy(reusableBuffer.sdmanager.lines[0], fn); reusableBuffer.sdmanager.lines[0][SD_SCREEN_FILE_LENGTH+1] = isfile; } } } } } reusableBuffer.sdmanager.offset = s_pgOfs; for (int i=0; i<NUM_BODY_LINES; i++) { coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH; lcdNextPos = 0; LcdFlags attr = (index == i ? BSS|INVERS : BSS); if (reusableBuffer.sdmanager.lines[i][0]) { if (!reusableBuffer.sdmanager.lines[i][SD_SCREEN_FILE_LENGTH+1]) { lcd_putcAtt(0, y, '[', s_editMode == EDIT_MODIFY_STRING ? 0 : attr); } if (s_editMode == EDIT_MODIFY_STRING && attr) { editName(lcdNextPos, y, reusableBuffer.sdmanager.lines[i], SD_SCREEN_FILE_LENGTH-4, _event, attr, 0); if (s_editMode == 0) { unsigned int len = effectiveLen(reusableBuffer.sdmanager.lines[i], SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION); char * ext = getFileExtension(reusableBuffer.sdmanager.originalName, sizeof(reusableBuffer.sdmanager.originalName)); if (ext) { strAppend(&reusableBuffer.sdmanager.lines[i][len], ext); } f_rename(reusableBuffer.sdmanager.originalName, reusableBuffer.sdmanager.lines[i]); REFRESH_FILES(); } } else { lcd_putsAtt(lcdNextPos, y, reusableBuffer.sdmanager.lines[i], attr); } if (!reusableBuffer.sdmanager.lines[i][SD_SCREEN_FILE_LENGTH+1]) { lcd_putcAtt(lcdNextPos, y, ']', s_editMode == EDIT_MODIFY_STRING ? 0 : attr); } } } char *ext = getFileExtension(reusableBuffer.sdmanager.lines[index], SD_SCREEN_FILE_LENGTH+1); if (ext && !strcasecmp(ext, BITMAPS_EXT)) { if (lastPos != m_posVert) { if (bmpLoad(modelBitmap, reusableBuffer.sdmanager.lines[index], MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)) { memcpy(modelBitmap, logo_taranis, MODEL_BITMAP_SIZE); } } lcd_bmp(22*FW+2, 2*FH+FH/2, modelBitmap); } }