mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 01:35:41 +03:00
Merge pull request #9746 from codecae/crsf_cms_compression
CMS over CRSF compression
This commit is contained in:
commit
944eb989d5
4 changed files with 106 additions and 32 deletions
|
@ -356,6 +356,17 @@ static void cmsPadToSize(char *buf, int size)
|
|||
#endif
|
||||
}
|
||||
|
||||
static int cmsDisplayWrite(displayPort_t *instance, uint8_t x, uint8_t y, uint8_t attr, const char *s)
|
||||
{
|
||||
uint8_t *c = (uint8_t*)s;
|
||||
const uint8_t *cEnd = c + strlen(s);
|
||||
for (; c != cEnd; c++) {
|
||||
*c = toupper(*c); // uppercase only
|
||||
*c = (*c < 0x20 || *c > 0x5F) ? ' ' : *c; // limit to alphanumeric and punctuation
|
||||
}
|
||||
return displayWrite(instance, x, y, attr, s);
|
||||
}
|
||||
|
||||
static int cmsDrawMenuItemValue(displayPort_t *pDisplay, char *buff, uint8_t row, uint8_t maxSize)
|
||||
{
|
||||
int colpos;
|
||||
|
@ -367,7 +378,7 @@ static int cmsDrawMenuItemValue(displayPort_t *pDisplay, char *buff, uint8_t row
|
|||
#else
|
||||
colpos = smallScreen ? rightMenuColumn - maxSize : rightMenuColumn;
|
||||
#endif
|
||||
cnt = displayWrite(pDisplay, colpos, row, DISPLAYPORT_ATTR_NONE, buff);
|
||||
cnt = cmsDisplayWrite(pDisplay, colpos, row, DISPLAYPORT_ATTR_NONE, buff);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
@ -516,7 +527,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t
|
|||
case OME_Label:
|
||||
if (IS_PRINTVALUE(*flags) && p->data) {
|
||||
// A label with optional string, immediately following text
|
||||
cnt = displayWrite(pDisplay, leftMenuColumn + 1 + (uint8_t)strlen(p->text), row, DISPLAYPORT_ATTR_NONE, p->data);
|
||||
cnt = cmsDisplayWrite(pDisplay, leftMenuColumn + 1 + (uint8_t)strlen(p->text), row, DISPLAYPORT_ATTR_NONE, p->data);
|
||||
CLR_PRINTVALUE(*flags);
|
||||
}
|
||||
break;
|
||||
|
@ -672,7 +683,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
|
|||
if (IS_PRINTLABEL(runtimeEntryFlags[i])) {
|
||||
uint8_t coloff = leftMenuColumn;
|
||||
coloff += (p->type == OME_Label) ? 0 : 1;
|
||||
room -= displayWrite(pDisplay, coloff, top + i * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, p->text);
|
||||
room -= cmsDisplayWrite(pDisplay, coloff, top + i * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, p->text);
|
||||
CLR_PRINTLABEL(runtimeEntryFlags[i]);
|
||||
if (room < 30) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue