1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 21:35:44 +03:00

Apply OSD severity (#11996)

This commit is contained in:
Steve Evans 2022-11-20 11:24:09 +00:00 committed by GitHub
parent 18751f5875
commit c508b6644d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 143 additions and 61 deletions

View file

@ -1525,7 +1525,7 @@ const clivalue_t valueTable[] = {
#ifdef USE_MSP_DISPLAYPORT #ifdef USE_MSP_DISPLAYPORT
{ "displayport_msp_col_adjust", VAR_INT8 | MASTER_VALUE, .config.minmax = { -6, 0 }, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, colAdjust) }, { "displayport_msp_col_adjust", VAR_INT8 | MASTER_VALUE, .config.minmax = { -6, 0 }, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, colAdjust) },
{ "displayport_msp_row_adjust", VAR_INT8 | MASTER_VALUE, .config.minmax = { -3, 0 }, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, rowAdjust) }, { "displayport_msp_row_adjust", VAR_INT8 | MASTER_VALUE, .config.minmax = { -3, 0 }, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, rowAdjust) },
{ "displayport_msp_attrs", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 4, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, attrValues) }, { "displayport_msp_fonts", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 4, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, fontSelection) },
{ "displayport_msp_use_device_blink", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, useDeviceBlink) }, { "displayport_msp_use_device_blink", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, useDeviceBlink) },
#endif #endif

View file

@ -389,7 +389,7 @@ static int cmsDrawMenuItemValue(displayPort_t *pDisplay, char *buff, uint8_t row
#else #else
colpos = smallScreen ? rightMenuColumn - maxSize : rightMenuColumn; colpos = smallScreen ? rightMenuColumn - maxSize : rightMenuColumn;
#endif #endif
cnt = cmsDisplayWrite(pDisplay, colpos, row, DISPLAYPORT_ATTR_NONE, buff); cnt = cmsDisplayWrite(pDisplay, colpos, row, DISPLAYPORT_ATTR_NORMAL, buff);
return cnt; return cnt;
} }
@ -590,7 +590,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t
case OME_Label: case OME_Label:
if (IS_PRINTVALUE(*flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
// A label with optional string, immediately following text // A label with optional string, immediately following text
cnt = cmsDisplayWrite(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_NORMAL, p->data);
CLR_PRINTVALUE(*flags); CLR_PRINTVALUE(*flags);
} }
break; break;
@ -606,9 +606,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 = cmsDisplayWrite(pDisplay, rightMenuColumn - 6, row, DISPLAYPORT_ATTR_NONE, "BADENT"); cnt = cmsDisplayWrite(pDisplay, rightMenuColumn - 6, row, DISPLAYPORT_ATTR_NORMAL, "BADENT");
#else #else
cnt = cmsDisplayWrite(pDisplay, rightMenuColumn, row, DISPLAYPORT_ATTR_NONE, "BADENT"); cnt = cmsDisplayWrite(pDisplay, rightMenuColumn, row, DISPLAYPORT_ATTR_NORMAL, "BADENT");
#endif #endif
#endif #endif
break; break;
@ -747,7 +747,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 -= cmsDisplayWrite(pDisplay, leftMenuColumn, top + pDisplay->cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, " "); room -= cmsDisplayWrite(pDisplay, leftMenuColumn, top + pDisplay->cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NORMAL, " ");
} }
if (room < 30) { if (room < 30) {
@ -755,7 +755,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
} }
if (pDisplay->cursorRow != currentCtx.cursorRow) { if (pDisplay->cursorRow != currentCtx.cursorRow) {
room -= cmsDisplayWrite(pDisplay, leftMenuColumn, top + currentCtx.cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, ">"); room -= cmsDisplayWrite(pDisplay, leftMenuColumn, top + currentCtx.cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NORMAL, ">");
pDisplay->cursorRow = currentCtx.cursorRow; pDisplay->cursorRow = currentCtx.cursorRow;
} }
@ -777,7 +777,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
if (IS_PRINTLABEL(runtimeEntryFlags[i])) { if (IS_PRINTLABEL(runtimeEntryFlags[i])) {
uint8_t coloff = leftMenuColumn; uint8_t coloff = leftMenuColumn;
coloff += ((p->flags & OSD_MENU_ELEMENT_MASK) == OME_Label) ? 0 : 1; coloff += ((p->flags & OSD_MENU_ELEMENT_MASK) == OME_Label) ? 0 : 1;
room -= cmsDisplayWrite(pDisplay, coloff, top + i * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, p->text); room -= cmsDisplayWrite(pDisplay, coloff, top + i * linesPerMenuItem, DISPLAYPORT_ATTR_NORMAL, p->text);
CLR_PRINTLABEL(runtimeEntryFlags[i]); CLR_PRINTLABEL(runtimeEntryFlags[i]);
if (room < 30) { if (room < 30) {
return; return;
@ -787,7 +787,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
// Highlight values overridden by sliders // Highlight values overridden by sliders
if (rowSliderOverride(p->flags)) { if (rowSliderOverride(p->flags)) {
displayWriteChar(pDisplay, leftMenuColumn - 1, top + i * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, 'S'); displayWriteChar(pDisplay, leftMenuColumn - 1, top + i * linesPerMenuItem, DISPLAYPORT_ATTR_NORMAL, 'S');
} }
// Print values // Print values
@ -811,11 +811,11 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
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_NORTH : '^';
displayWriteChar(pDisplay, leftMenuColumn - 1, top, DISPLAYPORT_ATTR_NONE, 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_SOUTH : 'V';
displayWriteChar(pDisplay, leftMenuColumn - 1, top + pageMaxRow, DISPLAYPORT_ATTR_NONE, symbol); displayWriteChar(pDisplay, leftMenuColumn - 1, top + pageMaxRow, DISPLAYPORT_ATTR_NORMAL, symbol);
} }
} }
@ -1004,7 +1004,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, DISPLAY_CLEAR_WAIT); displayClearScreen(pDisplay, DISPLAY_CLEAR_WAIT);
cmsDisplayWrite(pDisplay, 5, 3, DISPLAYPORT_ATTR_NONE, "REBOOTING..."); cmsDisplayWrite(pDisplay, 5, 3, DISPLAYPORT_ATTR_NORMAL, "REBOOTING...");
// Flush display // Flush display
displayRedraw(pDisplay); displayRedraw(pDisplay);

