void menuGeneralDiagAna(uint8_t event) { #if defined(TX_CAPACITY_MEASUREMENT) #define ANAS_ITEMS_COUNT 4 #else #define ANAS_ITEMS_COUNT 2 #endif SIMPLE_MENU(STR_MENUANA, menuTabGeneral, e_Ana, ANAS_ITEMS_COUNT); STICK_SCROLL_DISABLE(); for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) { #if (NUM_STICKS+NUM_POTS) > 9 coord_t y = MENU_HEADER_HEIGHT + 1 + (i/3)*FH; const uint8_t x_coord[] = {0, 70, 154}; uint8_t x = x_coord[i%3]; lcdDrawNumberNAtt(x, y, i+1, LEADING0|LEFT, 2); lcdDrawChar(x+2*FW-2, y, ':'); #else coord_t y = MENU_HEADER_HEIGHT + 1 + (i/2)*FH; uint8_t x = i&1 ? 64+5 : 0; lcdDrawStringWithIndex(x, y, PSTR("A"), i+1); lcdDrawChar(lcdNextPos, y, ':'); #endif lcd_outhex4(x+3*FW-1, y, anaIn(i)); lcd_outdez8(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256); } // Display raw BandGap result (debug) lcdDrawText(64+5, MENU_HEADER_HEIGHT+1+3*FH, STR_BG); lcdDrawNumberAttUnit(64+5+6*FW-3, 1+4*FH, BandGap, 0); #if defined(PCBGRUVIN9X) lcdDrawTextLeft(6*FH-2, STR_BATT_CALIB); // Gruvin wants 2 decimal places and instant update of volts calib field when button pressed static uint16_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; // running average, sourced directly (to avoid unending debate :P) uint32_t batCalV = ((uint32_t)adcBatt*1390 + (10*(int32_t)adcBatt*g_eeGeneral.txVoltageCalibration)/8) / BandGap; lcdDrawNumberNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(menuVerticalPosition==1 ? INVERS : 0)); #else lcdDrawTextLeft(6*FH-2, STR_BATT_CALIB); lcdPutsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (menuVerticalPosition==1 ? INVERS : 0)); #endif if (menuVerticalPosition==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.txVoltageCalibration, -127, 127); #if defined(TX_CAPACITY_MEASUREMENT) lcdDrawTextLeft(6*FH+1, STR_CURRENT_CALIB); lcdPutsValueWithUnit(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, getCurrent(), UNIT_MILLIAMPS, (menuVerticalPosition==2 ? INVERS : 0)) ; if (menuVerticalPosition==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.txCurrentCalibration, -49, 49); #endif }
void menuGeneralDiagAna(uint8_t event) { SIMPLE_MENU(STR_MENUANA, menuTabGeneral, e_Ana, 1); STICK_SCROLL_DISABLE(); for (int i=0; i<NUM_STICKS+NUM_POTS; i++) { #if (NUM_STICKS+NUM_POTS) > 9 coord_t y = MENU_HEADER_HEIGHT + 1 + (i/3)*FH; const uint8_t x_coord[] = {0, 70, 154}; uint8_t x = x_coord[i%3]; lcd_outdezNAtt(x, y, i+1, LEADING0|LEFT, 2); lcd_putc(x+2*FW-2, y, ':'); #else coord_t y = MENU_HEADER_HEIGHT + 1 + (i/2)*FH; uint8_t x = i&1 ? 64+5 : 0; putsStrIdx(x, y, PSTR("A"), i+1); lcd_putc(lcdNextPos, y, ':'); #endif lcd_outhex4(x+3*FW-1, y, anaIn(i)); lcd_outdez8(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256); } lcd_putsLeft(MENU_HEADER_HEIGHT+1+5*FH, STR_BATT_CALIB); static int32_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; uint32_t batCalV = (adcBatt + (adcBatt*g_eeGeneral.txVoltageCalibration)/128) * BATT_SCALE; batCalV >>= 11; batCalV += 2; // because of the diode putsVolts(LEN_CALIB_FIELDS*FW+4*FW, MENU_HEADER_HEIGHT+1+5*FH, batCalV, s_editMode > 0 ? BLINK|INVERS : INVERS); if (s_editMode > 0) CHECK_INCDEC_GENVAR(event, g_eeGeneral.txVoltageCalibration, -127, 127); }
void menuGeneralHardware(uint8_t event) { MENU(STR_HARDWARE, menuTabDiag, e_Hardware, ITEM_SETUP_HW_MAX+1, {0, 0, (uint8_t)-1, 0, 0, 0, 0, IF_BLUETOOTH(0)}); uint8_t sub = m_posVert - 1; for (uint8_t i=0; i<LCD_LINES-1; i++) { uint8_t y = 1 + 1*FH + i*FH; uint8_t k = i+s_pgOfs; uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); uint8_t attr = (sub == k ? blink : 0); switch(k) { case ITEM_SETUP_HW_OPTREX_DISPLAY: g_eeGeneral.optrexDisplay = selectMenuItem(GENERAL_HW_PARAM_OFS, y, STR_LCD, STR_VLCD, g_eeGeneral.optrexDisplay, 0, 1, attr, event); break; case ITEM_SETUP_HW_STICKS_GAINS_LABELS: lcd_putsLeft(y, PSTR("Sticks")); break; case ITEM_SETUP_HW_STICK_LV_GAIN: case ITEM_SETUP_HW_STICK_LH_GAIN: case ITEM_SETUP_HW_STICK_RV_GAIN: case ITEM_SETUP_HW_STICK_RH_GAIN: { lcd_putsiAtt(INDENT_WIDTH, y, PSTR("\002LVLHRVRH"), k-ITEM_SETUP_HW_STICK_LV_GAIN, 0); lcd_puts(INDENT_WIDTH+3*FW, y, PSTR("Gain")); uint8_t mask = (1<<(k-ITEM_SETUP_HW_STICK_LV_GAIN)); uint8_t val = (g_eeGeneral.sticksGain & mask ? 1 : 0); lcd_putcAtt(GENERAL_HW_PARAM_OFS, y, val ? '2' : '1', attr); if (attr) { CHECK_INCDEC_GENVAR(event, val, 0, 1); if (checkIncDec_Ret) { g_eeGeneral.sticksGain ^= mask; setSticksGain(g_eeGeneral.sticksGain); } } break; } case ITEM_SETUP_HW_ROTARY_ENCODER: g_eeGeneral.rotarySteps = selectMenuItem(GENERAL_HW_PARAM_OFS, y, PSTR("Rotary Encoder"), PSTR("\0062steps4steps"), g_eeGeneral.rotarySteps, 0, 1, attr, event); break; #if defined(BLUETOOTH) case ITEM_SETUP_HW_BT_BAUDRATE: g_eeGeneral.btBaudrate = selectMenuItem(GENERAL_HW_PARAM_OFS, y, STR_BAUDRATE, PSTR("\005115k 9600 19200"), g_eeGeneral.btBaudrate, 0, 2, attr, event); if (attr && checkIncDec_Ret) { btInit(); } break; #endif } } }
void menuGeneralTrainer(uint8_t event) { uint8_t y; bool slave = SLAVE_MODE(); MENU(STR_MENUTRAINER, menuTabGeneral, e_Trainer, (slave ? 1 : 7), {0, 2, 2, 2, 2, 0/*, 0*/}); if (slave) { lcd_puts(7*FW, 4*FH, STR_SLAVE); } else { uint8_t attr; uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); lcd_puts(3*FW, MENU_HEADER_HEIGHT+1, STR_MODESRC); y = MENU_HEADER_HEIGHT + 1 + FH; for (uint8_t i=1; i<=NUM_STICKS; i++) { uint8_t chan = channel_order(i); volatile TrainerMix *td = &g_eeGeneral.trainer.mix[chan-1]; putsMixerSource(0, y, MIXSRC_Rud-1+chan, (menuVerticalPosition==i && CURSOR_ON_LINE()) ? INVERS : 0); for (uint8_t j=0; j<3; j++) { attr = ((menuVerticalPosition==i && menuHorizontalPosition==j) ? blink : 0); switch(j) { case 0: lcd_putsiAtt(4*FW, y, STR_TRNMODE, td->mode, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->mode, 0, 2); break; case 1: lcd_outdezAtt(11*FW, y, td->studWeight, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->studWeight, -125, 125); break; case 2: lcd_putsiAtt(12*FW, y, STR_TRNCHN, td->srcChn, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->srcChn, 0, 3); break; } } y += FH; } attr = (menuVerticalPosition==5) ? blink : 0; lcd_putsLeft(MENU_HEADER_HEIGHT+1+5*FH, STR_MULTIPLIER); lcd_outdezAtt(LEN_MULTIPLIER*FW+3*FW, MENU_HEADER_HEIGHT+1+5*FH, g_eeGeneral.PPM_Multiplier+10, attr|PREC1); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40); attr = (menuVerticalPosition==6) ? INVERS : 0; if (attr) s_editMode = 0; lcd_putsAtt(0*FW, MENU_HEADER_HEIGHT+1+6*FH, STR_CAL, attr); for (uint8_t i=0; i<4; i++) { uint8_t x = (i*TRAINER_CALIB_POS+16)*FW/2; #if defined (PPM_UNIT_PERCENT_PREC1) lcd_outdezAtt(x, MENU_HEADER_HEIGHT+1+6*FH, (ppmInput[i]-g_eeGeneral.trainer.calib[i])*2, PREC1); #else lcd_outdezAtt(x, MENU_HEADER_HEIGHT+1+6*FH, (ppmInput[i]-g_eeGeneral.trainer.calib[i])/5, 0); #endif } if (attr) { if (event==EVT_KEY_LONG(KEY_ENTER)){ memcpy(g_eeGeneral.trainer.calib, ppmInput, sizeof(g_eeGeneral.trainer.calib)); eeDirty(EE_GENERAL); AUDIO_WARNING1(); } } } }
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 menuGeneralTrainer(uint8_t event) { uint8_t y; bool slave = SLAVE_MODE(); MENU(STR_MENUTRAINER, menuTabDiag, e_Trainer, slave ? 1 : 7, {0, 2, 2, 2, 2, 0/*, 0*/}); if (slave) { // i am the slave lcd_puts(7*FW, 3*FH, STR_SLAVE); } else { uint8_t attr; uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); lcd_puts(3*FW, 1 + 1*FH, STR_MODESRC); y = 1 + 2*FH; for (uint8_t i=1; i<=NUM_STICKS; i++) { uint8_t chan = channel_order(i); volatile TrainerMix *td = &g_eeGeneral.trainer.mix[chan-1]; putsMixerSource(0, y, chan, (m_posVert==i && m_posHorz<0) ? INVERS : 0); for (uint8_t j=0; j<3; j++) { attr = ((m_posVert==i && m_posHorz==j) ? blink : 0); switch(j) { case 0: lcd_putsiAtt(4*FW, y, STR_TRNMODE, td->mode, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->mode, 0, 2); break; case 1: lcd_outdezAtt(11*FW, y, td->studWeight, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->studWeight, -100, 100); break; case 2: lcd_putsiAtt(12*FW, y, STR_TRNCHN, td->srcChn, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->srcChn, 0, 3); break; } } y += FH; } attr = (m_posVert==5) ? blink : 0; lcd_putsLeft(6*FH+1, STR_MULTIPLIER); lcd_outdezAtt(LEN_MULTIPLIER*FW+3*FW, 6*FH+1, g_eeGeneral.PPM_Multiplier+10, attr|PREC1); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40); attr = (m_posVert==6) ? blink : 0; lcd_putsAtt(0*FW, 1+7*FH, STR_CAL, attr); for (uint8_t i=0; i<4; i++) { uint8_t x = (i*TRAINER_CALIB_POS+16)*FW/2; #if defined (PPM_UNIT_PERCENT_PREC1) lcd_outdezAtt(x, 1+7*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])*2, PREC1); #else lcd_outdezAtt(x, 1+7*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])/5, 0); #endif } if (attr) { if (event==EVT_KEY_FIRST(KEY_MENU)){ s_editMode = -1; memcpy(g_eeGeneral.trainer.calib, g_ppmIns, sizeof(g_eeGeneral.trainer.calib)); eeDirty(EE_GENERAL); AUDIO_KEYPAD_UP(); } } } }
void menuGeneralSetup(uint8_t event) { #if defined(RTCLOCK) struct gtm t; gettime(&t); if ((m_posVert==ITEM_SETUP_DATE+1 || m_posVert==ITEM_SETUP_TIME+1) && (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 (s_warning_result) { s_warning_result = 0; g_eeGeneral.fai = true; eeDirty(EE_GENERAL); } #endif MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) IF_BATTGRAPH(1) LABEL(SOUND), IF_AUDIO(0) IF_BUZZER(0) IF_VOICE(0) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) 0, IF_AUDIO(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) 0, LABEL(ALARMS), 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, IF_CPUARM(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, IF_SPLASH(0) IF_GPS(0) IF_GPS(0) IF_PXX(0) IF_CPUARM(0) IF_CPUARM(0) IF_FAI_CHOICE(0) 0, LABEL(TX_MODE), CASE_PCBTARANIS(0) 1/*to force edit mode*/}); uint8_t sub = m_posVert - 1; for (uint8_t i=0; i<LCD_LINES-1; i++) { uint8_t y = 1 + 1*FH + i*FH; uint8_t k = i+s_pgOfs; uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); uint8_t attr = (sub == k ? blink : 0); switch(k) { #if defined(RTCLOCK) case ITEM_SETUP_DATE: lcd_putsLeft(y, STR_DATE); lcd_putc(RADIO_SETUP_DATE_COLUMN, y, '-'); lcd_putc(RADIO_SETUP_DATE_COLUMN+3*FW-1, y, '-'); for (uint8_t j=0; j<3; j++) { uint8_t rowattr = (m_posHorz==j ? attr : 0); switch (j) { case 0: lcd_outdezAtt(RADIO_SETUP_DATE_COLUMN, y, t.tm_year+1900, rowattr); if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_year = checkIncDec(event, t.tm_year, 112, 200, 0); break; case 1: lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+3*FW-1, y, t.tm_mon+1, rowattr|LEADING0, 2); if (rowattr && (s_editMode>0 || p1valdiff)) 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-2, y, t.tm_mday, rowattr|LEADING0, 2); if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_mday = checkIncDec(event, t.tm_mday, 1, dlim, 0); break; } } } #if defined(PCBTARANIS) if (attr && m_posHorz < 0) lcd_filled_rect(RADIO_SETUP_2ND_COLUMN, y, LCD_W-RADIO_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); #endif 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-4, y, ':'); for (uint8_t j=0; j<3; j++) { uint8_t rowattr = (m_posHorz==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 || p1valdiff)) 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 || p1valdiff)) 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 || p1valdiff)) t.tm_sec = checkIncDec(event, t.tm_sec, 0, 59, 0); break; } } #if defined(PCBTARANIS) if (attr && m_posHorz < 0) lcd_filled_rect(RADIO_SETUP_2ND_COLUMN, y, LCD_W-RADIO_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); #endif if (attr && checkIncDec_Ret) g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated break; #endif #if defined(BATTGRAPH) || defined(PCBTARANIS) case ITEM_SETUP_BATT_RANGE: lcd_putsLeft(y, STR_BATTERY_RANGE); lcd_putc(g_eeGeneral.vBatMin >= 10 ? RADIO_SETUP_2ND_COLUMN+2*FW+FWNUM-1 : RADIO_SETUP_2ND_COLUMN+2*FW+FWNUM-FW/2, y, '-'); putsVolts(RADIO_SETUP_2ND_COLUMN, y, 90+g_eeGeneral.vBatMin, (m_posHorz==0 ? attr : 0)|LEFT|NO_UNIT); putsVolts(RADIO_SETUP_2ND_COLUMN+4*FW-2, y, 120+g_eeGeneral.vBatMax, (m_posHorz>0 ? attr : 0)|LEFT|NO_UNIT); #if defined(PCBTARANIS) if (attr && m_posHorz < 0) lcd_filled_rect(RADIO_SETUP_2ND_COLUMN, y, LCD_W-RADIO_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); #endif if (attr && s_editMode>0) { if (m_posHorz==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; #endif case ITEM_SETUP_SOUND_LABEL: lcd_putsLeft(y, STR_SOUND_LABEL); break; #if defined(AUDIO) 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; #if defined(BUZZER) case ITEM_SETUP_BUZZER_MODE: g_eeGeneral.buzzerMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_BUZZER, STR_VBEEPMODE, g_eeGeneral.buzzerMode, -2, 1, attr, event); #if defined(FRSKY) if (attr && checkIncDec_Ret) frskySendAlarms(); #endif break; #endif #else case ITEM_SETUP_BUZZER_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; #endif #if defined(VOICE) 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; #if !defined(CPUARM) setVolume(b); #endif } } break; } #endif #if defined(CPUARM) 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_VARIO_VOLUME: SLIDER_5POS(y, g_eeGeneral.varioVolume, STR_VARIO_VOLUME, event, attr); break; case ITEM_SETUP_BACKGROUND_VOLUME: SLIDER_5POS(y, g_eeGeneral.backgroundVolume, STR_BG_VOLUME, event, attr); break; #endif case ITEM_SETUP_BEEP_LENGTH: SLIDER_5POS(y, g_eeGeneral.beepLength, STR_LENGTH, event, attr); break; #if defined(AUDIO) case ITEM_SETUP_SPEAKER_PITCH: lcd_putsLeft( y, STR_SPKRPITCH); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.speakerPitch, attr|LEFT); if (attr) { CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerPitch, 0, 20); } 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: lcd_putsLeft( y, STR_HAPTICSTRENGTH); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.hapticStrength, attr|LEFT); if (attr) { CHECK_INCDEC_GENVAR(event, g_eeGeneral.hapticStrength, 0, 5); } 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) { #if defined(PCBTARANIS) CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, 0, 45); #else CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, 10, 45); #endif 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; } #if defined(PCBSKY9X) case ITEM_SETUP_CAPACITY_WARNING: lcd_putsLeft(y, STR_CAPAWARNING); putsTelemetryValue(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.mAhWarn*50, UNIT_MAH, attr|LEFT) ; if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.mAhWarn, 0, 100); break; #endif #if defined(PCBSKY9X) case ITEM_SETUP_TEMPERATURE_WARNING: lcd_putsLeft(y, STR_TEMPWARNING); putsTelemetryValue(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.temperatureWarn, UNIT_DEGREES, attr|LEFT) ; if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureWarn, 0, 120); // 0 means no alarm break; #endif 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; #if ROTARY_ENCODERS > 0 case ITEM_SETUP_RE_NAVIGATION: g_eeGeneral.reNavigation = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_RENAVIG, STR_VRENAVIG, g_eeGeneral.reNavigation, 0, NUM_ROTARY_ENCODERS, attr, event); if (attr && checkIncDec_Ret) { g_rotenc[NAVIGATION_RE_IDX()] = 0; } break; #endif 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; #if defined(CPUARM) 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; #endif #if defined(PWM_BACKLIGHT) case ITEM_SETUP_BACKLIGHT_BRIGHTNESS_OFF: lcd_putsLeft(y, STR_BLOFFBRIGHTNESS); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.blOffBright, attr|LEFT); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.blOffBright, 0, 15); break; case ITEM_SETUP_BACKLIGHT_BRIGHTNESS_ON: lcd_putsLeft(y, STR_BLONBRIGHTNESS); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 15-g_eeGeneral.blOnBright, attr|LEFT); if (attr) g_eeGeneral.blOnBright = 15 - checkIncDecGen(event, 15-g_eeGeneral.blOnBright, 0, 15); break; #endif #if defined(SPLASH) && !defined(FSPLASH) case ITEM_SETUP_DISABLE_SPLASH: { uint8_t b = 1-g_eeGeneral.splashMode; g_eeGeneral.splashMode = 1 - onoffMenuItem(b, RADIO_SETUP_2ND_COLUMN, y, STR_SPLASHSCREEN, attr, event); break; } #endif #if defined(FRSKY) && defined(FRSKY_HUB) && defined(GPS) 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_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 #if defined(CPUARM) 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; #endif #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 y, // Y STR_MAVLINK_BAUD_LABEL, // pm_char *label STR_MAVLINK_BAUDS, // pm_char *values // PSTR("4800""9600""14400""19200""38400""57600""76800""115200"), g_eeGeneral.mavbaud, // value 0, // min 7, // max attr, // attr event); // event break; #endif 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); break; case ITEM_SETUP_STICK_MODE: lcd_putcAtt(2*FW, y, '1'+g_eeGeneral.stickMode, attr); for (uint8_t i=0; i<4; i++) putsMixerSource((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(); } #if defined(ROTARY_ENCODER_NAVIGATION) MOVE_CURSOR_FROM_HERE(); #endif break; } } }
void menuGeneralDiagAna(uint8_t event) { #if defined(PCBSKY9X) && !defined(REVA) #define ANAS_ITEMS_COUNT 4 #elif defined(PCBSKY9X) #define ANAS_ITEMS_COUNT 3 #else #define ANAS_ITEMS_COUNT 2 #endif SIMPLE_MENU(STR_MENUANA, menuTabDiag, e_Ana, ANAS_ITEMS_COUNT); STICK_SCROLL_DISABLE(); for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) { uint8_t y = 1+FH+(i/2)*FH; uint8_t x = i&1 ? 64+5 : 0; putsStrIdx(x, y, PSTR("A"), i+1); lcd_putc(x+2*FWNUM, y, ':'); lcd_outhex4(x+3*FW-1, y, anaIn(i)); lcd_outdez8(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i+1)-1]*25/256); } #if !defined(CPUARM) // Display raw BandGap result (debug) lcd_puts(64+5, 1+4*FH, STR_BG); lcd_outdezAtt(64+5+6*FW-3, 1+4*FH, BandGap, 0); #endif #if defined(PCBTARANIS) lcd_putsLeft(6*FH+1, STR_BATT_CALIB); static int32_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(8)) / 8; uint32_t batCalV = (adcBatt + (adcBatt*g_eeGeneral.vBatCalib)/128) * BATT_SCALE; batCalV >>= 11; batCalV += 2; // because of the diode putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, batCalV, (m_posVert==1 ? INVERS : 0)); #elif defined(PCBSKY9X) lcd_putsLeft(5*FH+1, STR_BATT_CALIB); static int32_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(7)) / 8; uint32_t batCalV = (adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128) * 4191; batCalV /= 55296; putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 5*FH+1, batCalV, (m_posVert==1 ? INVERS : 0)); #elif defined(PCBGRUVIN9X) lcd_putsLeft(6*FH-2, STR_BATT_CALIB); // Gruvin wants 2 decimal places and instant update of volts calib field when button pressed static uint16_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(7)) / 8; // running average, sourced directly (to avoid unending debate :P) uint32_t batCalV = ((uint32_t)adcBatt*1390 + (10*(int32_t)adcBatt*g_eeGeneral.vBatCalib)/8) / BandGap; lcd_outdezNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(m_posVert==1 ? INVERS : 0)); #else lcd_putsLeft(6*FH-2, STR_BATT_CALIB); putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (m_posVert==1 ? INVERS : 0)); #endif if (m_posVert==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatCalib, -127, 127); #if defined(PCBSKY9X) && !defined(REVA) lcd_putsLeft(6*FH+1, STR_CURRENT_CALIB); putsTelemetryValue(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, getCurrent(), UNIT_MILLIAMPS, (m_posVert==2 ? INVERS : 0)) ; if (m_posVert==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.currentCalib, -49, 49); #endif #if defined(PCBSKY9X) lcd_putsLeft(7*FH+1, STR_TEMP_CALIB); putsTelemetryValue(LEN_CALIB_FIELDS*FW+4*FW, 7*FH+1, getTemperature(), UNIT_DEGREES, (m_posVert==3 ? INVERS : 0)) ; if (m_posVert==3) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureCalib, -100, 100); #endif }