diff --git a/radio/src/gui/128x64/gui.h b/radio/src/gui/128x64/gui.h index 0434feb9b..fab157c07 100644 --- a/radio/src/gui/128x64/gui.h +++ b/radio/src/gui/128x64/gui.h @@ -279,20 +279,19 @@ void title(const pm_char * s); SIMPLE_MENU_NOTITLE(tab, menu, lines_count); \ TITLE(title) - #define SIMPLE_SUBMENU(title, lines_count) \ SIMPLE_SUBMENU_NOTITLE(lines_count); \ TITLE(title) #if defined(CPUARM) -typedef int select_menu_value_t; +typedef int choice_t; #else -typedef int8_t select_menu_value_t; +typedef int8_t choice_t; #endif -select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event); -uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char *label, LcdFlags attr, uint8_t event); -int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t event); +choice_t editChoice(coord_t x, coord_t y, const pm_char * label, const pm_char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, uint8_t event); +uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char * label, LcdFlags attr, uint8_t event); +int8_t editSwitch(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t event); #define ON_OFF_MENU_ITEM(value, x, y, label, attr, event) value = editCheckBox(value, x, y, label, attr, event) diff --git a/radio/src/gui/128x64/lcd.cpp b/radio/src/gui/128x64/lcd.cpp index ffcc03fb7..304f4b1c6 100644 --- a/radio/src/gui/128x64/lcd.cpp +++ b/radio/src/gui/128x64/lcd.cpp @@ -1016,17 +1016,6 @@ void putsRotaryEncoderMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, Lcd #endif #if defined(CPUARM) -const pm_uint8_t bchunit_ar[] PROGMEM = { - UNIT_DIST, // Alt - UNIT_RAW, // Rpm - UNIT_PERCENT, // Fuel - UNIT_TEMPERATURE, // T1 - UNIT_TEMPERATURE, // T2 - UNIT_KTS, // Speed - UNIT_DIST, // Dist - UNIT_DIST, // GPS Alt -}; - void drawValueWithUnit(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlags att) { // convertUnit(val, unit); diff --git a/radio/src/gui/128x64/model_display.cpp b/radio/src/gui/128x64/model_display.cpp index aaa8a6e85..406e06602 100644 --- a/radio/src/gui/128x64/model_display.cpp +++ b/radio/src/gui/128x64/model_display.cpp @@ -109,7 +109,7 @@ void menuModelDisplay(uint8_t event) uint8_t screenIndex = TELEMETRY_CURRENT_SCREEN(k); drawStringWithIndex(0*FW, y, STR_SCREEN, screenIndex+1); TelemetryScreenType oldScreenType = TELEMETRY_SCREEN_TYPE(screenIndex); - TelemetryScreenType newScreenType = (TelemetryScreenType)selectMenuItem(DISPLAY_COL2, y, PSTR(""), STR_VTELEMSCREENTYPE, oldScreenType, 0, TELEMETRY_SCREEN_TYPE_MAX, (menuHorizontalPosition==0 ? attr : 0), event); + TelemetryScreenType newScreenType = (TelemetryScreenType)editChoice(DISPLAY_COL2, y, PSTR(""), STR_VTELEMSCREENTYPE, oldScreenType, 0, TELEMETRY_SCREEN_TYPE_MAX, (menuHorizontalPosition==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])); diff --git a/radio/src/gui/128x64/model_flightmodes.cpp b/radio/src/gui/128x64/model_flightmodes.cpp index a4bc457ab..95dc29d6d 100644 --- a/radio/src/gui/128x64/model_flightmodes.cpp +++ b/radio/src/gui/128x64/model_flightmodes.cpp @@ -125,7 +125,7 @@ void menuModelPhaseOne(uint8_t event) break; case ITEM_MODEL_PHASE_SWITCH: - fm->swtch = switchMenuItem(MIXES_2ND_COLUMN, y, fm->swtch, attr, event); + fm->swtch = editSwitch(MIXES_2ND_COLUMN, y, fm->swtch, attr, event); break; case ITEM_MODEL_PHASE_TRIMS: diff --git a/radio/src/gui/128x64/model_inputs.cpp b/radio/src/gui/128x64/model_inputs.cpp index 473bbc89e..2e348f0ef 100644 --- a/radio/src/gui/128x64/model_inputs.cpp +++ b/radio/src/gui/128x64/model_inputs.cpp @@ -252,11 +252,11 @@ void menuModelExpoOne(uint8_t event) #endif case EXPO_FIELD_SWITCH: - ed->swtch = switchMenuItem(EXPO_ONE_2ND_COLUMN, y, ed->swtch, RIGHT | attr, event); + ed->swtch = editSwitch(EXPO_ONE_2ND_COLUMN, y, ed->swtch, RIGHT | attr, event); break; case EXPO_FIELD_SIDE: - ed->mode = 4 - selectMenuItem(EXPO_ONE_2ND_COLUMN, y, STR_SIDE, STR_VSIDE, 4-ed->mode, 1, 3, RIGHT | attr, event); + ed->mode = 4 - editChoice(EXPO_ONE_2ND_COLUMN, y, STR_SIDE, STR_VSIDE, 4-ed->mode, 1, 3, RIGHT | attr, event); break; case EXPO_FIELD_TRIM: diff --git a/radio/src/gui/128x64/model_inputs_mixes.cpp b/radio/src/gui/128x64/model_inputs_mixes.cpp index 34f7c612f..b61a3054b 100644 --- a/radio/src/gui/128x64/model_inputs_mixes.cpp +++ b/radio/src/gui/128x64/model_inputs_mixes.cpp @@ -292,11 +292,11 @@ void menuModelExpoOne(uint8_t event) #endif case EXPO_FIELD_SWITCH: - ed->swtch = switchMenuItem(EXPO_ONE_2ND_COLUMN-3*FW, y, ed->swtch, attr, event); + ed->swtch = editSwitch(EXPO_ONE_2ND_COLUMN-3*FW, y, ed->swtch, attr, event); break; case EXPO_FIELD_SIDE: - ed->mode = 4 - selectMenuItem(EXPO_ONE_2ND_COLUMN-3*FW, y, STR_SIDE, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); + ed->mode = 4 - editChoice(EXPO_ONE_2ND_COLUMN-3*FW, y, STR_SIDE, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); break; } y += FH; @@ -513,7 +513,7 @@ void menuModelMixOne(uint8_t event) break; #endif case MIX_FIELD_SWITCH: - md2->swtch = switchMenuItem(COLUMN_X+MIXES_2ND_COLUMN, y, md2->swtch, attr, event); + md2->swtch = editSwitch(COLUMN_X+MIXES_2ND_COLUMN, y, md2->swtch, attr, event); break; case MIX_FIELD_WARNING: drawFieldLabel(COLUMN_X+MIXES_2ND_COLUMN, y, STR_MIXWARNING); @@ -524,7 +524,7 @@ void menuModelMixOne(uint8_t event) if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, md2->mixWarn, 3); break; case MIX_FIELD_MLTPX: - md2->mltpx = selectMenuItem(COLUMN_X+MIXES_2ND_COLUMN, y, STR_MULTPX, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); + md2->mltpx = editChoice(COLUMN_X+MIXES_2ND_COLUMN, y, STR_MULTPX, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); break; case MIX_FIELD_DELAY_UP: md2->delayUp = EDIT_DELAY(COLUMN_X, y, event, attr, STR_DELAYUP, md2->delayUp); diff --git a/radio/src/gui/128x64/model_mixes.cpp b/radio/src/gui/128x64/model_mixes.cpp index c159385f3..6d6bb8169 100644 --- a/radio/src/gui/128x64/model_mixes.cpp +++ b/radio/src/gui/128x64/model_mixes.cpp @@ -269,7 +269,7 @@ void menuModelMixOne(uint8_t event) #endif case MIX_FIELD_SWITCH: - md2->swtch = switchMenuItem(MIXES_2ND_COLUMN, y, md2->swtch, attr, event); + md2->swtch = editSwitch(MIXES_2ND_COLUMN, y, md2->swtch, attr, event); break; case MIX_FIELD_WARNING: @@ -282,7 +282,7 @@ void menuModelMixOne(uint8_t event) break; case MIX_FIELD_MLTPX: - md2->mltpx = selectMenuItem(MIXES_2ND_COLUMN, y, STR_MULTPX, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); + md2->mltpx = editChoice(MIXES_2ND_COLUMN, y, STR_MULTPX, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); break; case MIX_FIELD_DELAY_UP: diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index e5542b364..964a5a4a1 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -329,7 +329,7 @@ void menuModelSetup(uint8_t event) case ITEM_MODEL_TIMER3_COUNTDOWN_BEEP: { TimerData * timer = &g_model.timers[k>=ITEM_MODEL_TIMER3 ? 2 : (k>=ITEM_MODEL_TIMER2 ? 1 : 0)]; - timer->countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, STR_VBEEPCOUNTDOWN, timer->countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT-1, attr, event); + timer->countdownBeep = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, STR_VBEEPCOUNTDOWN, timer->countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT-1, attr, event); break; } @@ -338,7 +338,7 @@ void menuModelSetup(uint8_t event) case ITEM_MODEL_TIMER3_PERSISTENT: { TimerData * timer = &g_model.timers[k>=ITEM_MODEL_TIMER3 ? 2 : (k>=ITEM_MODEL_TIMER2 ? 1 : 0)]; - timer->persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, timer->persistent, 0, 2, attr, event); + timer->persistent = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, timer->persistent, 0, 2, attr, event); break; } #else @@ -390,7 +390,7 @@ void menuModelSetup(uint8_t event) case ITEM_MODEL_TIMER2_PERSISTENT: { TimerData &timer = g_model.timers[k==ITEM_MODEL_TIMER2_PERSISTENT]; - timer.persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, timer.persistent, 0, 2, attr, event); + timer.persistent = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, timer.persistent, 0, 2, attr, event); break; } #endif @@ -422,12 +422,12 @@ void menuModelSetup(uint8_t event) #if defined(CPUARM) case ITEM_MODEL_DISPLAY_TRIMS: - g_model.displayTrims = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_DISPLAY_TRIMS, STR_VDISPLAYTRIMS, g_model.displayTrims, 0, 2, attr, event); + g_model.displayTrims = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_DISPLAY_TRIMS, STR_VDISPLAYTRIMS, g_model.displayTrims, 0, 2, attr, event); break; #endif case ITEM_MODEL_TRIM_INC: - g_model.trimInc = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_TRIMINC, STR_VTRIMINC, g_model.trimInc, -2, 2, attr, event); + g_model.trimInc = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_TRIMINC, STR_VTRIMINC, g_model.trimInc, -2, 2, attr, event); break; case ITEM_MODEL_THROTTLE_REVERSED: @@ -864,7 +864,7 @@ void menuModelSetup(uint8_t event) { uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); ModuleData & moduleData = g_model.moduleData[moduleIdx]; - moduleData.ppm.outputType = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_OUTPUT_TYPE, STR_VOUTPUT_TYPE, moduleData.ppm.outputType, 0, 1, attr, event); + moduleData.ppm.outputType = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_OUTPUT_TYPE, STR_VOUTPUT_TYPE, moduleData.ppm.outputType, 0, 1, attr, event); break; } #endif @@ -918,7 +918,7 @@ void menuModelSetup(uint8_t event) lcdDrawTextAlignedLeft(y, STR_MULTI_VIDFREQ); break; case MM_RF_PROTO_DSM2: - g_model.moduleData[moduleIdx].multi.optionValue = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_MULTI_DSMFRAME, STR_OPTIONS_DSM, g_model.moduleData[moduleIdx].multi.optionValue, 0, 12, attr, event); + g_model.moduleData[moduleIdx].multi.optionValue = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_MULTI_DSMFRAME, STR_OPTIONS_DSM, g_model.moduleData[moduleIdx].multi.optionValue, 0, 12, attr, event); break; default: lcdDrawTextAlignedLeft(y, STR_MULTI_OPTION); diff --git a/radio/src/gui/128x64/model_telemetry.cpp b/radio/src/gui/128x64/model_telemetry.cpp index 82c03b924..206d48756 100644 --- a/radio/src/gui/128x64/model_telemetry.cpp +++ b/radio/src/gui/128x64/model_telemetry.cpp @@ -241,7 +241,7 @@ void menuModelSensor(uint8_t event) break; case SENSOR_FIELD_TYPE: - sensor->type = selectMenuItem(SENSOR_2ND_COLUMN, y, NO_INDENT(STR_TYPE), STR_VSENSORTYPES, sensor->type, 0, 1, attr, event); + sensor->type = editChoice(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) { @@ -270,7 +270,7 @@ void menuModelSensor(uint8_t event) } } else { - sensor->formula = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_FORMULA, STR_VFORMULAS, sensor->formula, 0, TELEM_FORMULA_LAST, attr, event); + sensor->formula = editChoice(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) { @@ -291,7 +291,7 @@ void menuModelSensor(uint8_t event) case SENSOR_FIELD_UNIT: lcdDrawTextAlignedLeft(y, "Unit"); - // TODO flash saving with selectMenuItem where I copied those 2 lines? + // TODO flash saving with editChoice where I copied those 2 lines? lcdDrawTextAtIndex(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr); if (attr) { CHECK_INCDEC_MODELVAR_ZERO(event, sensor->unit, UNIT_MAX); @@ -302,7 +302,7 @@ void menuModelSensor(uint8_t event) break; case SENSOR_FIELD_PRECISION: - sensor->prec = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_PRECISION, STR_VPREC, sensor->prec, 0, 2, attr, event); + sensor->prec = editChoice(SENSOR_2ND_COLUMN, y, STR_PRECISION, STR_VPREC, sensor->prec, 0, 2, attr, event); if (attr && checkIncDec_Ret) { telemetryItems[s_currIdx].clear(); } @@ -357,7 +357,7 @@ void menuModelSensor(uint8_t event) 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); + sensor->cell.index = editChoice(SENSOR_2ND_COLUMN, y, STR_CELLINDEX, STR_VCELLINDEX, sensor->cell.index, 0, 8, attr, event); break; } else if (sensor->formula == TELEM_FORMULA_DIST) { @@ -806,7 +806,7 @@ void menuModelTelemetryFrsky(uint8_t event) drawStringWithIndex(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)) + if (screenType != (bool)editChoice(TELEM_SCRTYPE_COL, y, PSTR(""), STR_VTELEMSCREENTYPE, screenType, 0, 1, attr, event)) g_model.frsky.screensType ^= screenIndex; #endif break; diff --git a/radio/src/gui/128x64/radio_hardware.cpp b/radio/src/gui/128x64/radio_hardware.cpp index a466aa515..d270551f9 100644 --- a/radio/src/gui/128x64/radio_hardware.cpp +++ b/radio/src/gui/128x64/radio_hardware.cpp @@ -49,7 +49,7 @@ void menuRadioHardware(uint8_t event) switch(k) { case ITEM_RADIO_HARDWARE_OPTREX_DISPLAY: - g_eeGeneral.optrexDisplay = selectMenuItem(GENERAL_HW_PARAM_OFS, y, STR_LCD, STR_VLCD, g_eeGeneral.optrexDisplay, 0, 1, attr, event); + g_eeGeneral.optrexDisplay = editChoice(GENERAL_HW_PARAM_OFS, y, STR_LCD, STR_VLCD, g_eeGeneral.optrexDisplay, 0, 1, attr, event); break; case ITEM_RADIO_HARDWARE_STICKS_GAINS_LABELS: @@ -78,13 +78,13 @@ void menuRadioHardware(uint8_t event) #if defined(ROTARY_ENCODERS) case ITEM_RADIO_HARDWARE_ROTARY_ENCODER: - g_eeGeneral.rotarySteps = selectMenuItem(GENERAL_HW_PARAM_OFS, y, PSTR("Rotary Encoder"), PSTR("\0062steps4steps"), g_eeGeneral.rotarySteps, 0, 1, attr, event); + g_eeGeneral.rotarySteps = editChoice(GENERAL_HW_PARAM_OFS, y, PSTR("Rotary Encoder"), PSTR("\0062steps4steps"), g_eeGeneral.rotarySteps, 0, 1, attr, event); break; #endif #if defined(BLUETOOTH) case ITEM_RADIO_HARDWARE_BT_BAUDRATE: - g_eeGeneral.btBaudrate = selectMenuItem(GENERAL_HW_PARAM_OFS, y, STR_BAUDRATE, PSTR("\005115k 9600 19200"), g_eeGeneral.btBaudrate, 0, 2, attr, event); + g_eeGeneral.btBaudrate = editChoice(GENERAL_HW_PARAM_OFS, y, STR_BAUDRATE, PSTR("\005115k 9600 19200"), g_eeGeneral.btBaudrate, 0, 2, attr, event); if (attr && checkIncDec_Ret) { btInit(); } diff --git a/radio/src/gui/128x64/radio_setup.cpp b/radio/src/gui/128x64/radio_setup.cpp index 9e96741dd..f82cfef7c 100644 --- a/radio/src/gui/128x64/radio_setup.cpp +++ b/radio/src/gui/128x64/radio_setup.cpp @@ -34,16 +34,16 @@ const pm_uchar sticks[] PROGMEM = { #define SLIDER_5POS(y, value, label, event, attr) { \ int8_t tmp = value; \ drawSlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \ - value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ + value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ } #elif defined(GRAPHICS) #define SLIDER_5POS(y, value, label, event, attr) { \ int8_t tmp = value; \ display5posSlider(RADIO_SETUP_2ND_COLUMN, y, tmp, attr); \ - value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ + value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ } #else - #define SLIDER_5POS(y, value, label, event, attr) value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, STR_VBEEPLEN, value, -2, +2, attr, event) + #define SLIDER_5POS(y, value, label, event, attr) value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, STR_VBEEPLEN, value, -2, +2, attr, event) #endif #if defined(SPLASH) && !defined(FSPLASH) @@ -234,7 +234,7 @@ void menuRadioSetup(uint8_t event) #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); + g_eeGeneral.beepMode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_SPEAKER, STR_VBEEPMODE, g_eeGeneral.beepMode, -2, 1, attr, event); #if defined(TELEMETRY_FRSKY) if (attr && checkIncDec_Ret) frskySendAlarms(); #endif @@ -242,7 +242,7 @@ void menuRadioSetup(uint8_t event) #if defined(BUZZER) // AUDIO + 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); + g_eeGeneral.buzzerMode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_BUZZER, STR_VBEEPMODE, g_eeGeneral.buzzerMode, -2, 1, attr, event); #if defined(TELEMETRY_FRSKY) if (attr && checkIncDec_Ret) frskySendAlarms(); #endif @@ -250,7 +250,7 @@ void menuRadioSetup(uint8_t event) #endif #elif defined(BUZZER) // BUZZER only 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); + g_eeGeneral.beepMode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_SPEAKER, STR_VBEEPMODE, g_eeGeneral.beepMode, -2, 1, attr, event); #if defined(TELEMETRY_FRSKY) if (attr && checkIncDec_Ret) frskySendAlarms(); #endif @@ -341,7 +341,7 @@ void menuRadioSetup(uint8_t event) 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); + g_eeGeneral.hapticMode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_MODE, STR_VBEEPMODE, g_eeGeneral.hapticMode, -2, 1, attr, event); break; case ITEM_SETUP_HAPTIC_LENGTH: @@ -411,7 +411,7 @@ void menuRadioSetup(uint8_t event) #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); + g_eeGeneral.reNavigation = editChoice(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; } @@ -423,7 +423,7 @@ void menuRadioSetup(uint8_t event) 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); + g_eeGeneral.backlightMode = editChoice(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: @@ -480,13 +480,13 @@ void menuRadioSetup(uint8_t 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); + g_eeGeneral.gpsFormat = editChoice(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); + g_eeGeneral.countryCode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_COUNTRYCODE, STR_COUNTRYCODES, g_eeGeneral.countryCode, 0, 2, attr, event); break; #endif @@ -504,7 +504,7 @@ void menuRadioSetup(uint8_t event) 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); + g_eeGeneral.imperial = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_UNITSSYSTEM, STR_VUNITSSYSTEM, g_eeGeneral.imperial, 0, 1, attr, event); break; #endif @@ -522,7 +522,7 @@ void menuRadioSetup(uint8_t event) #if defined(TELEMETRY_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); + g_eeGeneral.mavbaud = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_MAVLINK_BAUD_LABEL, STR_MAVLINK_BAUDS, g_eeGeneral.mavbaud, 0, 7, attr, event); break; #endif diff --git a/radio/src/gui/128x64/widgets.cpp b/radio/src/gui/128x64/widgets.cpp index 0e850fda5..754234164 100644 --- a/radio/src/gui/128x64/widgets.cpp +++ b/radio/src/gui/128x64/widgets.cpp @@ -72,7 +72,7 @@ void title(const pm_char * s) lcdDrawText(0, 0, s, INVERS); } -select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event) +choice_t editChoice(coord_t x, coord_t y, const pm_char *label, const pm_char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, uint8_t event) { drawFieldLabel(x, y, label); if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr); @@ -84,13 +84,13 @@ uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char *label, { #if defined(GRAPHICS) drawCheckBox(x, y, value, attr); - return selectMenuItem(x, y, label, NULL, value, 0, 1, attr, event); + return editChoice(x, y, label, NULL, value, 0, 1, attr, event); #else - return selectMenuItem(x, y, label, STR_OFFON, value, 0, 1, attr, event); + return editChoice(x, y, label, STR_OFFON, value, 0, 1, attr, event); #endif } -int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t event) +int8_t editSwitch(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t event) { drawFieldLabel(x, y, STR_SWITCH); drawSwitch(x, y, value, attr); diff --git a/radio/src/gui/212x64/gui.h b/radio/src/gui/212x64/gui.h index 680918eb8..f18e768dd 100644 --- a/radio/src/gui/212x64/gui.h +++ b/radio/src/gui/212x64/gui.h @@ -236,11 +236,11 @@ void title(const pm_char * s); #define SIMPLE_SUBMENU(title, lines_count) \ check_submenu_simple(title, event, lines_count) -typedef int select_menu_value_t; +typedef int choice_t; -select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event); +choice_t editChoice(coord_t x, coord_t y, const pm_char *label, const pm_char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, uint8_t event); uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char *label, LcdFlags attr, uint8_t event); -swsrc_t switchMenuItem(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, uint8_t event); +swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, uint8_t event); #define ON_OFF_MENU_ITEM(value, x, y, label, attr, event) value = editCheckBox(value, x, y, label, attr, event) diff --git a/radio/src/gui/212x64/lcd.cpp b/radio/src/gui/212x64/lcd.cpp index 5d7356670..20a07ef88 100644 --- a/radio/src/gui/212x64/lcd.cpp +++ b/radio/src/gui/212x64/lcd.cpp @@ -803,17 +803,6 @@ void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att } } -const pm_uint8_t bchunit_ar[] PROGMEM = { - UNIT_DIST, // Alt - UNIT_RAW, // Rpm - UNIT_PERCENT, // Fuel - UNIT_TEMPERATURE, // T1 - UNIT_TEMPERATURE, // T2 - UNIT_KTS, // Speed - UNIT_DIST, // Dist - UNIT_DIST, // GPS Alt -}; - void drawValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att) { // convertUnit(val, unit); diff --git a/radio/src/gui/212x64/menus.h b/radio/src/gui/212x64/menus.h index 0c3a1b306..b7949cb25 100644 --- a/radio/src/gui/212x64/menus.h +++ b/radio/src/gui/212x64/menus.h @@ -107,6 +107,7 @@ enum MenuModelIndexes { void menuModelSelect(uint8_t event); void menuModelSetup(uint8_t event); +void menuModelFailsafe(uint8_t event); void menuModelHeli(uint8_t event); void menuModelFlightModesAll(uint8_t event); void menuModelExposAll(uint8_t event); diff --git a/radio/src/gui/212x64/model_display.cpp b/radio/src/gui/212x64/model_display.cpp index 23cc9fe7e..47ce6162a 100644 --- a/radio/src/gui/212x64/model_display.cpp +++ b/radio/src/gui/212x64/model_display.cpp @@ -125,7 +125,7 @@ void menuModelDisplay(uint8_t event) uint8_t screenIndex = TELEMETRY_CURRENT_SCREEN(k); drawStringWithIndex(0*FW, y, STR_SCREEN, screenIndex+1); TelemetryScreenType oldScreenType = TELEMETRY_SCREEN_TYPE(screenIndex); - TelemetryScreenType newScreenType = (TelemetryScreenType)selectMenuItem(DISPLAY_COL2, y, PSTR(""), STR_VTELEMSCREENTYPE, oldScreenType, 0, TELEMETRY_SCREEN_TYPE_MAX, (menuHorizontalPosition==0 ? attr : 0), event); + TelemetryScreenType newScreenType = (TelemetryScreenType)editChoice(DISPLAY_COL2, y, PSTR(""), STR_VTELEMSCREENTYPE, oldScreenType, 0, TELEMETRY_SCREEN_TYPE_MAX, (menuHorizontalPosition==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])); diff --git a/radio/src/gui/212x64/model_gvars.cpp b/radio/src/gui/212x64/model_gvars.cpp index cffa18eae..ab0c61491 100644 --- a/radio/src/gui/212x64/model_gvars.cpp +++ b/radio/src/gui/212x64/model_gvars.cpp @@ -83,11 +83,11 @@ void menuModelGVarOne(uint8_t event) break; case GVAR_FIELD_UNIT: - gvar->unit = selectMenuItem(GVAR_2ND_COLUMN, y, STR_UNIT, "\001-%", gvar->unit, 0, 1, attr, event); + gvar->unit = editChoice(GVAR_2ND_COLUMN, y, STR_UNIT, "\001-%", gvar->unit, 0, 1, attr, event); break; case GVAR_FIELD_PREC: - gvar->prec = selectMenuItem(GVAR_2ND_COLUMN, y, STR_PRECISION, STR_VPREC, gvar->prec, 0, 1, attr, event); + gvar->prec = editChoice(GVAR_2ND_COLUMN, y, STR_PRECISION, STR_VPREC, gvar->prec, 0, 1, attr, event); break; case GVAR_FIELD_MIN: diff --git a/radio/src/gui/212x64/model_inputs.cpp b/radio/src/gui/212x64/model_inputs.cpp index 697a23c18..48311782f 100644 --- a/radio/src/gui/212x64/model_inputs.cpp +++ b/radio/src/gui/212x64/model_inputs.cpp @@ -249,11 +249,11 @@ void menuModelExpoOne(uint8_t event) #endif case EXPO_FIELD_SWITCH: - ed->swtch = switchMenuItem(EXPO_ONE_2ND_COLUMN, y, ed->swtch, attr, event); + ed->swtch = editSwitch(EXPO_ONE_2ND_COLUMN, y, ed->swtch, attr, event); break; case EXPO_FIELD_SIDE: - ed->mode = 4 - selectMenuItem(EXPO_ONE_2ND_COLUMN, y, STR_SIDE, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); + ed->mode = 4 - editChoice(EXPO_ONE_2ND_COLUMN, y, STR_SIDE, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); break; case EXPO_FIELD_TRIM: diff --git a/radio/src/gui/212x64/model_mixes.cpp b/radio/src/gui/212x64/model_mixes.cpp index e5a2b64d7..3295e8e66 100644 --- a/radio/src/gui/212x64/model_mixes.cpp +++ b/radio/src/gui/212x64/model_mixes.cpp @@ -276,7 +276,7 @@ void menuModelMixOne(uint8_t event) #endif case MIX_FIELD_SWITCH: - md2->swtch = switchMenuItem(MENU_COLUMN2_X+MIXES_2ND_COLUMN, y, md2->swtch, attr, event); + md2->swtch = editSwitch(MENU_COLUMN2_X+MIXES_2ND_COLUMN, y, md2->swtch, attr, event); break; case MIX_FIELD_WARNING: @@ -289,7 +289,7 @@ void menuModelMixOne(uint8_t event) break; case MIX_FIELD_MLTPX: - md2->mltpx = selectMenuItem(MENU_COLUMN2_X+MIXES_2ND_COLUMN, y, STR_MULTPX, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); + md2->mltpx = editChoice(MENU_COLUMN2_X+MIXES_2ND_COLUMN, y, STR_MULTPX, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); break; case MIX_FIELD_DELAY_UP: diff --git a/radio/src/gui/212x64/model_setup.cpp b/radio/src/gui/212x64/model_setup.cpp index 4322ae8c3..69b482612 100644 --- a/radio/src/gui/212x64/model_setup.cpp +++ b/radio/src/gui/212x64/model_setup.cpp @@ -21,7 +21,6 @@ #include "opentx.h" uint8_t g_moduleIdx; -void menuModelFailsafe(uint8_t event); enum MenuModelSetupItems { ITEM_MODEL_NAME, @@ -355,7 +354,7 @@ void menuModelSetup(uint8_t 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); + g_model.timers[0].persistent = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, g_model.timers[0].persistent, 0, 2, attr, event); break; #if TIMERS > 1 @@ -376,7 +375,7 @@ void menuModelSetup(uint8_t 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); + g_model.timers[1].persistent = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, g_model.timers[1].persistent, 0, 2, attr, event); break; #endif @@ -398,7 +397,7 @@ void menuModelSetup(uint8_t 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); + g_model.timers[2].persistent = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_PERSISTENT, STR_VPERSISTENT, g_model.timers[2].persistent, 0, 2, attr, event); break; #endif @@ -433,11 +432,11 @@ void menuModelSetup(uint8_t event) 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); + g_model.displayTrims = editChoice(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); + g_model.trimInc = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_TRIMINC, STR_VTRIMINC, g_model.trimInc, -2, 2, attr, event); break; case ITEM_MODEL_THROTTLE_LABEL: @@ -990,7 +989,7 @@ void menuModelSetup(uint8_t event) lcdDrawTextAlignedLeft(y, STR_MULTI_VIDFREQ); break; case MM_RF_PROTO_DSM2: - g_model.moduleData[moduleIdx].multi.optionValue = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_MULTI_DSMFRAME, STR_OPTIONS_DSM, g_model.moduleData[moduleIdx].multi.optionValue, 0, 12, attr, event); + g_model.moduleData[moduleIdx].multi.optionValue = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_MULTI_DSMFRAME, STR_OPTIONS_DSM, g_model.moduleData[moduleIdx].multi.optionValue, 0, 12, attr, event); break; default: lcdDrawTextAlignedLeft(y, STR_MULTI_OPTION); diff --git a/radio/src/gui/212x64/model_telemetry.cpp b/radio/src/gui/212x64/model_telemetry.cpp index ffe0e5b2c..e26ac7a7b 100644 --- a/radio/src/gui/212x64/model_telemetry.cpp +++ b/radio/src/gui/212x64/model_telemetry.cpp @@ -122,7 +122,7 @@ enum SensorFields { #define SENSOR_FILTER_ROWS (sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW) #define SENSOR_PERSISTENT_ROWS (sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : HIDDEN_ROW) -void menuModelSensor(uint8_t event) +void menuModelSensor(event_t event) { TelemetrySensor * sensor = &g_model.telemetrySensors[s_currIdx]; @@ -132,7 +132,7 @@ void menuModelSensor(uint8_t event) 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_ONLYPOS_ROWS, SENSOR_FILTER_ROWS, SENSOR_PERSISTENT_ROWS, 0 }); - for (int i=0; itype = selectMenuItem(SENSOR_2ND_COLUMN, y, NO_INDENT(STR_TYPE), STR_VSENSORTYPES, sensor->type, 0, 1, attr, event); + sensor->type = editChoice(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) { @@ -181,7 +181,7 @@ void menuModelSensor(uint8_t event) } } else { - sensor->formula = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_FORMULA, STR_VFORMULAS, sensor->formula, 0, TELEM_FORMULA_LAST, attr, event); + sensor->formula = editChoice(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) { @@ -202,7 +202,7 @@ void menuModelSensor(uint8_t event) case SENSOR_FIELD_UNIT: lcdDrawTextAlignedLeft(y, STR_UNIT); - // TODO flash saving with selectMenuItem where I copied those 2 lines? + // TODO flash saving with editChoice where I copied those 2 lines? lcdDrawTextAtIndex(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr); if (attr) { CHECK_INCDEC_MODELVAR_ZERO(event, sensor->unit, UNIT_MAX); @@ -216,7 +216,7 @@ void menuModelSensor(uint8_t event) break; case SENSOR_FIELD_PRECISION: - sensor->prec = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_PRECISION, STR_VPREC, sensor->prec, 0, 2, attr, event); + sensor->prec = editChoice(SENSOR_2ND_COLUMN, y, STR_PRECISION, STR_VPREC, sensor->prec, 0, 2, attr, event); if (attr && checkIncDec_Ret) { telemetryItems[s_currIdx].clear(); } @@ -279,7 +279,7 @@ void menuModelSensor(uint8_t event) 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); + sensor->cell.index = editChoice(SENSOR_2ND_COLUMN, y, STR_CELLINDEX, STR_VCELLINDEX, sensor->cell.index, 0, 8, attr, event); break; } else if (sensor->formula == TELEM_FORMULA_DIST) { @@ -358,7 +358,7 @@ void menuModelSensor(uint8_t event) void onSensorMenu(const char *result) { - int index = menuVerticalPosition - ITEM_TELEMETRY_SENSOR1; + uint8_t index = menuVerticalPosition - ITEM_TELEMETRY_SENSOR1; if (index < MAX_TELEMETRY_SENSORS) { if (result == STR_EDIT) { @@ -391,7 +391,7 @@ void onSensorMenu(const char *result) } } -void menuModelTelemetryFrsky(uint8_t event) +void menuModelTelemetryFrsky(event_t event) { if (warningResult) { warningResult = 0; @@ -402,7 +402,7 @@ void menuModelTelemetryFrsky(uint8_t event) MENU(STR_MENUTELEMETRY, menuTabModel, MENU_MODEL_TELEMETRY_FRSKY, ITEM_TELEMETRY_MAX, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS }); - for (int i=0; i> idx; - potType = selectMenuItem(HW_SETTINGS_COLUMN+5*FW, y, "", STR_SLIDERTYPES, potType, SLIDER_NONE, SLIDER_WITH_DETENT, menuHorizontalPosition == 1 ? attr : 0, event); + potType = editChoice(HW_SETTINGS_COLUMN+5*FW, y, "", STR_SLIDERTYPES, potType, SLIDER_NONE, SLIDER_WITH_DETENT, menuHorizontalPosition == 1 ? attr : 0, event); g_eeGeneral.slidersConfig &= ~mask; g_eeGeneral.slidersConfig |= (potType << idx); break; @@ -153,7 +153,7 @@ void menuRadioHardware(uint8_t event) else lcdDrawTextAtIndex(HW_SETTINGS_COLUMN, y, STR_MMMINV, 0, 0); uint8_t potType = (g_eeGeneral.potsConfig & mask) >> shift; - potType = selectMenuItem(HW_SETTINGS_COLUMN+5*FW, y, "", STR_POTTYPES, potType, POT_NONE, POT_WITHOUT_DETENT, menuHorizontalPosition == 1 ? attr : 0, event); + potType = editChoice(HW_SETTINGS_COLUMN+5*FW, y, "", STR_POTTYPES, potType, POT_NONE, POT_WITHOUT_DETENT, menuHorizontalPosition == 1 ? attr : 0, event); g_eeGeneral.potsConfig &= ~mask; g_eeGeneral.potsConfig |= (potType << shift); break; @@ -189,7 +189,7 @@ void menuRadioHardware(uint8_t event) editName(HW_SETTINGS_COLUMN, y, g_eeGeneral.switchNames[index], LEN_SWITCH_NAME, event, menuHorizontalPosition == 0 ? attr : 0); else lcdDrawTextAtIndex(HW_SETTINGS_COLUMN, y, STR_MMMINV, 0, 0); - config = selectMenuItem(HW_SETTINGS_COLUMN+5*FW, y, "", STR_SWTYPES, config, SWITCH_NONE, SWITCH_TYPE_MAX(index), menuHorizontalPosition == 1 ? attr : 0, event); + config = editChoice(HW_SETTINGS_COLUMN+5*FW, y, "", STR_SWTYPES, config, SWITCH_NONE, SWITCH_TYPE_MAX(index), menuHorizontalPosition == 1 ? attr : 0, event); if (attr && checkIncDec_Ret) { swconfig_t mask = (swconfig_t)0x03 << (2*index); g_eeGeneral.switchConfig = (g_eeGeneral.switchConfig & ~mask) | ((swconfig_t(config) & 0x03) << (2*index)); @@ -207,7 +207,7 @@ void menuRadioHardware(uint8_t event) break; #endif case ITEM_RADIO_HARDWARE_UART3_MODE: - g_eeGeneral.serial2Mode = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_UART3MODE, STR_UART3MODES, g_eeGeneral.serial2Mode, 0, UART_MODE_MAX, attr, event); + g_eeGeneral.serial2Mode = editChoice(HW_SETTINGS_COLUMN, y, STR_UART3MODE, STR_UART3MODES, g_eeGeneral.serial2Mode, 0, UART_MODE_MAX, attr, event); if (attr && checkIncDec_Ret) { serial2Init(g_eeGeneral.serial2Mode, MODEL_TELEMETRY_PROTOCOL()); } diff --git a/radio/src/gui/212x64/radio_setup.cpp b/radio/src/gui/212x64/radio_setup.cpp index b0e2577b1..1b1f4ff96 100644 --- a/radio/src/gui/212x64/radio_setup.cpp +++ b/radio/src/gui/212x64/radio_setup.cpp @@ -33,7 +33,7 @@ const pm_uchar sticks[] PROGMEM = { #define SLIDER_5POS(y, value, label, event, attr) { \ int8_t tmp = value; \ drawSlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \ - value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ + value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ } #if defined(SPLASH) && !defined(FSPLASH) @@ -215,7 +215,7 @@ void menuRadioSetup(uint8_t event) 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); + g_eeGeneral.beepMode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_SPEAKER, STR_VBEEPMODE, g_eeGeneral.beepMode, -2, 1, attr, event); #if defined(TELEMETRY_FRSKY) if (attr && checkIncDec_Ret) frskySendAlarms(); #endif @@ -298,7 +298,7 @@ void menuRadioSetup(uint8_t event) 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); + g_eeGeneral.hapticMode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_MODE, STR_VBEEPMODE, g_eeGeneral.hapticMode, -2, 1, attr, event); break; case ITEM_SETUP_HAPTIC_LENGTH: @@ -355,7 +355,7 @@ void menuRadioSetup(uint8_t event) 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); + g_eeGeneral.backlightMode = editChoice(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: @@ -419,13 +419,13 @@ void menuRadioSetup(uint8_t 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); + g_eeGeneral.gpsFormat = editChoice(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); + g_eeGeneral.countryCode = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_COUNTRYCODE, STR_COUNTRYCODES, g_eeGeneral.countryCode, 0, 2, attr, event); break; #endif @@ -442,7 +442,7 @@ void menuRadioSetup(uint8_t event) 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); + g_eeGeneral.imperial = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_UNITSSYSTEM, STR_VUNITSSYSTEM, g_eeGeneral.imperial, 0, 1, attr, event); break; #if defined(FAI_CHOICE) @@ -459,7 +459,7 @@ void menuRadioSetup(uint8_t event) #if defined(TELEMETRY_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); + g_eeGeneral.mavbaud = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_MAVLINK_BAUD_LABEL, STR_MAVLINK_BAUDS, g_eeGeneral.mavbaud, 0, 7, attr, event); break; #endif diff --git a/radio/src/gui/212x64/widgets.cpp b/radio/src/gui/212x64/widgets.cpp index 7cc52d622..4716308d9 100644 --- a/radio/src/gui/212x64/widgets.cpp +++ b/radio/src/gui/212x64/widgets.cpp @@ -129,7 +129,7 @@ void title(const pm_char * s) lcdDrawText(0, 0, s, INVERS); } -select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event) +choice_t editChoice(coord_t x, coord_t y, const pm_char *label, const pm_char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, uint8_t event) { drawFieldLabel(x, y, label); if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr); @@ -140,10 +140,10 @@ select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, c uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char *label, LcdFlags attr, uint8_t event ) { drawCheckBox(x, y, value, attr); - return selectMenuItem(x, y, label, NULL, value, 0, 1, attr, event); + return editChoice(x, y, label, NULL, value, 0, 1, attr, event); } -swsrc_t switchMenuItem(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, uint8_t event) +swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, uint8_t event) { drawFieldLabel(x, y, STR_SWITCH); drawSwitch(x, y, value, attr); diff --git a/radio/src/gui/480x272/gui.h b/radio/src/gui/480x272/gui.h index 1e57e8f21..19b55f760 100644 --- a/radio/src/gui/480x272/gui.h +++ b/radio/src/gui/480x272/gui.h @@ -28,6 +28,7 @@ #include "bitmaps.h" #include "theme.h" +#define MENU_TOOLTIPS #define MENU_HEADER_HEIGHT 45 #define MENU_TITLE_TOP 48 #define MENU_TITLE_HEIGHT 21 diff --git a/radio/src/gui/480x272/lcd.cpp b/radio/src/gui/480x272/lcd.cpp index c7df879eb..225d9a95a 100644 --- a/radio/src/gui/480x272/lcd.cpp +++ b/radio/src/gui/480x272/lcd.cpp @@ -294,30 +294,6 @@ void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att } } -const pm_uint8_t bchunit_ar[] PROGMEM = { - UNIT_DIST, // Alt - UNIT_RAW, // Rpm - UNIT_PERCENT, // Fuel - UNIT_TEMPERATURE, // T1 - UNIT_TEMPERATURE, // T2 - UNIT_KTS, // Speed - UNIT_DIST, // Dist - UNIT_DIST, // GPS Alt -}; - -void drawValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att) -{ - // convertUnit(val, unit); - if (!(att & NO_UNIT) && unit != UNIT_RAW) { - char unitStr[8]; - strAppend(unitStr, STR_VTELEMUNIT+1+unit*STR_VTELEMUNIT[0], STR_VTELEMUNIT[0]); - lcdDrawNumber(x, y, val, att, 0, NULL, unitStr); - } - else { - lcdDrawNumber(x, y, val, att); - } -} - void drawDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags att) { // TODO diff --git a/radio/src/gui/480x272/lcd.h b/radio/src/gui/480x272/lcd.h index 2174496d4..07a858a80 100644 --- a/radio/src/gui/480x272/lcd.h +++ b/radio/src/gui/480x272/lcd.h @@ -129,7 +129,6 @@ inline void lcdDrawSizedText(coord_t x, coord_t y, const pm_char * s, uint8_t le void lcdDrawHexNumber(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0); void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags=0, uint8_t len=0, const char * prefix=NULL, const char * suffix=NULL); -void drawStringWithIndex(coord_t x, coord_t y, const pm_char *str, int idx, LcdFlags att=0, const char *prefix=""); void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att); void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0); void drawSwitch(coord_t x, coord_t y, swsrc_t swtch, LcdFlags flags=0); diff --git a/radio/src/gui/480x272/menus.h b/radio/src/gui/480x272/menus.h index 1bdc035fc..8e10d93a2 100644 --- a/radio/src/gui/480x272/menus.h +++ b/radio/src/gui/480x272/menus.h @@ -167,6 +167,7 @@ const uint8_t MONITOR_ICONS[] = { }; bool menuModelSetup(event_t event); +bool menuModelFailsafe(event_t event); bool menuModelHeli(event_t event); bool menuModelFlightModesAll(event_t event); bool menuModelExposAll(event_t event); @@ -400,11 +401,6 @@ bool check_submenu_simple(event_t event, uint8_t maxrow); if (!check_submenu_simple(event, lines_count)) return false; \ drawMenuTemplate(title, icon, NULL, options) -typedef int select_menu_value_t; - -select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char * values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, event_t event); -uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event); - #if defined(GVARS) #define GVAR_MENU_ITEM(x, y, v, min, max, lcdattr, editflags, event) editGVarFieldValue(x, y, v, min, max, lcdattr, editflags, event) #else diff --git a/radio/src/gui/480x272/model_curves.cpp b/radio/src/gui/480x272/model_curves.cpp index a9c458ee7..45132218a 100644 --- a/radio/src/gui/480x272/model_curves.cpp +++ b/radio/src/gui/480x272/model_curves.cpp @@ -159,7 +159,7 @@ bool menuModelCurveOne(event_t event) pointsOfs = 0; break; case EVT_KEY_LONG(KEY_ENTER): - if (menuVerticalPosition > ITEM_CURVE_POINTS) { + if (menuVerticalPosition > ITEM_CURVE_NAME) { killEvents(event); POPUP_MENU_ADD_ITEM(STR_CURVE_PRESET); POPUP_MENU_ADD_ITEM(STR_MIRROR); @@ -290,12 +290,11 @@ bool menuModelCurvesAll(event_t event) { SIMPLE_MENU(STR_MENUCURVES, MODEL_ICONS, menuTabModel, MENU_MODEL_CURVES, MAX_CURVES); - int8_t sub = menuVerticalPosition; + s_curveChan = menuVerticalPosition; switch (event) { case EVT_KEY_BREAK(KEY_ENTER): if (!READ_ONLY()) { - s_curveChan = sub; pushMenu(menuModelCurveOne); } break; @@ -304,7 +303,7 @@ bool menuModelCurvesAll(event_t event) for (int i=0; i= 0) { - s_curveChan = sub; - drawCurve(CURVE_CENTER_X, CURVE_CENTER_Y+10, 80); - } + drawCurve(CURVE_CENTER_X, CURVE_CENTER_Y+10, 80); return true; } diff --git a/radio/src/gui/480x272/model_flightmodes.cpp b/radio/src/gui/480x272/model_flightmodes.cpp index 5d75baacc..c4d40d121 100644 --- a/radio/src/gui/480x272/model_flightmodes.cpp +++ b/radio/src/gui/480x272/model_flightmodes.cpp @@ -121,11 +121,11 @@ bool menuModelFlightModesAll(event_t event) return true; } - FlightModeData *p = flightModeAddress(k); + FlightModeData * p = flightModeAddress(k); drawFlightMode(MENUS_MARGIN_LEFT, y, k+1, (getFlightMode()==k ? BOLD : 0) | ((menuVerticalPosition==k && menuHorizontalPosition<0) ? INVERS : 0)); - for (int j=0; j0) ? BLINK|INVERS : INVERS) : 0); LcdFlags active = (attr && s_editMode>0) ; switch (j) { diff --git a/radio/src/gui/480x272/model_inputs.cpp b/radio/src/gui/480x272/model_inputs.cpp index 4fd410769..c01480a17 100644 --- a/radio/src/gui/480x272/model_inputs.cpp +++ b/radio/src/gui/480x272/model_inputs.cpp @@ -219,7 +219,7 @@ bool menuModelExpoOne(event_t event) drawCurveCoord(CURVE_CENTER_X-CURVE_SIDE_WIDTH-37, top, texty); } - for (int i=0; i0 ? BLINK|INVERS : INVERS) : 0); switch (i) { case EXPO_FIELD_INPUT_NAME: @@ -244,7 +244,7 @@ bool menuModelExpoOne(event_t event) menuHorizontalPosition = 0; } break; - + case EXPO_FIELD_SCALE: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SCALE); drawSensorCustomValue(EXPO_ONE_2ND_COLUMN, y, (ed->srcRaw - MIXSRC_FIRST_TELEM)/3, convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale), LEFT|attr); @@ -277,12 +277,12 @@ bool menuModelExpoOne(event_t event) case EXPO_FIELD_SWITCH: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWITCH); - ed->swtch = switchMenuItem(EXPO_ONE_2ND_COLUMN, y, ed->swtch, attr, event); + ed->swtch = editSwitch(EXPO_ONE_2ND_COLUMN, y, ed->swtch, attr, event); break; case EXPO_FIELD_SIDE: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SIDE); - ed->mode = 4 - selectMenuItem(EXPO_ONE_2ND_COLUMN, y, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); + ed->mode = 4 - editChoice(EXPO_ONE_2ND_COLUMN, y, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); break; case EXPO_FIELD_TRIM: diff --git a/radio/src/gui/480x272/model_logical_switches.cpp b/radio/src/gui/480x272/model_logical_switches.cpp index 4bf92247a..643f41c27 100644 --- a/radio/src/gui/480x272/model_logical_switches.cpp +++ b/radio/src/gui/480x272/model_logical_switches.cpp @@ -85,9 +85,11 @@ bool menuModelLogicalSwitches(event_t event) REPEAT_LAST_CURSOR_MOVE(LS_FIELD_LAST, false); } +#if defined(MENU_TOOLTIPS) if (menuVerticalPosition>= 0 && menuHorizontalPosition>=0) { drawColumnHeader(STR_LSW_HEADERS, STR_LSW_DESCRIPTIONS, menuHorizontalPosition); } +#endif if (menuHorizontalPosition<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { killEvents(event); diff --git a/radio/src/gui/480x272/model_mixes.cpp b/radio/src/gui/480x272/model_mixes.cpp index a370a89c1..3fa34a1b0 100644 --- a/radio/src/gui/480x272/model_mixes.cpp +++ b/radio/src/gui/480x272/model_mixes.cpp @@ -239,11 +239,11 @@ bool menuModelMixOne(event_t event) #endif case MIX_FIELD_SWITCH: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWITCH); - md2->swtch = switchMenuItem(MIXES_2ND_COLUMN, y, md2->swtch, attr, event); + md2->swtch = editSwitch(MIXES_2ND_COLUMN, y, md2->swtch, attr, event); break; case MIX_FIELD_MLTPX: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MULTPX); - md2->mltpx = selectMenuItem(MIXES_2ND_COLUMN, y, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); + md2->mltpx = editChoice(MIXES_2ND_COLUMN, y, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); break; case MIX_FIELD_DELAY_UP: lcdDrawText(MENU_COLUMN2_X+MENUS_MARGIN_LEFT, y, STR_DELAYUP); @@ -381,14 +381,14 @@ void displayMixStatus(uint8_t channel) bool menuModelMixAll(event_t event) { - BitmapBuffer * mpx_mode[] = { + static const BitmapBuffer * mpx_mode[] = { mixerSetupAddBitmap, mixerSetupMultiBitmap, mixerSetupReplaceBitmap }; - int sub = menuVerticalPosition; + uint8_t sub = menuVerticalPosition; if (s_editMode > 0) { s_editMode = 0; @@ -465,7 +465,7 @@ bool menuModelMixAll(event_t event) s_copyMode = 0; return true; } - else if (menuVerticalPosition >= 0) { + else { event = 0; s_copyMode = 0; POPUP_MENU_ADD_ITEM(STR_EDIT); @@ -543,7 +543,9 @@ bool menuModelMixAll(event_t event) if (cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES) { LcdFlags attr = ((s_copyMode || sub != cur) ? 0 : INVERS); - if (mixCnt > 0) lcd->drawBitmap(10, y, mpx_mode[md->mltpx]); + if (mixCnt > 0) { + lcd->drawBitmap(10, y, mpx_mode[md->mltpx]); + } drawSource(MIX_LINE_SRC_POS, y, md->srcRaw); diff --git a/radio/src/gui/480x272/model_setup.cpp b/radio/src/gui/480x272/model_setup.cpp index 4a3cc8936..adbca635e 100644 --- a/radio/src/gui/480x272/model_setup.cpp +++ b/radio/src/gui/480x272/model_setup.cpp @@ -21,7 +21,6 @@ #include "opentx.h" uint8_t g_moduleIdx; -bool menuModelFailsafe(event_t event); enum MenuModelSetupItems { ITEM_MODEL_NAME, @@ -89,7 +88,7 @@ enum MenuModelSetupItems { #define MODEL_SETUP_RANGE_OFS 80 #define MODEL_SETUP_SET_FAILSAFE_OFS 100 -void onModelSetupBitmapMenu(const char *result) +void onModelSetupBitmapMenu(const char * result) { if (result == STR_UPDATE_LIST) { if (!sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), NULL)) { @@ -255,9 +254,9 @@ bool menuModelSetup(event_t event) int sub = menuVerticalPosition; - for (int i=0; i 1 @@ -333,10 +332,10 @@ bool menuModelSetup(event_t event) case ITEM_MODEL_TIMER2_PERSISTENT: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PERSISTENT); - g_model.timers[1].persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VPERSISTENT, g_model.timers[1].persistent, 0, 2, attr, event); + g_model.timers[1].persistent = editChoice(MODEL_SETUP_2ND_COLUMN, y, 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); @@ -358,7 +357,7 @@ bool menuModelSetup(event_t event) case ITEM_MODEL_TIMER3_PERSISTENT: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PERSISTENT); - g_model.timers[2].persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VPERSISTENT, g_model.timers[2].persistent, 0, 2, attr, event); + g_model.timers[2].persistent = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_VPERSISTENT, g_model.timers[2].persistent, 0, 2, attr, event); break; #endif @@ -386,12 +385,12 @@ bool menuModelSetup(event_t event) case ITEM_MODEL_DISPLAY_TRIMS: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_DISPLAY_TRIMS); - g_model.displayTrims = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, "\006No\0 ChangeYes", g_model.displayTrims, 0, 2, attr, event); + g_model.displayTrims = editChoice(MODEL_SETUP_2ND_COLUMN, y, "\006No\0 ChangeYes", g_model.displayTrims, 0, 2, attr, event); break; case ITEM_MODEL_TRIM_INC: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TRIMINC); - g_model.trimInc = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VTRIMINC, g_model.trimInc, -2, 2, attr, event); + g_model.trimInc = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_VTRIMINC, g_model.trimInc, -2, 2, attr, event); break; case ITEM_MODEL_THROTTLE_LABEL: @@ -568,7 +567,7 @@ bool menuModelSetup(event_t event) case ITEM_MODEL_INTERNAL_MODULE_ANTENNA: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ANTENNASELECTION); - newAntennaSel = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VANTENNATYPES, g_model.moduleData[INTERNAL_MODULE].ppm.pulsePol, 0, 1, attr, event); + newAntennaSel = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_VANTENNATYPES, g_model.moduleData[INTERNAL_MODULE].ppm.pulsePol, 0, 1, attr, event); if (newAntennaSel != g_model.moduleData[INTERNAL_MODULE].ppm.pulsePol && newAntennaSel == XJT_EXTERNAL_ANTENNA) { POPUP_CONFIRMATION(STR_ANTENNACONFIRM1); const char * w = STR_ANTENNACONFIRM2; @@ -581,7 +580,7 @@ bool menuModelSetup(event_t event) case ITEM_MODEL_TRAINER_MODE: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MODE); - g_model.trainerMode = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VTRAINERMODES, g_model.trainerMode, 0, HAS_WIRELESS_TRAINER_HARDWARE() ? TRAINER_MODE_MASTER_BATTERY_COMPARTMENT : TRAINER_MODE_SLAVE, attr, event); + g_model.trainerMode = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_VTRAINERMODES, g_model.trainerMode, 0, HAS_WIRELESS_TRAINER_HARDWARE() ? TRAINER_MODE_MASTER_BATTERY_COMPARTMENT : TRAINER_MODE_SLAVE, attr, event); break; case ITEM_MODEL_EXTERNAL_MODULE_LABEL: @@ -590,7 +589,7 @@ bool menuModelSetup(event_t event) case ITEM_MODEL_EXTERNAL_MODULE_MODE: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MODE); - lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_TARANIS_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].type, (menuHorizontalPosition==0 ? attr : 0)); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_TARANIS_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0); if (IS_MODULE_XJT(EXTERNAL_MODULE)) lcdDrawTextAtIndex(MODEL_SETUP_3RD_COLUMN, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].rfProtocol, (menuHorizontalPosition==1 ? attr : 0)); else if (IS_MODULE_DSM2(EXTERNAL_MODULE)) @@ -856,7 +855,7 @@ bool menuModelSetup(event_t event) break; case MM_RF_PROTO_DSM2: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MULTI_DSMFRAME); - g_model.moduleData[moduleIdx].multi.optionValue = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_OPTIONS_DSM, g_model.moduleData[moduleIdx].multi.optionValue, 0, 12, attr, event); + g_model.moduleData[moduleIdx].multi.optionValue = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_OPTIONS_DSM, g_model.moduleData[moduleIdx].multi.optionValue, 0, 12, attr, event); break; default: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MULTI_OPTION); diff --git a/radio/src/gui/480x272/model_telemetry.cpp b/radio/src/gui/480x272/model_telemetry.cpp index 05d2bb6c2..a617211dc 100644 --- a/radio/src/gui/480x272/model_telemetry.cpp +++ b/radio/src/gui/480x272/model_telemetry.cpp @@ -131,7 +131,7 @@ bool menuModelSensor(event_t event) lcdDrawNumber(lcdNextPos, 3, s_currIdx+1, MENU_TITLE_COLOR|LEFT); drawSensorCustomValue(50, 3+FH, s_currIdx, getValue(MIXSRC_FIRST_TELEM+3*s_currIdx), MENU_TITLE_COLOR|LEFT); - for (unsigned int i=0; itype = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_VSENSORTYPES, sensor->type, 0, 1, attr, event); + sensor->type = editChoice(SENSOR_2ND_COLUMN, y, STR_VSENSORTYPES, sensor->type, 0, 1, attr, event); if (attr && checkIncDec_Ret) { sensor->instance = 0; if (sensor->type == TELEM_TYPE_CALCULATED) { @@ -183,7 +183,7 @@ bool menuModelSensor(event_t event) } else { lcdDrawText(MENUS_MARGIN_LEFT, y, STR_FORMULA); - sensor->formula = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_VFORMULAS, sensor->formula, 0, TELEM_FORMULA_LAST, attr, event); + sensor->formula = editChoice(SENSOR_2ND_COLUMN, y, STR_VFORMULAS, sensor->formula, 0, TELEM_FORMULA_LAST, attr, event); if (attr && checkIncDec_Ret) { sensor->param = 0; if (sensor->formula == TELEM_FORMULA_CELL) { @@ -204,7 +204,7 @@ bool menuModelSensor(event_t event) case SENSOR_FIELD_UNIT: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_UNIT); - // TODO flash saving with selectMenuItem where I copied those 2 lines? + // TODO flash saving with editChoice where I copied those 2 lines? lcdDrawTextAtIndex(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr); if (attr) { CHECK_INCDEC_MODELVAR_ZERO(event, sensor->unit, UNIT_MAX); @@ -219,7 +219,7 @@ bool menuModelSensor(event_t event) case SENSOR_FIELD_PRECISION: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PRECISION); - sensor->prec = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_VPREC, sensor->prec, 0, 2, attr, event); + sensor->prec = editChoice(SENSOR_2ND_COLUMN, y, STR_VPREC, sensor->prec, 0, 2, attr, event); if (attr && checkIncDec_Ret) { telemetryItems[s_currIdx].clear(); } @@ -247,7 +247,7 @@ bool menuModelSensor(event_t event) lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CURRENTSENSOR); drawSource(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_TELEMETRY_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isTelemetryFieldAvailable); + sensor->consumption.source = checkIncDec(event, sensor->consumption.source, 0, MAX_TELEMETRY_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable); } break; } @@ -255,7 +255,7 @@ bool menuModelSensor(event_t event) lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_SOURCE)); drawSource(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_TELEMETRY_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isTelemetryFieldComparisonAvailable); + sensor->consumption.source = checkIncDec(event, sensor->consumption.source, 0, MAX_TELEMETRY_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable); } break; } @@ -283,7 +283,7 @@ bool menuModelSensor(event_t event) if (sensor->type == TELEM_TYPE_CALCULATED) { if (sensor->formula == TELEM_FORMULA_CELL) { lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CELLINDEX); - sensor->cell.index = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_VCELLINDEX, sensor->cell.index, 0, 8, attr, event); + sensor->cell.index = editChoice(SENSOR_2ND_COLUMN, y, STR_VCELLINDEX, sensor->cell.index, 0, 8, attr, event); break; } else if (sensor->formula == TELEM_FORMULA_DIST) { @@ -348,6 +348,9 @@ bool menuModelSensor(event_t event) case SENSOR_FIELD_PERSISTENT: lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_PERSISTENT)); sensor->persistent = editCheckBox(sensor->persistent, SENSOR_2ND_COLUMN, y, attr, event); + if (checkIncDec_Ret && !sensor->persistent) { + sensor->persistentValue = 0; + } break; case SENSOR_FIELD_LOGS: @@ -359,13 +362,12 @@ bool menuModelSensor(event_t event) break; } } - return true; } -void onSensorMenu(const char *result) +void onSensorMenu(const char * result) { - int index = menuVerticalPosition - ITEM_TELEMETRY_SENSOR1; + uint8_t index = menuVerticalPosition - ITEM_TELEMETRY_SENSOR1; if (index < MAX_TELEMETRY_SENSORS) { if (result == STR_EDIT) { @@ -409,7 +411,7 @@ bool menuModelTelemetryFrsky(event_t event) MENU(STR_MENUTELEMETRY, MODEL_ICONS, menuTabModel, MENU_MODEL_TELEMETRY_FRSKY, ITEM_TELEMETRY_MAX, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS }); - for (int i=0; i> idx; - potType = selectMenuItem(HW_SETTINGS_COLUMN+50, y, STR_SLIDERTYPES, potType, SLIDER_NONE, SLIDER_WITH_DETENT, menuHorizontalPosition == 1 ? attr : 0, event); + potType = editChoice(HW_SETTINGS_COLUMN+50, y, STR_SLIDERTYPES, potType, SLIDER_NONE, SLIDER_WITH_DETENT, menuHorizontalPosition == 1 ? attr : 0, event); g_eeGeneral.slidersConfig &= ~mask; g_eeGeneral.slidersConfig |= (potType << idx); break; @@ -128,7 +128,7 @@ bool menuRadioHardware(event_t event) else lcdDrawTextAtIndex(HW_SETTINGS_COLUMN, y, STR_MMMINV, 0, 0); uint8_t potType = (g_eeGeneral.potsConfig & mask) >> shift; - potType = selectMenuItem(HW_SETTINGS_COLUMN+50, y, STR_POTTYPES, potType, POT_NONE, POT_WITHOUT_DETENT, menuHorizontalPosition == 1 ? attr : 0, event); + potType = editChoice(HW_SETTINGS_COLUMN+50, y, STR_POTTYPES, potType, POT_NONE, POT_WITHOUT_DETENT, menuHorizontalPosition == 1 ? attr : 0, event); g_eeGeneral.potsConfig &= ~mask; g_eeGeneral.potsConfig |= (potType << shift); break; @@ -152,7 +152,7 @@ bool menuRadioHardware(event_t event) editName(HW_SETTINGS_COLUMN, y, g_eeGeneral.switchNames[index], LEN_SWITCH_NAME, event, menuHorizontalPosition == 0 ? attr : 0); else lcdDrawTextAtIndex(HW_SETTINGS_COLUMN, y, STR_MMMINV, 0, 0); - config = selectMenuItem(HW_SETTINGS_COLUMN+50, y, STR_SWTYPES, config, SWITCH_NONE, SWITCH_TYPE_MAX(index), menuHorizontalPosition == 1 ? attr : 0, event); + config = editChoice(HW_SETTINGS_COLUMN+50, y, STR_SWTYPES, config, SWITCH_NONE, SWITCH_TYPE_MAX(index), menuHorizontalPosition == 1 ? attr : 0, event); if (attr && checkIncDec_Ret) { swconfig_t mask = (swconfig_t)0x03 << (2*index); g_eeGeneral.switchConfig = (g_eeGeneral.switchConfig & ~mask) | ((swconfig_t(config) & 0x03) << (2*index)); @@ -171,7 +171,7 @@ bool menuRadioHardware(event_t event) #if 0 case ITEM_RADIO_HARDWARE_UART3_MODE: - g_eeGeneral.serial2Mode = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_UART3MODE, STR_UART3MODES, g_eeGeneral.serial2Mode, 0, UART_MODE_MAX, attr, event); + g_eeGeneral.serial2Mode = editChoice(HW_SETTINGS_COLUMN, y, STR_UART3MODE, STR_UART3MODES, g_eeGeneral.serial2Mode, 0, UART_MODE_MAX, attr, event); if (attr && checkIncDec_Ret) { serial2Init(g_eeGeneral.serial2Mode, MODEL_TELEMETRY_PROTOCOL()); } diff --git a/radio/src/gui/480x272/radio_sdmanager.cpp b/radio/src/gui/480x272/radio_sdmanager.cpp index bd6f1a804..cf76096cf 100644 --- a/radio/src/gui/480x272/radio_sdmanager.cpp +++ b/radio/src/gui/480x272/radio_sdmanager.cpp @@ -181,6 +181,7 @@ bool menuRadioSdManager(event_t _event) break; #if 0 + // TODO: Implement it case EVT_KEY_LONG(KEY_MENU): if (!READ_ONLY() && s_editMode == 0) { killEvents(_event); @@ -196,13 +197,7 @@ bool menuRadioSdManager(event_t _event) break; case EVT_KEY_BREAK(KEY_ENTER): - if (menuVerticalPosition < 0) { - if (reusableBuffer.sdmanager.count > 0) { - menuVerticalPosition = 0; - } - break; - } - else if (s_editMode > 0) { + if (s_editMode > 0) { break; } else { @@ -342,7 +337,7 @@ bool menuRadioSdManager(event_t _event) reusableBuffer.sdmanager.offset = menuVerticalOffset; - for (int i=0; i