View file

@ -31,13 +31,14 @@ typedef enum {
} displayPortDeviceType_e; } displayPortDeviceType_e;
typedef enum { typedef enum {
DISPLAYPORT_ATTR_NONE = 0, DISPLAYPORT_ATTR_NORMAL = 0,
DISPLAYPORT_ATTR_INFO, DISPLAYPORT_ATTR_INFO,
DISPLAYPORT_ATTR_WARNING, DISPLAYPORT_ATTR_WARNING,
DISPLAYPORT_ATTR_CRITICAL, DISPLAYPORT_ATTR_CRITICAL,
} displayPortAttr_e; DISPLAYPORT_ATTR_COUNT,
} displayPortSeverity_e;
#define DISPLAYPORT_ATTR_BLINK 0x80 // Device local blink bit or'ed into displayPortAttr_e #define DISPLAYPORT_ATTR_BLINK 0x80 // Device local blink bit or'ed into displayPortSeverity_e
// System elements rendered by VTX or Goggles // System elements rendered by VTX or Goggles
typedef enum { typedef enum {

View file

@ -56,7 +56,7 @@ static int hottWriteString(displayPort_t *displayPort, uint8_t col, uint8_t row,
UNUSED(attr); UNUSED(attr);
while (*s) { while (*s) {
hottWriteChar(displayPort, col++, row, DISPLAYPORT_ATTR_NONE, *(s++)); hottWriteChar(displayPort, col++, row, DISPLAYPORT_ATTR_NORMAL, *(s++));
} }
return 0; return 0;
} }
@ -67,7 +67,7 @@ static int hottClearScreen(displayPort_t *displayPort, displayClearOption_e opti
for (int row = 0; row < displayPort->rows; row++) { for (int row = 0; row < displayPort->rows; row++) {
for (int col= 0; col < displayPort->cols; col++) { for (int col= 0; col < displayPort->cols; col++) {
hottWriteChar(displayPort, col, row, DISPLAYPORT_ATTR_NONE, ' '); hottWriteChar(displayPort, col, row, DISPLAYPORT_ATTR_NORMAL, ' ');
} }
} }
return 0; return 0;

View file

@ -117,7 +117,7 @@ static int writeString(displayPort_t *displayPort, uint8_t col, uint8_t row, uin
buf[0] = MSP_DP_WRITE_STRING; buf[0] = MSP_DP_WRITE_STRING;
buf[1] = row; buf[1] = row;
buf[2] = col; buf[2] = col;
buf[3] = displayPortProfileMsp()->attrValues[attr] & ~DISPLAYPORT_MSP_ATTR_BLINK & DISPLAYPORT_MSP_ATTR_MASK; buf[3] = displayPortProfileMsp()->fontSelection[attr] & ~DISPLAYPORT_MSP_ATTR_BLINK & DISPLAYPORT_MSP_ATTR_MASK;
if (attr & DISPLAYPORT_ATTR_BLINK) { if (attr & DISPLAYPORT_ATTR_BLINK) {
buf[3] |= DISPLAYPORT_MSP_ATTR_BLINK; buf[3] |= DISPLAYPORT_MSP_ATTR_BLINK;
@ -146,7 +146,7 @@ static int writeChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint8
buf[0] = c; buf[0] = c;
buf[1] = 0; buf[1] = 0;
return writeString(displayPort, col, row, attr, buf); //!!TODO - check if there is a direct MSP command to do this return writeString(displayPort, col, row, attr, buf);
} }
static bool isTransferInProgress(const displayPort_t *displayPort) static bool isTransferInProgress(const displayPort_t *displayPort)

View file

@ -41,7 +41,7 @@ typedef enum {
// MSP displayport V2 attribute byte bit functions // MSP displayport V2 attribute byte bit functions
#define DISPLAYPORT_MSP_ATTR_VERSION BIT(7) // Format indicator; must be zero for V2 (and V1) #define DISPLAYPORT_MSP_ATTR_VERSION BIT(7) // Format indicator; must be zero for V2 (and V1)
#define DISPLAYPORT_MSP_ATTR_BLINK BIT(6) // Device local blink #define DISPLAYPORT_MSP_ATTR_BLINK BIT(6) // Device local blink
#define DISPLAYPORT_MSP_ATTR_FONT (BIT(0) | BIT(1)) // Select bank of 256 characters as per displayPortAttr_e #define DISPLAYPORT_MSP_ATTR_FONT (BIT(0) | BIT(1)) // Select bank of 256 characters as per displayPortSeverity_e
#define DISPLAYPORT_MSP_ATTR_MASK (~(DISPLAYPORT_MSP_ATTR_VERSION | DISPLAYPORT_MSP_ATTR_BLINK | DISPLAYPORT_MSP_ATTR_FONT)) #define DISPLAYPORT_MSP_ATTR_MASK (~(DISPLAYPORT_MSP_ATTR_VERSION | DISPLAYPORT_MSP_ATTR_BLINK | DISPLAYPORT_MSP_ATTR_FONT))
struct displayPort_s *displayPortMspInit(void); struct displayPort_s *displayPortMspInit(void);

View file

@ -71,15 +71,15 @@ static int srxlClearScreen(displayPort_t *displayPort, displayClearOption_e opti
UNUSED(options); UNUSED(options);
for (int row = 0; row < SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS; row++) { for (int row = 0; row < SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS; row++) {
for (int col= 0; col < SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS; col++) { for (int col= 0; col < SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS; col++) {
srxlWriteChar(displayPort, col, row, DISPLAYPORT_ATTR_NONE, ' '); srxlWriteChar(displayPort, col, row, DISPLAYPORT_ATTR_NORMAL, ' ');
} }
} }
srxlWriteString(displayPort, 1, 0, DISPLAYPORT_ATTR_NONE, "BETAFLIGHT"); srxlWriteString(displayPort, 1, 0, DISPLAYPORT_ATTR_NORMAL, "BETAFLIGHT");
if (displayPort->grabCount == 0) { if (displayPort->grabCount == 0) {
srxlWriteString(displayPort, 0, 2, DISPLAYPORT_ATTR_NONE, CMS_STARTUP_HELP_TEXT1); srxlWriteString(displayPort, 0, 2, DISPLAYPORT_ATTR_NORMAL, CMS_STARTUP_HELP_TEXT1);
srxlWriteString(displayPort, 2, 3, DISPLAYPORT_ATTR_NONE, CMS_STARTUP_HELP_TEXT2); srxlWriteString(displayPort, 2, 3, DISPLAYPORT_ATTR_NORMAL, CMS_STARTUP_HELP_TEXT2);
srxlWriteString(displayPort, 2, 4, DISPLAYPORT_ATTR_NONE, CMS_STARTUP_HELP_TEXT3); srxlWriteString(displayPort, 2, 4, DISPLAYPORT_ATTR_NORMAL, CMS_STARTUP_HELP_TEXT3);
} }
return 0; return 0;
} }

View file

@ -1314,7 +1314,7 @@ case MSP_NAME:
if (isBlinking) { if (isBlinking) {
displayAttr |= DISPLAYPORT_ATTR_BLINK; displayAttr |= DISPLAYPORT_ATTR_BLINK;
} }
sbufWriteU8(dst, displayAttr); // see displayPortAttr_e sbufWriteU8(dst, displayAttr); // see displayPortSeverity_e
sbufWriteU8(dst, warningsLen); // length byte followed by the actual characters sbufWriteU8(dst, warningsLen); // length byte followed by the actual characters
for (unsigned i = 0; i < warningsLen; i++) { for (unsigned i = 0; i < warningsLen; i++) {
sbufWriteU8(dst, warningsBuffer[i]); sbufWriteU8(dst, warningsBuffer[i]);

View file

@ -432,7 +432,7 @@ static void osdDrawLogo(int x, int y)
for (int row = 0; row < 4; row++) { for (int row = 0; row < 4; row++) {
for (int column = 0; column < 24; column++) { for (int column = 0; column < 24; column++) {
if (fontOffset <= SYM_END_OF_FONT) if (fontOffset <= SYM_END_OF_FONT)
displayWriteChar(osdDisplayPort, x + column, y + row, DISPLAYPORT_ATTR_NONE, fontOffset++); displayWriteChar(osdDisplayPort, x + column, y + row, DISPLAYPORT_ATTR_NORMAL, fontOffset++);
} }
} }
} }
@ -453,17 +453,17 @@ static void osdCompleteInitialization(void)
char string_buffer[30]; char string_buffer[30];
tfp_sprintf(string_buffer, "V%s", FC_VERSION_STRING); tfp_sprintf(string_buffer, "V%s", FC_VERSION_STRING);
displayWrite(osdDisplayPort, 20, 6, DISPLAYPORT_ATTR_NONE, string_buffer); displayWrite(osdDisplayPort, 20, 6, DISPLAYPORT_ATTR_NORMAL, string_buffer);
#ifdef USE_CMS #ifdef USE_CMS
displayWrite(osdDisplayPort, 7, 8, DISPLAYPORT_ATTR_NONE, CMS_STARTUP_HELP_TEXT1); displayWrite(osdDisplayPort, 7, 8, DISPLAYPORT_ATTR_NORMAL, CMS_STARTUP_HELP_TEXT1);
displayWrite(osdDisplayPort, 11, 9, DISPLAYPORT_ATTR_NONE, CMS_STARTUP_HELP_TEXT2); displayWrite(osdDisplayPort, 11, 9, DISPLAYPORT_ATTR_NORMAL, CMS_STARTUP_HELP_TEXT2);
displayWrite(osdDisplayPort, 11, 10, DISPLAYPORT_ATTR_NONE, CMS_STARTUP_HELP_TEXT3); displayWrite(osdDisplayPort, 11, 10, DISPLAYPORT_ATTR_NORMAL, CMS_STARTUP_HELP_TEXT3);
#endif #endif
#ifdef USE_RTC_TIME #ifdef USE_RTC_TIME
char dateTimeBuffer[FORMATTED_DATE_TIME_BUFSIZE]; char dateTimeBuffer[FORMATTED_DATE_TIME_BUFSIZE];
if (osdFormatRtcDateTime(&dateTimeBuffer[0])) { if (osdFormatRtcDateTime(&dateTimeBuffer[0])) {
displayWrite(osdDisplayPort, 5, 12, DISPLAYPORT_ATTR_NONE, dateTimeBuffer); displayWrite(osdDisplayPort, 5, 12, DISPLAYPORT_ATTR_NORMAL, dateTimeBuffer);
} }
#endif #endif
@ -679,9 +679,9 @@ static void osdGetBlackboxStatusString(char * buff)
static void osdDisplayStatisticLabel(uint8_t y, const char * text, const char * value) static void osdDisplayStatisticLabel(uint8_t y, const char * text, const char * value)
{ {
displayWrite(osdDisplayPort, 2, y, DISPLAYPORT_ATTR_NONE, text); displayWrite(osdDisplayPort, 2, y, DISPLAYPORT_ATTR_NORMAL, text);
displayWrite(osdDisplayPort, 20, y, DISPLAYPORT_ATTR_NONE, ":"); displayWrite(osdDisplayPort, 20, y, DISPLAYPORT_ATTR_NORMAL, ":");
displayWrite(osdDisplayPort, 22, y, DISPLAYPORT_ATTR_NONE, value); displayWrite(osdDisplayPort, 22, y, DISPLAYPORT_ATTR_NORMAL, value);
} }
/* /*
@ -713,7 +713,7 @@ static bool osdDisplayStat(int statistic, uint8_t displayRow)
tfp_sprintf(buff, "NO RTC"); tfp_sprintf(buff, "NO RTC");
} }
displayWrite(osdDisplayPort, 2, displayRow, DISPLAYPORT_ATTR_NONE, buff); displayWrite(osdDisplayPort, 2, displayRow, DISPLAYPORT_ATTR_NORMAL, buff);
return true; return true;
} }
@ -965,7 +965,7 @@ static bool osdRenderStatsContinue(void)
} }
if (displayLabel) { if (displayLabel) {
displayWrite(osdDisplayPort, 2, osdStatsRenderingState.row++, DISPLAYPORT_ATTR_NONE, " --- STATS ---"); displayWrite(osdDisplayPort, 2, osdStatsRenderingState.row++, DISPLAYPORT_ATTR_NORMAL, " --- STATS ---");
return false; return false;
} }
} }
@ -1068,10 +1068,10 @@ static timeDelta_t osdShowArmed(void)
} else { } else {
ret = (REFRESH_1S / 2); ret = (REFRESH_1S / 2);
} }
displayWrite(osdDisplayPort, 12, 7, DISPLAYPORT_ATTR_NONE, "ARMED"); displayWrite(osdDisplayPort, 12, 7, DISPLAYPORT_ATTR_NORMAL, "ARMED");
if (isFlipOverAfterCrashActive()) { if (isFlipOverAfterCrashActive()) {
displayWrite(osdDisplayPort, 8, 8, DISPLAYPORT_ATTR_NONE, CRASH_FLIP_WARNING); displayWrite(osdDisplayPort, 8, 8, DISPLAYPORT_ATTR_NORMAL, CRASH_FLIP_WARNING);
} }
return ret; return ret;

View file

@ -287,7 +287,7 @@ static void renderOsdEscRpmOrFreq(getEscRpmOrFreqFnPtr escFnPtr, osdElementParms
const int rpm = MIN((*escFnPtr)(i),99999); const int rpm = MIN((*escFnPtr)(i),99999);
const int len = tfp_sprintf(rpmStr, "%d", rpm); const int len = tfp_sprintf(rpmStr, "%d", rpm);
rpmStr[len] = '\0'; rpmStr[len] = '\0';
osdDisplayWrite(element, x, y + i, DISPLAYPORT_ATTR_NONE, rpmStr); osdDisplayWrite(element, x, y + i, DISPLAYPORT_ATTR_NORMAL, rpmStr);
} }
element->drawElement = false; element->drawElement = false;
} }
@ -663,6 +663,12 @@ static void osdElementAltitude(osdElementParms_t *element)
#ifdef USE_GPS #ifdef USE_GPS
haveGps = sensors(SENSOR_GPS) && STATE(GPS_FIX); haveGps = sensors(SENSOR_GPS) && STATE(GPS_FIX);
#endif // USE_GPS #endif // USE_GPS
int32_t alt = osdGetMetersToSelectedUnit(getEstimatedAltitudeCm()) / 100;
if ((alt >= osdConfig()->alt_alarm) && ARMING_FLAG(ARMED)) {
element->attr = DISPLAYPORT_ATTR_CRITICAL;
}
if (haveBaro || haveGps) { if (haveBaro || haveGps) {
osdFormatAltitudeString(element->buff, getEstimatedAltitudeCm(), element->type); osdFormatAltitudeString(element->buff, getEstimatedAltitudeCm(), element->type);
} else { } else {
@ -707,7 +713,7 @@ static void osdElementArtificialHorizon(osdElementParms_t *element)
for (int x = -4; x <= 4; x++) { for (int x = -4; x <= 4; x++) {
const int y = ((-rollAngle * x) / 64) - pitchAngle; const int y = ((-rollAngle * x) / 64) - pitchAngle;
if (y >= 0 && y <= 81) { if (y >= 0 && y <= 81) {
osdDisplayWriteChar(element, element->elemPosX + x, element->elemPosY + (y / AH_SYMBOL_COUNT), DISPLAYPORT_ATTR_NONE, (SYM_AH_BAR9_0 + (y % AH_SYMBOL_COUNT))); osdDisplayWriteChar(element, element->elemPosX + x, element->elemPosY + (y / AH_SYMBOL_COUNT), DISPLAYPORT_ATTR_NORMAL, (SYM_AH_BAR9_0 + (y % AH_SYMBOL_COUNT)));
} }
} }
@ -737,7 +743,7 @@ static void osdElementUpDownReference(osdElementParms_t *element)
int posX = element->elemPosX + lrintf(scaleRangef(psiB, -M_PIf / 4, M_PIf / 4, -14, 14)); int posX = element->elemPosX + lrintf(scaleRangef(psiB, -M_PIf / 4, M_PIf / 4, -14, 14));
int posY = element->elemPosY + lrintf(scaleRangef(thetaB, -M_PIf / 4, M_PIf / 4, -8, 8)); int posY = element->elemPosY + lrintf(scaleRangef(thetaB, -M_PIf / 4, M_PIf / 4, -8, 8));
osdDisplayWrite(element, posX, posY, DISPLAYPORT_ATTR_NONE, symbol[direction]); osdDisplayWrite(element, posX, posY, DISPLAYPORT_ATTR_NORMAL, symbol[direction]);
} }
element->drawElement = false; // element already drawn element->drawElement = false; // element already drawn
} }
@ -746,6 +752,19 @@ static void osdElementUpDownReference(osdElementParms_t *element)
static void osdElementAverageCellVoltage(osdElementParms_t *element) static void osdElementAverageCellVoltage(osdElementParms_t *element)
{ {
const int cellV = getBatteryAverageCellVoltage(); const int cellV = getBatteryAverageCellVoltage();
const batteryState_e batteryState = getBatteryState();
switch (batteryState) {
case BATTERY_WARNING:
element->attr = DISPLAYPORT_ATTR_WARNING;
break;
case BATTERY_CRITICAL:
element->attr = DISPLAYPORT_ATTR_CRITICAL;
break;
default:
break;
}
osdPrintFloat(element->buff, osdGetBatterySymbol(cellV), cellV / 100.0f, "", 2, false, SYM_VOLT); osdPrintFloat(element->buff, osdGetBatterySymbol(cellV), cellV / 100.0f, "", 2, false, SYM_VOLT);
} }
@ -776,12 +795,12 @@ static void osdBackgroundCameraFrame(osdElementParms_t *element)
element->buff[width - 1] = SYM_STICK_OVERLAY_CENTER; element->buff[width - 1] = SYM_STICK_OVERLAY_CENTER;
element->buff[width] = 0; // string terminator element->buff[width] = 0; // string terminator
osdDisplayWrite(element, xpos, ypos, DISPLAYPORT_ATTR_NONE, element->buff); osdDisplayWrite(element, xpos, ypos, DISPLAYPORT_ATTR_NORMAL, element->buff);
for (int i = 1; i < (height - 1); i++) { for (int i = 1; i < (height - 1); i++) {
osdDisplayWriteChar(element, xpos, ypos + i, DISPLAYPORT_ATTR_NONE, SYM_STICK_OVERLAY_VERTICAL); osdDisplayWriteChar(element, xpos, ypos + i, DISPLAYPORT_ATTR_NORMAL, SYM_STICK_OVERLAY_VERTICAL);
osdDisplayWriteChar(element, xpos + width - 1, ypos + i, DISPLAYPORT_ATTR_NONE, SYM_STICK_OVERLAY_VERTICAL); osdDisplayWriteChar(element, xpos + width - 1, ypos + i, DISPLAYPORT_ATTR_NORMAL, SYM_STICK_OVERLAY_VERTICAL);
} }
osdDisplayWrite(element, xpos, ypos + height - 1, DISPLAYPORT_ATTR_NONE, element->buff); osdDisplayWrite(element, xpos, ypos + height - 1, DISPLAYPORT_ATTR_NORMAL, element->buff);
element->drawElement = false; // element already drawn element->drawElement = false; // element already drawn
} }
@ -1060,6 +1079,18 @@ static void osdElementGpsCoordinate(osdElementParms_t *element)
static void osdElementGpsSats(osdElementParms_t *element) static void osdElementGpsSats(osdElementParms_t *element)
{ {
if ((STATE(GPS_FIX) == 0) || (gpsSol.numSat < GPS_MIN_SAT_COUNT) ) {
element->attr = DISPLAYPORT_ATTR_CRITICAL;
}
#ifdef USE_GPS_RESCUE
else if ((gpsSol.numSat < gpsRescueConfig()->minSats) && gpsRescueIsConfigured()) {
element->attr = DISPLAYPORT_ATTR_WARNING;
}
#endif
else {
element->attr = DISPLAYPORT_ATTR_INFO;
}
if (!gpsIsHealthy()) { if (!gpsIsHealthy()) {
tfp_sprintf(element->buff, "%c%cNC", SYM_SAT_L, SYM_SAT_R); tfp_sprintf(element->buff, "%c%cNC", SYM_SAT_L, SYM_SAT_R);
} else { } else {
@ -1104,13 +1135,13 @@ static void osdBackgroundHorizonSidebars(osdElementParms_t *element)
const int8_t hudwidth = AH_SIDEBAR_WIDTH_POS; const int8_t hudwidth = AH_SIDEBAR_WIDTH_POS;
const int8_t hudheight = AH_SIDEBAR_HEIGHT_POS; const int8_t hudheight = AH_SIDEBAR_HEIGHT_POS;
for (int y = -hudheight; y <= hudheight; y++) { for (int y = -hudheight; y <= hudheight; y++) {
osdDisplayWriteChar(element, element->elemPosX - hudwidth, element->elemPosY + y, DISPLAYPORT_ATTR_NONE, SYM_AH_DECORATION); osdDisplayWriteChar(element, element->elemPosX - hudwidth, element->elemPosY + y, DISPLAYPORT_ATTR_NORMAL, SYM_AH_DECORATION);
osdDisplayWriteChar(element, element->elemPosX + hudwidth, element->elemPosY + y, DISPLAYPORT_ATTR_NONE, SYM_AH_DECORATION); osdDisplayWriteChar(element, element->elemPosX + hudwidth, element->elemPosY + y, DISPLAYPORT_ATTR_NORMAL, SYM_AH_DECORATION);
} }
// AH level indicators // AH level indicators
osdDisplayWriteChar(element, element->elemPosX - hudwidth + 1, element->elemPosY, DISPLAYPORT_ATTR_NONE, SYM_AH_LEFT); osdDisplayWriteChar(element, element->elemPosX - hudwidth + 1, element->elemPosY, DISPLAYPORT_ATTR_NORMAL, SYM_AH_LEFT);
osdDisplayWriteChar(element, element->elemPosX + hudwidth - 1, element->elemPosY, DISPLAYPORT_ATTR_NONE, SYM_AH_RIGHT); osdDisplayWriteChar(element, element->elemPosX + hudwidth - 1, element->elemPosY, DISPLAYPORT_ATTR_NORMAL, SYM_AH_RIGHT);
element->drawElement = false; // element already drawn element->drawElement = false; // element already drawn
} }
@ -1119,6 +1150,11 @@ static void osdBackgroundHorizonSidebars(osdElementParms_t *element)
static void osdElementLinkQuality(osdElementParms_t *element) static void osdElementLinkQuality(osdElementParms_t *element)
{ {
uint16_t osdLinkQuality = 0; uint16_t osdLinkQuality = 0;
if (rxGetLinkQualityPercent() < osdConfig()->link_quality_alarm) {
element->attr = DISPLAYPORT_ATTR_CRITICAL;
}
if (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_CRSF) { // 0-99 if (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_CRSF) { // 0-99
osdLinkQuality = rxGetLinkQuality(); osdLinkQuality = rxGetLinkQuality();
const uint8_t osdRfMode = rxGetRfMode(); const uint8_t osdRfMode = rxGetRfMode();
@ -1170,13 +1206,24 @@ static void osdElementLogStatus(osdElementParms_t *element)
static void osdElementMahDrawn(osdElementParms_t *element) static void osdElementMahDrawn(osdElementParms_t *element)
{ {
tfp_sprintf(element->buff, "%4d%c", getMAhDrawn(), SYM_MAH); const int mAhDrawn = getMAhDrawn();
if (mAhDrawn >= osdConfig()->cap_alarm) {
element->attr = DISPLAYPORT_ATTR_CRITICAL;
}
tfp_sprintf(element->buff, "%4d%c", mAhDrawn, SYM_MAH);
} }
static void osdElementWattHoursDrawn(osdElementParms_t *element) static void osdElementWattHoursDrawn(osdElementParms_t *element)
{ {
const int mAhDrawn = getMAhDrawn();
const float wattHoursDrawn = getWhDrawn(); const float wattHoursDrawn = getWhDrawn();
if (mAhDrawn >= osdConfig()->cap_alarm) {
element->attr = DISPLAYPORT_ATTR_CRITICAL;
}
if (wattHoursDrawn < 1.0f) { if (wattHoursDrawn < 1.0f) {
tfp_sprintf(element->buff, "%3dMWH", lrintf(wattHoursDrawn * 1000)); tfp_sprintf(element->buff, "%3dMWH", lrintf(wattHoursDrawn * 1000));
} else { } else {
@ -1191,10 +1238,14 @@ static void osdElementMainBatteryUsage(osdElementParms_t *element)
{ {
// Set length of indicator bar // Set length of indicator bar
#define MAIN_BATT_USAGE_STEPS 11 // Use an odd number so the bar can be centered. #define MAIN_BATT_USAGE_STEPS 11 // Use an odd number so the bar can be centered.
const int mAhDrawn = getMAhDrawn();
const int usedCapacity = getMAhDrawn(); const int usedCapacity = getMAhDrawn();
int displayBasis = usedCapacity; int displayBasis = usedCapacity;
if (mAhDrawn >= osdConfig()->cap_alarm) {
element->attr = DISPLAYPORT_ATTR_CRITICAL;
}
switch (element->type) { switch (element->type) {
case OSD_ELEMENT_TYPE_3: // mAh remaining percentage (counts down as battery is used) case OSD_ELEMENT_TYPE_3: // mAh remaining percentage (counts down as battery is used)
displayBasis = constrain(batteryConfig()->batteryCapacity - usedCapacity, 0, batteryConfig()->batteryCapacity); displayBasis = constrain(batteryConfig()->batteryCapacity - usedCapacity, 0, batteryConfig()->batteryCapacity);
@ -1243,6 +1294,18 @@ static void osdElementMainBatteryVoltage(osdElementParms_t *element)
{ {
unsigned decimalPlaces; unsigned decimalPlaces;
const float batteryVoltage = getBatteryVoltage() / 100.0f; const float batteryVoltage = getBatteryVoltage() / 100.0f;
batteryState_e batteryState = getBatteryState();
switch (batteryState) {
case BATTERY_WARNING:
element->attr = DISPLAYPORT_ATTR_WARNING;
break;
case BATTERY_CRITICAL:
element->attr = DISPLAYPORT_ATTR_CRITICAL;
break;
default:
break;
}
if (batteryVoltage >= 10) { // if voltage is 10v or more then display only 1 decimal place if (batteryVoltage >= 10) { // if voltage is 10v or more then display only 1 decimal place
decimalPlaces = 1; decimalPlaces = 1;
@ -1339,7 +1402,7 @@ static void osdElementRcChannels(osdElementParms_t *element)
// Decimal notation can be added when tfp_sprintf supports float among fancy options. // Decimal notation can be added when tfp_sprintf supports float among fancy options.
char fmtbuf[6]; char fmtbuf[6];
tfp_sprintf(fmtbuf, "%5d", data); tfp_sprintf(fmtbuf, "%5d", data);
osdDisplayWrite(element, xpos, ypos + i, DISPLAYPORT_ATTR_NONE, fmtbuf); osdDisplayWrite(element, xpos, ypos + i, DISPLAYPORT_ATTR_NORMAL, fmtbuf);
} }
} }
@ -1350,6 +1413,10 @@ static void osdElementRemainingTimeEstimate(osdElementParms_t *element)
{ {
const int mAhDrawn = getMAhDrawn(); const int mAhDrawn = getMAhDrawn();
if (mAhDrawn >= osdConfig()->cap_alarm) {
element->attr = DISPLAYPORT_ATTR_CRITICAL;
}
if (mAhDrawn <= 0.1 * osdConfig()->cap_alarm) { // also handles the mAhDrawn == 0 condition if (mAhDrawn <= 0.1 * osdConfig()->cap_alarm) { // also handles the mAhDrawn == 0 condition
tfp_sprintf(element->buff, "--:--"); tfp_sprintf(element->buff, "--:--");
} else if (mAhDrawn > osdConfig()->cap_alarm) { } else if (mAhDrawn > osdConfig()->cap_alarm) {
@ -1367,6 +1434,10 @@ static void osdElementRssi(osdElementParms_t *element)
osdRssi = 99; osdRssi = 99;
} }
if (getRssiPercent() < osdConfig()->rssi_alarm) {
element->attr = DISPLAYPORT_ATTR_CRITICAL;
}
tfp_sprintf(element->buff, "%c%2d", SYM_RSSI, osdRssi); tfp_sprintf(element->buff, "%c%2d", SYM_RSSI, osdRssi);
} }
@ -1402,11 +1473,11 @@ static void osdBackgroundStickOverlay(osdElementParms_t *element)
for (unsigned y = 0; y < OSD_STICK_OVERLAY_HEIGHT; y++) { for (unsigned y = 0; y < OSD_STICK_OVERLAY_HEIGHT; y++) {
// draw the axes, vertical and horizonal // draw the axes, vertical and horizonal
if ((x == ((OSD_STICK_OVERLAY_WIDTH - 1) / 2)) && (y == (OSD_STICK_OVERLAY_HEIGHT - 1) / 2)) { if ((x == ((OSD_STICK_OVERLAY_WIDTH - 1) / 2)) && (y == (OSD_STICK_OVERLAY_HEIGHT - 1) / 2)) {
osdDisplayWriteChar(element, xpos + x, ypos + y, DISPLAYPORT_ATTR_NONE, SYM_STICK_OVERLAY_CENTER); osdDisplayWriteChar(element, xpos + x, ypos + y, DISPLAYPORT_ATTR_NORMAL, SYM_STICK_OVERLAY_CENTER);
} else if (x == ((OSD_STICK_OVERLAY_WIDTH - 1) / 2)) { } else if (x == ((OSD_STICK_OVERLAY_WIDTH - 1) / 2)) {
osdDisplayWriteChar(element, xpos + x, ypos + y, DISPLAYPORT_ATTR_NONE, SYM_STICK_OVERLAY_VERTICAL); osdDisplayWriteChar(element, xpos + x, ypos + y, DISPLAYPORT_ATTR_NORMAL, SYM_STICK_OVERLAY_VERTICAL);
} else if (y == ((OSD_STICK_OVERLAY_HEIGHT - 1) / 2)) { } else if (y == ((OSD_STICK_OVERLAY_HEIGHT - 1) / 2)) {
osdDisplayWriteChar(element, xpos + x, ypos + y, DISPLAYPORT_ATTR_NONE, SYM_STICK_OVERLAY_HORIZONTAL); osdDisplayWriteChar(element, xpos + x, ypos + y, DISPLAYPORT_ATTR_NORMAL, SYM_STICK_OVERLAY_HORIZONTAL);
} }
} }
} }
@ -1434,7 +1505,7 @@ static void osdElementStickOverlay(osdElementParms_t *element)
const uint8_t cursorY = OSD_STICK_OVERLAY_VERTICAL_POSITIONS - 1 - scaleRange(constrain(rcData[vertical_channel], PWM_RANGE_MIN, PWM_RANGE_MAX - 1), PWM_RANGE_MIN, PWM_RANGE_MAX, 0, OSD_STICK_OVERLAY_VERTICAL_POSITIONS); const uint8_t cursorY = OSD_STICK_OVERLAY_VERTICAL_POSITIONS - 1 - scaleRange(constrain(rcData[vertical_channel], PWM_RANGE_MIN, PWM_RANGE_MAX - 1), PWM_RANGE_MIN, PWM_RANGE_MAX, 0, OSD_STICK_OVERLAY_VERTICAL_POSITIONS);
const char cursor = SYM_STICK_OVERLAY_SPRITE_HIGH + (cursorY % OSD_STICK_OVERLAY_SPRITE_HEIGHT); const char cursor = SYM_STICK_OVERLAY_SPRITE_HIGH + (cursorY % OSD_STICK_OVERLAY_SPRITE_HEIGHT);
osdDisplayWriteChar(element, xpos + cursorX, ypos + cursorY / OSD_STICK_OVERLAY_SPRITE_HEIGHT, DISPLAYPORT_ATTR_NONE, cursor); osdDisplayWriteChar(element, xpos + cursorX, ypos + cursorY / OSD_STICK_OVERLAY_SPRITE_HEIGHT, DISPLAYPORT_ATTR_NORMAL, cursor);
element->drawElement = false; // element already drawn element->drawElement = false; // element already drawn
} }
@ -1447,6 +1518,15 @@ static void osdElementThrottlePosition(osdElementParms_t *element)
static void osdElementTimer(osdElementParms_t *element) static void osdElementTimer(osdElementParms_t *element)
{ {
for (int i = 0; i < OSD_TIMER_COUNT; i++) {
const uint16_t timer = osdConfig()->timers[i];
const timeUs_t time = osdGetTimerValue(OSD_TIMER_SRC(timer));
const timeUs_t alarmTime = OSD_TIMER_ALARM(timer) * 60000000; // convert from minutes to us
if (alarmTime != 0 && time >= alarmTime) {
element->attr = DISPLAYPORT_ATTR_CRITICAL;
}
}
osdFormatTimer(element->buff, true, true, element->item - OSD_ITEM_TIMER_1); osdFormatTimer(element->buff, true, true, element->item - OSD_ITEM_TIMER_1);
} }
@ -1867,7 +1947,7 @@ static void osdDrawSingleElement(displayPort_t *osdDisplayPort, uint8_t item)
element.buff = (char *)&buff; element.buff = (char *)&buff;
element.osdDisplayPort = osdDisplayPort; element.osdDisplayPort = osdDisplayPort;
element.drawElement = true; element.drawElement = true;
element.attr = DISPLAYPORT_ATTR_NONE; element.attr = DISPLAYPORT_ATTR_NORMAL;
// Call the element drawing function // Call the element drawing function
if ((item >= OSD_SYS_GOGGLE_VOLTAGE) && (item < OSD_SYS_WARNINGS)) { if ((item >= OSD_SYS_GOGGLE_VOLTAGE) && (item < OSD_SYS_WARNINGS)) {
@ -1903,7 +1983,7 @@ static void osdDrawSingleElementBackground(displayPort_t *osdDisplayPort, uint8_
// Call the element background drawing function // Call the element background drawing function
osdElementBackgroundFunction[item](&element); osdElementBackgroundFunction[item](&element);
if (element.drawElement) { if (element.drawElement) {
osdDisplayWrite(&element, elemPosX, elemPosY, DISPLAYPORT_ATTR_NONE, buff); osdDisplayWrite(&element, elemPosX, elemPosY, DISPLAYPORT_ATTR_NORMAL, buff);
} }
} }

View file

@ -75,7 +75,7 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr)
static unsigned armingDisabledDisplayIndex; static unsigned armingDisabledDisplayIndex;
warningText[0] = '\0'; warningText[0] = '\0';
*displayAttr = DISPLAYPORT_ATTR_NONE; *displayAttr = DISPLAYPORT_ATTR_NORMAL;
*blinking = false; *blinking = false;
// Cycle through the arming disabled reasons // Cycle through the arming disabled reasons

View file

@ -20,6 +20,7 @@
#pragma once #pragma once
#include "io/displayport_msp.h"
#include "pg/pg.h" #include "pg/pg.h"
typedef struct displayPortProfile_s { typedef struct displayPortProfile_s {
@ -31,7 +32,7 @@ typedef struct displayPortProfile_s {
// For attribute-rich OSDs // For attribute-rich OSDs
uint8_t attrValues[4]; // NORMAL, INFORMATIONAL, WARNING, CRITICAL uint8_t fontSelection[DISPLAYPORT_ATTR_COUNT];
uint8_t useDeviceBlink; // Use device local blink capability uint8_t useDeviceBlink; // Use device local blink capability
} displayPortProfile_t; } displayPortProfile_t;