mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 07:15:18 +03:00
Fix max permissible CMS rows and up/down page arrows (#12277)
* Fix max permissible CMS rows and up/down page arrows * For CMS displays of 30 columns or less shrink width of menu to fit * Fix string overflow * Use 'v' for down arrow rather than 'V' as it's less ugly as devices without OSD character set can display lower case
This commit is contained in:
parent
33a96bb5f6
commit
e5cd2cad7b
2 changed files with 17 additions and 7 deletions
|
@ -161,9 +161,10 @@ bool cmsDisplayPortSelect(displayPort_t *instance)
|
||||||
// 13 cols x 9 rows, top row printed as a Bold Heading
|
// 13 cols x 9 rows, top row printed as a Bold Heading
|
||||||
// Needs the "smallScreen" adaptions
|
// Needs the "smallScreen" adaptions
|
||||||
|
|
||||||
#define CMS_MAX_ROWS 16
|
#define CMS_MAX_ROWS 31
|
||||||
|
|
||||||
#define NORMAL_SCREEN_MIN_COLS 18 // Less is a small screen
|
#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 bool smallScreen;
|
||||||
static uint8_t leftMenuColumn;
|
static uint8_t leftMenuColumn;
|
||||||
static uint8_t rightMenuColumn;
|
static uint8_t rightMenuColumn;
|
||||||
|
@ -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.
|
// 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 (displayWasCleared && leftMenuColumn > 0) { // make sure there's room to draw the symbol
|
||||||
if (currentCtx.page > 0) {
|
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);
|
displayWriteChar(pDisplay, leftMenuColumn - 1, top, DISPLAYPORT_ATTR_NORMAL, symbol);
|
||||||
}
|
}
|
||||||
if (currentCtx.page < pageCount - 1) {
|
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);
|
displayWriteChar(pDisplay, leftMenuColumn - 1, top + pageMaxRow, DISPLAYPORT_ATTR_NORMAL, symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -936,12 +937,21 @@ void cmsMenuOpen(void)
|
||||||
} else {
|
} else {
|
||||||
smallScreen = false;
|
smallScreen = false;
|
||||||
linesPerMenuItem = 1;
|
linesPerMenuItem = 1;
|
||||||
|
if (pCurrentDisplay->cols <= NORMAL_SCREEN_MAX_COLS) {
|
||||||
|
leftMenuColumn = 2;
|
||||||
|
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
|
||||||
|
rightMenuColumn = pCurrentDisplay->cols - 2;
|
||||||
|
#else
|
||||||
|
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
leftMenuColumn = (pCurrentDisplay->cols / 2) - 13;
|
leftMenuColumn = (pCurrentDisplay->cols / 2) - 13;
|
||||||
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
|
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
|
||||||
rightMenuColumn = (pCurrentDisplay->cols / 2) + 13;
|
rightMenuColumn = (pCurrentDisplay->cols / 2) + 13;
|
||||||
#else
|
#else
|
||||||
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
|
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
maxMenuItems = pCurrentDisplay->rows - 2;
|
maxMenuItems = pCurrentDisplay->rows - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
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);
|
tfp_sprintf(s, "%c", c);
|
||||||
return crsfWriteString(displayPort, col, row, attr, s);
|
return crsfWriteString(displayPort, col, row, attr, s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue