1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 14:55:21 +03:00

Fixed lockup when entering CMS.

This commit is contained in:
mikeller 2020-07-30 02:41:02 +12:00
parent b1af9befe5
commit d8e3aa7e2d

View file

@ -358,13 +358,14 @@ 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[40];
const uint8_t *cEnd = c + strlen(s); unsigned index = 0;
for (; c != cEnd; c++) { for (; index < strlen(s); index++) {
*c = toupper(*c); // uppercase only buffer[index] = toupper(s[index]); // uppercase only
*c = (*c < 0x20 || *c > 0x5F) ? ' ' : *c; // limit to alphanumeric and punctuation buffer[index] = (buffer[index] < 0x20 || buffer[index] > 0x5F) ? ' ' : buffer[index]; // limit to alphanumeric and punctuation
} }
return displayWrite(instance, x, y, attr, s); buffer[index] = 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 +544,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 +654,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 +662,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 +878,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);