1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-26 09:45:37 +03:00

Add up/down page indicator to CMS menu display

Often the user doesn't realize that there are more menu items then displayed and the only way to tell was to try and move the selection to the bottom to see if another page appears.

This PR adds page up/down indicators if there are more menu items than those visible on the current display.

Uses the OSD arrow symbols when possible (for OSD supporting devices), otherwise the `^` (carat) and `V` are used for text-only represenatations.

To determine if the device was capable of displaying symbols the `displayPort` structure has a new `deviceType` set when it is initialized. There have been other times when knowing the type of device would have been useful so that's now supported. Then this is abstracted by a new `displaySupportsOsdSymbols()` function. Devices that support OSD are assumed to support the OSD symbols as the OSD element drawing code always uses them. For devices that don't support OSD function we have to presume the sybols aren't available.
This commit is contained in:
Bruce Luckcuck 2021-01-16 13:29:35 -05:00
parent 35de1c8229
commit 07598d824c
11 changed files with 60 additions and 14 deletions

View file

@ -51,9 +51,10 @@
#include "config/config.h"
#include "config/feature.h"
#include "drivers/motor.h"
#include "drivers/osd_symbols.h"
#include "drivers/system.h"
#include "drivers/time.h"
#include "drivers/motor.h"
#include "fc/rc_controls.h"
#include "fc/runtime_config.h"
@ -671,10 +672,13 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
return;
}
const bool displayWasCleared = pDisplay->cleared;
uint8_t i;
const OSD_Entry *p;
uint8_t top = smallScreen ? 1 : (pDisplay->rows - pageMaxRow)/2;
pDisplay->cleared = false;
// Polled (dynamic) value display denominator.
bool drawPolled = false;
@ -687,12 +691,11 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
uint32_t room = displayTxBytesFree(pDisplay);
if (pDisplay->cleared) {
if (displayWasCleared) {
for (p = pageTop, i= 0; (p <= pageTop + pageMaxRow); p++, i++) {
SET_PRINTLABEL(runtimeEntryFlags[i]);
SET_PRINTVALUE(runtimeEntryFlags[i]);
}
pDisplay->cleared = false;
} else if (drawPolled) {
for (p = pageTop, i = 0; (p <= pageTop + pageMaxRow); p++, i++) {
if (IS_DYNAMIC(p))
@ -761,6 +764,22 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
}
}
}
// Draw the up/down page indicators if the display has space.
// Only draw the symbols when necessary after the screen has been cleared. Otherwise they're static.
// If the device supports OSD symbols then use the up/down arrows. Otherwise assume it's a
// 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 : '^';
displayWriteChar(pDisplay, leftMenuColumn - 1, top, DISPLAYPORT_ATTR_NONE, symbol);
}
if (currentCtx.page < pageCount - 1) {
const uint8_t symbol = displaySupportsOsdSymbols(pDisplay) ? SYM_ARROW_SOUTH : 'V';
displayWriteChar(pDisplay, leftMenuColumn - 1, top + pageMaxRow, DISPLAYPORT_ATTR_NONE, symbol);
}
}
}
const void *cmsMenuChange(displayPort_t *pDisplay, const void *ptr)