diff --git a/radio/src/gui/horus/menu_model_curves.cpp b/radio/src/gui/horus/menu_model_curves.cpp index dddd8dc43..9829676f1 100644 --- a/radio/src/gui/horus/menu_model_curves.cpp +++ b/radio/src/gui/horus/menu_model_curves.cpp @@ -150,6 +150,21 @@ bool menuModelCurveOne(evt_t event) drawStringWithIndex(50, 3+FH, STR_CV, s_curveChan+1, MENU_TITLE_COLOR); lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, 250, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR); + if (crv.type==CURVE_TYPE_CUSTOM && menuVerticalPosition == ITEM_CURVE_COORDS1) { + if (menuHorizontalPosition == 0) { + if (CURSOR_MOVED_RIGHT(event)) + menuHorizontalPosition = 1; + else + menuVerticalPosition -= 1; + } + else if (menuHorizontalPosition == 4+crv.points) { + if (CURSOR_MOVED_RIGHT(event)) + (menuHorizontalPosition = 0, menuVerticalPosition += 1); + else + menuHorizontalPosition -= 1; + } + } + // Curve name lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP-FH, STR_NAME); editName(MODEL_CURVE_ONE_2ND_COLUMN, MENU_CONTENT_TOP-FH, crv.name, sizeof(crv.name), event, menuVerticalPosition==ITEM_CURVE_NAME); @@ -234,15 +249,6 @@ bool menuModelCurveOne(evt_t event) selectionMode = 2; } - if (selectionMode == 1) { - if (menuHorizontalPosition == 0) { - REPEAT_LAST_CURSOR_MOVE(1); - } - else if (menuHorizontalPosition == 4+crv.points) { - REPEAT_LAST_CURSOR_MOVE(3+crv.points); - } - } - int8_t x = -100 + 200*i/(5+crv.points-1); if (crv.type==CURVE_TYPE_CUSTOM && i>0 && i<5+crv.points-1) x = points[5+crv.points+i-1]; diff --git a/radio/src/gui/horus/menu_model_flightmodes.cpp b/radio/src/gui/horus/menu_model_flightmodes.cpp index 13c3a2b7b..39b5f5bf6 100644 --- a/radio/src/gui/horus/menu_model_flightmodes.cpp +++ b/radio/src/gui/horus/menu_model_flightmodes.cpp @@ -36,14 +36,12 @@ void displayFlightModes(coord_t x, coord_t y, FlightModesType value, uint8_t att FlightModesType editFlightModes(coord_t x, coord_t y, evt_t event, FlightModesType value, uint8_t attr) { - int posHorz = menuHorizontalPosition; - displayFlightModes(x, y, value, attr); if (attr) { if (s_editMode && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; - value ^= (1<=0) { - drawColumnHeader(STR_PHASES_HEADERS, NULL, posHorz); + if (menuVerticalPosition=0) { + drawColumnHeader(STR_PHASES_HEADERS, NULL, menuHorizontalPosition); } - for (int i=0; i0) ? BLINK|INVERS : INVERS) : 0); + LcdFlags attr = ((menuVerticalPosition==k && menuHorizontalPosition==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); LcdFlags active = (attr && s_editMode>0) ; switch (j) { case ITEM_FLIGHT_MODES_NAME: diff --git a/radio/src/gui/horus/menu_model_logical_switches.cpp b/radio/src/gui/horus/menu_model_logical_switches.cpp index 8366d3b36..8733128c9 100644 --- a/radio/src/gui/horus/menu_model_logical_switches.cpp +++ b/radio/src/gui/horus/menu_model_logical_switches.cpp @@ -56,8 +56,7 @@ void putsEdgeDelayParam(coord_t x, coord_t y, LogicalSwitchData *cs, uint8_t lat void onLogicalSwitchesMenu(const char *result) { - int8_t sub = menuVerticalPosition; - LogicalSwitchData * cs = lswAddress(sub); + LogicalSwitchData * cs = lswAddress(menuVerticalPosition); if (result == STR_COPY) { clipboard.type = CLIPBOARD_TYPE_CUSTOM_SWITCH; @@ -79,17 +78,19 @@ bool menuModelLogicalSwitches(evt_t event) MENU(STR_MENULOGICALSWITCHES, MODEL_ICONS, menuTabModel, e_LogicalSwitches, NUM_LOGICAL_SWITCH, { NAVIGATION_LINE_BY_LINE|LS_FIELD_LAST/*repeated...*/} ); - int k = 0; - int sub = menuVerticalPosition; - int horz = menuHorizontalPosition; - - if (sub>= 0 && horz>=0) { - drawColumnHeader(STR_LSW_HEADERS, STR_LSW_DESCRIPTIONS, horz); + LogicalSwitchData * cs = lswAddress(menuVerticalPosition); + uint8_t cstate = lswFamily(cs->func); + if ((cstate == LS_FAMILY_EDGE && menuHorizontalPosition == LS_FIELD_DELAY) || + (cstate != LS_FAMILY_EDGE && menuHorizontalPosition == LS_FIELD_V3)) { + REPEAT_LAST_CURSOR_MOVE(LS_FIELD_LAST, false); } - if (horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { + if (menuVerticalPosition>= 0 && menuHorizontalPosition>=0) { + drawColumnHeader(STR_LSW_HEADERS, STR_LSW_DESCRIPTIONS, menuHorizontalPosition); + } + + if (menuHorizontalPosition<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { killEvents(event); - LogicalSwitchData * cs = lswAddress(sub); if (cs->func) POPUP_MENU_ADD_ITEM(STR_COPY); if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH) @@ -101,21 +102,21 @@ bool menuModelLogicalSwitches(evt_t event) for (int i=0; i0) ? BLINK|INVERS : INVERS) : 0); - LcdFlags attr1 = (horz==1 ? attr : 0); - LcdFlags attr2 = (horz==2 ? attr : 0); - LogicalSwitchData * cs = lswAddress(k); + int k = i+menuVerticalOffset; + LcdFlags attr = (menuVerticalPosition==k ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); + LcdFlags attr1 = (menuHorizontalPosition==1 ? attr : 0); + LcdFlags attr2 = (menuHorizontalPosition==2 ? attr : 0); + cs = lswAddress(k); // CSW name unsigned int sw = SWSRC_SW1+k; - putsSwitches(MENUS_MARGIN_LEFT, y, sw, (getSwitch(sw) ? BOLD : 0) | ((sub==k && CURSOR_ON_LINE()) ? INVERS : 0)); + putsSwitches(MENUS_MARGIN_LEFT, y, sw, (getSwitch(sw) ? BOLD : 0) | ((menuVerticalPosition==k && CURSOR_ON_LINE()) ? INVERS : 0)); // CSW func - lcdDrawTextAtIndex(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, horz==0 ? attr : 0); + lcdDrawTextAtIndex(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, menuHorizontalPosition==0 ? attr : 0); // CSW params - unsigned int cstate = lswFamily(cs->func); + cstate = lswFamily(cs->func); int v1_val=cs->v1, v1_min=0, v1_max=MIXSRC_LAST_TELEM; int v2_min=0, v2_max=MIXSRC_LAST_TELEM; int v3_min=-1, v3_max=100; @@ -130,11 +131,11 @@ bool menuModelLogicalSwitches(evt_t event) } else if (cstate == LS_FAMILY_EDGE) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); - putsEdgeDelayParam(CSW_3RD_COLUMN, y, cs, attr2, (horz==LS_FIELD_V3 ? attr : 0)); + putsEdgeDelayParam(CSW_3RD_COLUMN, y, cs, attr2, (menuHorizontalPosition==LS_FIELD_V3 ? attr : 0)); v1_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES; v2_min=-129; v2_max = 122; v3_max = 222 - cs->v2; - if (horz == 1) { + if (menuHorizontalPosition == 1) { INCDEC_SET_FLAG(EE_MODEL | INCDEC_SWITCH); INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); } @@ -161,7 +162,7 @@ bool menuModelLogicalSwitches(evt_t event) else { v1_val = cs->v1; putsMixerSource(CSW_2ND_COLUMN, y, v1_val, attr1); - if (horz == 1) { + if (menuHorizontalPosition == 1) { INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailableInCustomSwitches); } @@ -175,34 +176,27 @@ bool menuModelLogicalSwitches(evt_t event) } // CSW AND switch - putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==LS_FIELD_ANDSW ? attr : 0); + putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, menuHorizontalPosition==LS_FIELD_ANDSW ? attr : 0); // CSW duration if (cs->duration > 0) - lcdDrawNumber(CSW_5TH_COLUMN, y, cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); + lcdDrawNumber(CSW_5TH_COLUMN, y, cs->duration, (menuHorizontalPosition==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); else - lcdDrawTextAtIndex(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); + lcdDrawTextAtIndex(CSW_5TH_COLUMN, y, STR_MMMINV, 0, menuHorizontalPosition==LS_FIELD_DURATION ? attr : 0); // CSW delay if (cstate == LS_FAMILY_EDGE) { lcdDrawText(CSW_6TH_COLUMN, y, STR_NA); - if (attr && horz == LS_FIELD_DELAY) { - REPEAT_LAST_CURSOR_MOVE(0); - } } else if (cs->delay > 0) { - lcdDrawNumber(CSW_6TH_COLUMN, y, cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); + lcdDrawNumber(CSW_6TH_COLUMN, y, cs->delay, (menuHorizontalPosition==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); } else { - lcdDrawTextAtIndex(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); - } - - if (attr && horz == LS_FIELD_V3 && cstate != LS_FAMILY_EDGE) { - REPEAT_LAST_CURSOR_MOVE(0); + lcdDrawTextAtIndex(CSW_6TH_COLUMN, y, STR_MMMINV, 0, menuHorizontalPosition==LS_FIELD_DELAY ? attr : 0); } if (s_editMode>0 && attr) { - switch (horz) { + switch (menuHorizontalPosition) { case LS_FIELD_FUNCTION: { cs->func = checkIncDec(event, cs->func, 0, LS_FUNC_MAX, EE_MODEL, isLogicalSwitchFunctionAvailable); diff --git a/radio/src/gui/horus/menus.h b/radio/src/gui/horus/menus.h index bb0ee42db..67162675c 100644 --- a/radio/src/gui/horus/menus.h +++ b/radio/src/gui/horus/menus.h @@ -515,9 +515,7 @@ void pushModelNotes(); #define CURSOR_MOVED_LEFT(event) (event==EVT_ROTARY_LEFT || EVT_KEY_MASK(event) == KEY_LEFT) #define CURSOR_MOVED_RIGHT(event) (event==EVT_ROTARY_RIGHT || EVT_KEY_MASK(event) == KEY_RIGHT) - -#define REPEAT_LAST_CURSOR_MOVE(defaultPosition) { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else menuHorizontalPosition = (defaultPosition); } -#define MOVE_CURSOR_FROM_HERE() if (menuHorizontalPosition > 0) REPEAT_LAST_CURSOR_MOVE(0) +#define REPEAT_LAST_CURSOR_MOVE(last, refresh) { if (CURSOR_MOVED_RIGHT(event)) menuHorizontalPosition = (menuHorizontalPosition >= (last) ? 0 : menuHorizontalPosition + 1); else menuHorizontalPosition = (menuHorizontalPosition <= (0) ? last : menuHorizontalPosition - 1); if (refresh) putEvent(EVT_REFRESH); } #define MENU_FIRST_LINE_EDIT (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0) #define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0) diff --git a/radio/src/gui/horus/model_special_functions.cpp b/radio/src/gui/horus/model_special_functions.cpp index 273dcfec1..ccd8e6f67 100644 --- a/radio/src/gui/horus/model_special_functions.cpp +++ b/radio/src/gui/horus/model_special_functions.cpp @@ -29,16 +29,15 @@ void onCustomFunctionsFileSelectionMenu(const char * result) { - int sub = menuVerticalPosition; CustomFunctionData * cf; uint8_t eeFlags; if (menuHandlers[menuLevel] == menuModelCustomFunctions) { - cf = &g_model.customFn[sub]; + cf = &g_model.customFn[menuVerticalPosition]; eeFlags = EE_MODEL; } else { - cf = &g_eeGeneral.customFn[sub]; + cf = &g_eeGeneral.customFn[menuVerticalPosition]; eeFlags = EE_GENERAL; } @@ -69,16 +68,15 @@ void onCustomFunctionsFileSelectionMenu(const char * result) void onCustomFunctionsMenu(const char *result) { - int sub = menuVerticalPosition; CustomFunctionData * cfn; uint8_t eeFlags; if (menuHandlers[menuLevel] == menuModelCustomFunctions) { - cfn = &g_model.customFn[sub]; + cfn = &g_model.customFn[menuVerticalPosition]; eeFlags = EE_MODEL; } else { - cfn = &g_eeGeneral.customFn[sub]; + cfn = &g_eeGeneral.customFn[menuVerticalPosition]; eeFlags = EE_GENERAL; } @@ -95,12 +93,12 @@ void onCustomFunctionsMenu(const char *result) storageDirty(eeFlags); } else if (result == STR_INSERT) { - memmove(cfn+1, cfn, (NUM_CFN-sub-1)*sizeof(CustomFunctionData)); + memmove(cfn+1, cfn, (NUM_CFN-menuVerticalPosition-1)*sizeof(CustomFunctionData)); memset(cfn, 0, sizeof(CustomFunctionData)); storageDirty(eeFlags); } else if (result == STR_DELETE) { - memmove(cfn, cfn+1, (NUM_CFN-sub-1)*sizeof(CustomFunctionData)); + memmove(cfn, cfn+1, (NUM_CFN-menuVerticalPosition-1)*sizeof(CustomFunctionData)); memset(&g_model.customFn[NUM_CFN-1], 0, sizeof(CustomFunctionData)); storageDirty(eeFlags); } @@ -135,15 +133,23 @@ void onAdjustGvarSourceLongEnterPress(const char * result) } } +enum SpecialFunctionsItems { + ITEM_SPECIAL_FUNCTIONS_SWITCH, + ITEM_SPECIAL_FUNCTIONS_FUNCTION, + ITEM_SPECIAL_FUNCTIONS_PARAM, + ITEM_SPECIAL_FUNCTIONS_VALUE, + ITEM_SPECIAL_FUNCTIONS_ENABLE, + ITEM_SPECIAL_FUNCTIONS_COUNT, + ITEM_SPECIAL_FUNCTIONS_LAST = ITEM_SPECIAL_FUNCTIONS_COUNT-1 +}; + bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext) { - uint32_t sub = menuVerticalPosition; - uint8_t eeFlags = (functions == g_model.customFn) ? EE_MODEL : EE_GENERAL; if (menuHorizontalPosition<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { killEvents(event); - CustomFunctionData *cfn = &functions[sub]; + CustomFunctionData *cfn = &functions[menuVerticalPosition]; if (!CFN_EMPTY(cfn)) POPUP_MENU_ADD_ITEM(STR_COPY); if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_FUNCTION) @@ -152,7 +158,7 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc POPUP_MENU_ADD_ITEM(STR_INSERT); if (!CFN_EMPTY(cfn)) POPUP_MENU_ADD_ITEM(STR_CLEAR); - for (int i=sub+1; i0) ? BLINK|INVERS : INVERS) : 0); + for (int j=0; j0) ? BLINK|INVERS : INVERS) : 0); LcdFlags active = (attr && s_editMode>0); switch (j) { - case 0: + case ITEM_SPECIAL_FUNCTIONS_SWITCH: if (active || AUTOSWITCH_ENTER_LONG()) { CHECK_INCDEC_SWITCH(event, CFN_SWITCH(cfn), SWSRC_FIRST, SWSRC_LAST, eeFlags, isSwitchAvailableInCustomFunctions); } putsSwitches(MODEL_SPECIAL_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | ((functionsContext.activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); break; - case 1: + case ITEM_SPECIAL_FUNCTIONS_FUNCTION: if (CFN_SWITCH(cfn)) { if (active) { func = CFN_FUNC(cfn) = checkIncDec(event, CFN_FUNC(cfn), 0, FUNC_MAX-1, eeFlags, isAssignableFunctionAvailable); @@ -189,14 +195,14 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc lcdDrawTextAtIndex(MODEL_SPECIAL_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr); } else { - j = 4; // skip other fields - if (sub==k && menuHorizontalPosition > 0) { - REPEAT_LAST_CURSOR_MOVE(0); + j = ITEM_SPECIAL_FUNCTIONS_ENABLE; // skip other fields + while (menuVerticalPosition==k && menuHorizontalPosition > 0) { + REPEAT_LAST_CURSOR_MOVE(ITEM_SPECIAL_FUNCTIONS_LAST, true); } } break; - case 2: + case ITEM_SPECIAL_FUNCTIONS_PARAM: { int8_t maxParam = NUM_CHNOUT-1; #if defined(OVERRIDE_CHANNEL_FUNCTION) @@ -224,13 +230,13 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc break; } else if (attr) { - REPEAT_LAST_CURSOR_MOVE(0); + REPEAT_LAST_CURSOR_MOVE(ITEM_SPECIAL_FUNCTIONS_LAST, true); } if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_INDEX(cfn), maxParam); break; } - case 3: + case ITEM_SPECIAL_FUNCTIONS_VALUE: { INCDEC_DECLARE_VARS(eeFlags); int16_t val_displayed = CFN_PARAM(cfn); @@ -357,7 +363,7 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc } #endif else if (attr) { - REPEAT_LAST_CURSOR_MOVE(0); + REPEAT_LAST_CURSOR_MOVE(ITEM_SPECIAL_FUNCTIONS_LAST, true); } if (active || event==EVT_KEY_LONG(KEY_ENTER)) { @@ -379,7 +385,7 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc break; } - case 4: + case ITEM_SPECIAL_FUNCTIONS_ENABLE: if (HAS_ENABLE_PARAM(func)) { if (active) CFN_ACTIVE(cfn) = checkIncDec(event, CFN_ACTIVE(cfn), 0, 1, eeFlags); drawCheckBox(MODEL_SPECIAL_FUNC_4TH_COLUMN_ONOFF, y, CFN_ACTIVE(cfn), attr); @@ -397,7 +403,7 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc } } else if (attr) { - REPEAT_LAST_CURSOR_MOVE(0); + REPEAT_LAST_CURSOR_MOVE(ITEM_SPECIAL_FUNCTIONS_LAST, true); } break; }