1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 12:25:20 +03:00

Merge pull request #10062 from mikeller/fix_cms_lockup

Fixed lockup when entering CMS.
This commit is contained in:
Michael Keller 2020-08-11 23:09:09 +12:00 committed by GitHub
commit 77ceda89c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -358,13 +358,15 @@ static void cmsPadToSize(char *buf, int size)
static int cmsDisplayWrite(displayPort_t *instance, uint8_t x, uint8_t y, uint8_t attr, const char *s) static int cmsDisplayWrite(displayPort_t *instance, uint8_t x, uint8_t y, uint8_t attr, const char *s)
{ {
uint8_t *c = (uint8_t*)s; char buffer[strlen(s) + 1];
const uint8_t *cEnd = c + strlen(s); char* b = buffer;
for (; c != cEnd; c++) { while (*s) {
*c = toupper(*c); // uppercase only char c = toupper(*s++);
*c = (*c < 0x20 || *c > 0x5F) ? ' ' : *c; // limit to alphanumeric and punctuation *b++ = (c < 0x20 || c > 0x5F) ? ' ' : c; // limit to alphanumeric and punctuation
} }
return displayWrite(instance, x, y, attr, s); *b++ = '\0';
return displayWrite(instance, x, y, attr, buffer);
} }
static int cmsDrawMenuItemValue(displayPort_t *pDisplay, char *buff, uint8_t row, uint8_t maxSize) static int cmsDrawMenuItemValue(displayPort_t *pDisplay, char *buff, uint8_t row, uint8_t maxSize)
@ -543,9 +545,9 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
// Shouldn't happen. Notify creator of this menu content // Shouldn't happen. Notify creator of this menu content
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES #ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
cnt = displayWrite(pDisplay, rightMenuColumn - 6, row, DISPLAYPORT_ATTR_NONE, "BADENT"); cnt = cmsDisplayWrite(pDisplay, rightMenuColumn - 6, row, DISPLAYPORT_ATTR_NONE, "BADENT");
#else #else
cnt = displayWrite(pDisplay, rightMenuColumn, row, DISPLAYPORT_ATTR_NONE, "BADENT"); cnt = cmsDisplayWrite(pDisplay, rightMenuColumn, row, DISPLAYPORT_ATTR_NONE, "BADENT");
#endif #endif
#endif #endif
break; break;
@ -653,7 +655,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
#endif #endif
if (pDisplay->cursorRow >= 0 && currentCtx.cursorRow != pDisplay->cursorRow) { if (pDisplay->cursorRow >= 0 && currentCtx.cursorRow != pDisplay->cursorRow) {
room -= displayWrite(pDisplay, leftMenuColumn, top + pDisplay->cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, " "); room -= cmsDisplayWrite(pDisplay, leftMenuColumn, top + pDisplay->cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, " ");
} }
if (room < 30) { if (room < 30) {
@ -661,7 +663,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
} }
if (pDisplay->cursorRow != currentCtx.cursorRow) { if (pDisplay->cursorRow != currentCtx.cursorRow) {
room -= displayWrite(pDisplay, leftMenuColumn, top + currentCtx.cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, ">"); room -= cmsDisplayWrite(pDisplay, leftMenuColumn, top + currentCtx.cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, ">");
pDisplay->cursorRow = currentCtx.cursorRow; pDisplay->cursorRow = currentCtx.cursorRow;
} }
@ -877,7 +879,7 @@ const void *cmsMenuExit(displayPort_t *pDisplay, const void *ptr)
if ((exitType == CMS_EXIT_SAVEREBOOT) || (exitType == CMS_POPUP_SAVEREBOOT) || (exitType == CMS_POPUP_EXITREBOOT)) { if ((exitType == CMS_EXIT_SAVEREBOOT) || (exitType == CMS_POPUP_SAVEREBOOT) || (exitType == CMS_POPUP_EXITREBOOT)) {
displayClearScreen(pDisplay); displayClearScreen(pDisplay);
displayWrite(pDisplay, 5, 3, DISPLAYPORT_ATTR_NONE, "REBOOTING..."); cmsDisplayWrite(pDisplay, 5, 3, DISPLAYPORT_ATTR_NONE, "REBOOTING...");
// Flush display // Flush display
displayRedraw(pDisplay); displayRedraw(pDisplay);