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 max permissible CMS rows and up/down page arrows (#12277) #12284

Merged
merged 1 commit into from
Feb 2, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/main/cms/cms.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ bool cmsDisplayPortSelect(displayPort_t *instance)
// 13 cols x 9 rows, top row printed as a Bold Heading
// Needs the "smallScreen" adaptions

#define CMS_MAX_ROWS 16
#define CMS_MAX_ROWS 31
blckmn marked this conversation as resolved.
Show resolved Hide resolved

#define NORMAL_SCREEN_MIN_COLS 18 // Less is a small screen
#define NORMAL_SCREEN_MAX_COLS 30 // More is a large screen
static bool smallScreen;
static uint8_t leftMenuColumn;
static uint8_t rightMenuColumn;
Expand Down Expand Up @@ -810,11 +811,11 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
// simple text device and use the '^' (carat) and 'V' for arrow approximations.
if (displayWasCleared && leftMenuColumn > 0) { // make sure there's room to draw the symbol
if (currentCtx.page > 0) {
const uint8_t symbol = displaySupportsOsdSymbols(pDisplay) ? SYM_ARROW_NORTH : '^';
const uint8_t symbol = displaySupportsOsdSymbols(pDisplay) ? SYM_ARROW_SMALL_UP : '^';
displayWriteChar(pDisplay, leftMenuColumn - 1, top, DISPLAYPORT_ATTR_NORMAL, symbol);
}
if (currentCtx.page < pageCount - 1) {
const uint8_t symbol = displaySupportsOsdSymbols(pDisplay) ? SYM_ARROW_SOUTH : 'V';
const uint8_t symbol = displaySupportsOsdSymbols(pDisplay) ? SYM_ARROW_SMALL_DOWN : 'v';
displayWriteChar(pDisplay, leftMenuColumn - 1, top + pageMaxRow, DISPLAYPORT_ATTR_NORMAL, symbol);
}
}
Expand Down Expand Up @@ -936,12 +937,21 @@ void cmsMenuOpen(void)
} else {
smallScreen = false;
linesPerMenuItem = 1;
leftMenuColumn = (pCurrentDisplay->cols / 2) - 13;
if (pCurrentDisplay->cols <= NORMAL_SCREEN_MAX_COLS) {
leftMenuColumn = 2;
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
rightMenuColumn = (pCurrentDisplay->cols / 2) + 13;
rightMenuColumn = pCurrentDisplay->cols - 2;
#else
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
#endif
} else {
leftMenuColumn = (pCurrentDisplay->cols / 2) - 13;
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
rightMenuColumn = (pCurrentDisplay->cols / 2) + 13;
#else
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
#endif
}
maxMenuItems = pCurrentDisplay->rows - 2;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/io/displayport_crsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static int crsfWriteString(displayPort_t *displayPort, uint8_t col, uint8_t row,

static int crsfWriteChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint8_t attr, uint8_t c)
{
char s[1];
char s[2];
tfp_sprintf(s, "%c", c);
return crsfWriteString(displayPort, col, row, attr, s);
}
Expand Down