Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bw): multiple issues with menu navigation for 9X type radios #4884

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion radio/src/gui/128x64/model_flightmodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void menuModelFlightModeOne(event_t event)
#endif
0, 0,(uint8_t)-1, 2, 2, 2, 2, 2};

check(event, 0, nullptr, 0, (s_currIdx == 0) ? mstate_tab_fm1 : mstate_tab_others, DIM(mstate_tab_others)-1, ITEM_MODEL_FLIGHT_MODE_MAX - HEADER_LINE - (s_currIdx==0 ? (ITEM_MODEL_FLIGHT_MODE_FADE_IN-ITEM_MODEL_FLIGHT_MODE_SWITCH-TRIMS_LINES) : 0));
check(event, 0, nullptr, 0, (s_currIdx == 0) ? mstate_tab_fm1 : mstate_tab_others, DIM(mstate_tab_others)-1, ITEM_MODEL_FLIGHT_MODE_MAX - (s_currIdx==0 ? (ITEM_MODEL_FLIGHT_MODE_FADE_IN-ITEM_MODEL_FLIGHT_MODE_SWITCH-TRIMS_LINES) : 0));

title(STR_MENUFLIGHTMODE);

Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/128x64/model_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void menuModelSelect(event_t event)

int8_t oldSub = menuVerticalPosition;

check_submenu_simple(_event_, MAX_MODELS - HEADER_LINE);
check_submenu_simple(_event_, MAX_MODELS);

if (s_editMode > 0) s_editMode = 0;

Expand Down
4 changes: 4 additions & 0 deletions radio/src/gui/common/stdlcd/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
MenuHandlerFunc menuHandlers[5];
event_t menuEvent = 0;
uint8_t menuVerticalPositions[4];
uint8_t menuVerticalOffsets[4];
uint8_t menuLevel = 0;

void popMenu()
{
killEvents(KEY_EXIT);

assert(menuLevel > 0);
menuLevel = menuLevel - 1;
menuEvent = EVT_ENTRY_UP;
Expand Down Expand Up @@ -63,6 +66,7 @@ void pushMenu(MenuHandlerFunc newMenu)
else {
menuVerticalPositions[menuLevel] = menuVerticalPosition;
}
menuVerticalOffsets[menuLevel] = menuVerticalOffset;

menuLevel++;

Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/common/stdlcd/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern vertpos_t menuVerticalOffset;
extern uint8_t menuCalibrationState;
extern MenuHandlerFunc menuHandlers[5];
extern uint8_t menuVerticalPositions[4];
extern uint8_t menuVerticalOffsets[4];
extern uint8_t menuLevel;
extern event_t menuEvent;

Expand Down
7 changes: 4 additions & 3 deletions radio/src/gui/navigation/navigation_9x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,

tmr10ms_t menuEntryTime;

#define MAXCOL(row) (horTab ? *(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0)
#define MAXCOL_RAW(row) (horTab ? *(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0)
#define MAXCOL(row) (MAXCOL_RAW(row) >= HIDDEN_ROW ? MAXCOL_RAW(row) : (const uint8_t)(MAXCOL_RAW(row) & (~NAVIGATION_LINE_BY_LINE)))
#define POS_HORZ_INIT(posVert) 0

uint8_t chgMenu(uint8_t curr, const MenuHandler * menuTab, uint8_t menuTabSize, int direction)
Expand Down Expand Up @@ -272,7 +273,7 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab,
case EVT_KEY_FIRST(KEY_DOWN):
if (s_editMode>0) break;
do {
INC(l_posVert, 0, maxrow);
INC(l_posVert, 0, maxrow - 1);
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
l_posHorz = min<horzpos_t>(l_posHorz, MAXCOL(l_posVert));
break;
Expand All @@ -293,7 +294,7 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab,
if (s_editMode>0) break;

do {
DEC(l_posVert, 0, maxrow);
DEC(l_posVert, 0, maxrow - 1);
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
l_posHorz = min((uint8_t)l_posHorz, MAXCOL(l_posVert));
break;
Expand Down
4 changes: 2 additions & 2 deletions radio/src/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ inline bool IS_KEY_EVT(event_t evt, uint8_t key)

inline bool IS_NEXT_EVENT(event_t evt)
{
return evt == EVT_KEY_FIRST(KEY_DOWN) || evt == EVT_KEY_REPT(KEY_DOWN) ||
return evt == EVT_KEY_FIRST(KEY_RIGHT) || evt == EVT_KEY_REPT(KEY_RIGHT) ||
evt == EVT_KEY_FIRST(KEY_MINUS) || evt == EVT_KEY_REPT(KEY_MINUS) ||
evt == EVT_ROTARY_RIGHT;
}

inline bool IS_PREVIOUS_EVENT(event_t evt)
{
return evt == EVT_KEY_FIRST(KEY_UP) || evt == EVT_KEY_REPT(KEY_UP) ||
return evt == EVT_KEY_FIRST(KEY_LEFT) || evt == EVT_KEY_REPT(KEY_LEFT) ||
Copy link
Member

@pfeerick pfeerick Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, why did you change this? As up/down was correct for popup menu navigation on the t-lite (and also the LR3pro I think). Hence #4917, although depending on the reason it may need to remove this change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix the left right scrolling on the SF/GF page for 9x nav - I fixed this first and meant to come back and check that it did not affect other things (which it clearly did). Thanks for picking it up - the fix in 4917 looks better.

Copy link
Member

@pfeerick pfeerick Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought that might be the case when digging a bit deeper... I suspect it is has been broken somewhere else, but that should hopefully do for now to make most all the use cases work. 🤞 Will need revisiting in the future though as the popup menus should't be responding to sideways keys, hence the real 🐛 is somewhere else 🤪

evt == EVT_KEY_FIRST(KEY_PLUS) || evt == EVT_KEY_REPT(KEY_PLUS) ||
evt == EVT_ROTARY_LEFT;
}
Expand Down
10 changes: 8 additions & 2 deletions radio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,14 @@ void guiMain(event_t evt)

if (menuEvent) {
// we have a popupMenuActive entry or exit event
menuVerticalPosition =
(menuEvent == EVT_ENTRY_UP) ? menuVerticalPositions[menuLevel] : 0;
if (menuEvent == EVT_ENTRY_UP) {
menuVerticalPosition = menuVerticalPositions[menuLevel];
menuVerticalOffset = menuVerticalOffsets[menuLevel];
} else {
menuVerticalPosition = 0;
menuVerticalOffset = 0;
}

menuHorizontalPosition = 0;
evt = menuEvent;
menuEvent = 0;
Expand Down