Skip to content

Commit

Permalink
msp hd osd
Browse files Browse the repository at this point in the history
  • Loading branch information
shanggl committed May 3, 2023
1 parent eb200da commit a415d8b
Show file tree
Hide file tree
Showing 32 changed files with 2,067 additions and 489 deletions.
129 changes: 47 additions & 82 deletions src/main/cli/settings.c

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main/cli/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef enum {
#ifdef USE_SERVOS
TABLE_GIMBAL_MODE,
#endif
#ifdef USE_SERIAL_RX
#ifdef USE_SERIALRX
TABLE_SERIAL_RX,
#endif
#ifdef USE_RX_SPI
Expand Down Expand Up @@ -97,7 +97,7 @@ typedef enum {
TABLE_GYRO,
#endif
TABLE_THROTTLE_LIMIT_TYPE,
#if defined(USE_MAX7456) || defined(USE_FRSKYOSD)
#if defined(USE_VIDEO_SYSTEM)
TABLE_VIDEO_SYSTEM,
#endif
#if defined(USE_ITERM_RELAX)
Expand Down
51 changes: 33 additions & 18 deletions src/main/cms/cms.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,16 @@ bool cmsDisplayPortSelect(displayPort_t *instance)
// 30 cols x 13 rows
// HoTT Telemetry Screen
// 21 cols x 8 rows
//
// HD
// 53 cols x 20 rows
// Spektrum SRXL Telemtry Textgenerator
// 13 cols x 9 rows, top row printed as a Bold Heading
// Needs the "smallScreen" adaptions

#define CMS_MAX_ROWS 16
#define CMS_MAX_ROWS 31

#define NORMAL_SCREEN_MIN_COLS 18 // Less is a small screen
#define NORMAL_SCREEN_MAX_COLS 30 // More is a large screen
static bool smallScreen;
static uint8_t leftMenuColumn;
static uint8_t rightMenuColumn;
Expand Down Expand Up @@ -388,7 +390,7 @@ static int cmsDrawMenuItemValue(displayPort_t *pDisplay, char *buff, uint8_t row
#else
colpos = smallScreen ? rightMenuColumn - maxSize : rightMenuColumn;
#endif
cnt = cmsDisplayWrite(pDisplay, colpos, row, DISPLAYPORT_ATTR_NONE, buff);
cnt = cmsDisplayWrite(pDisplay, colpos, row, DISPLAYPORT_SEVERITY_NORMAL, buff);
return cnt;
}

Expand Down Expand Up @@ -589,7 +591,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 = 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_SEVERITY_NORMAL, p->data);
CLR_PRINTVALUE(*flags);
}
break;
Expand All @@ -605,9 +607,9 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t
#ifdef CMS_MENU_DEBUG
// Shouldn't happen. Notify creator of this menu content
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
cnt = cmsDisplayWrite(pDisplay, rightMenuColumn - 6, row, DISPLAYPORT_ATTR_NONE, "BADENT");
cnt = cmsDisplayWrite(pDisplay, rightMenuColumn - 6, row, DISPLAYPORT_SEVERITY_NORMAL, "BADENT");
#else
cnt = cmsDisplayWrite(pDisplay, rightMenuColumn, row, DISPLAYPORT_ATTR_NONE, "BADENT");
cnt = cmsDisplayWrite(pDisplay, rightMenuColumn, row, DISPLAYPORT_SEVERITY_NORMAL, "BADENT");
#endif
#endif
break;
Expand Down Expand Up @@ -746,15 +748,15 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
#endif

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_SEVERITY_NORMAL, " ");
}

if (room < 30) {
return;
}

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_SEVERITY_NORMAL, ">");
pDisplay->cursorRow = currentCtx.cursorRow;
}

Expand All @@ -776,7 +778,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
if (IS_PRINTLABEL(runtimeEntryFlags[i])) {
uint8_t coloff = leftMenuColumn;
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_SEVERITY_NORMAL, p->text);
CLR_PRINTLABEL(runtimeEntryFlags[i]);
if (room < 30) {
return;
Expand All @@ -786,7 +788,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)

// Highlight values overridden by sliders
if (rowSliderOverride(p->flags)) {
displayWriteChar(pDisplay, leftMenuColumn - 1, top + i * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, 'S');
displayWriteChar(pDisplay, leftMenuColumn - 1, top + i * linesPerMenuItem, DISPLAYPORT_SEVERITY_NORMAL, 'S');
}

// Print values
Expand All @@ -809,12 +811,12 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
// 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);
const uint8_t symbol = displaySupportsOsdSymbols(pDisplay) ? SYM_ARROW_SMALL_UP : '^';
displayWriteChar(pDisplay, leftMenuColumn - 1, top, DISPLAYPORT_SEVERITY_NORMAL, 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 uint8_t symbol = displaySupportsOsdSymbols(pDisplay) ? SYM_ARROW_SMALL_DOWN : 'v';
displayWriteChar(pDisplay, leftMenuColumn - 1, top + pageMaxRow, DISPLAYPORT_SEVERITY_NORMAL, symbol);
}
}

Expand Down Expand Up @@ -897,9 +899,11 @@ void cmsMenuOpen(void)
menuStackIdx = 0;
setArmingDisabled(ARMING_DISABLED_CMS_MENU);
displayLayerSelect(pCurrentDisplay, DISPLAYPORT_LAYER_FOREGROUND); // make sure the foreground layer is active
#ifdef USE_OSD
if (osdConfig()->cms_background_type != DISPLAY_BACKGROUND_TRANSPARENT) {
displaySetBackgroundType(pCurrentDisplay, (displayPortBackground_e)osdConfig()->cms_background_type); // set the background type if not transparent
}
#endif
} else {
// Switch display
displayPort_t *pNextDisplay = cmsDisplayPortSelectNext();
Expand All @@ -911,7 +915,9 @@ void cmsMenuOpen(void)
displaySetBackgroundType(pCurrentDisplay, DISPLAY_BACKGROUND_TRANSPARENT); // reset previous displayPort to transparent
displayRelease(pCurrentDisplay);
pCurrentDisplay = pNextDisplay;
#ifdef USE_OSD
displaySetBackgroundType(pCurrentDisplay, (displayPortBackground_e)osdConfig()->cms_background_type); // set the background type if not transparent
#endif
} else {
return;
}
Expand All @@ -931,12 +937,21 @@ void cmsMenuOpen(void)
} else {
smallScreen = false;
linesPerMenuItem = 1;
leftMenuColumn = 2;
if (pCurrentDisplay->cols <= NORMAL_SCREEN_MAX_COLS) {
leftMenuColumn = 2;
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
rightMenuColumn = pCurrentDisplay->cols - 2;
#else
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
#endif
} else {
leftMenuColumn = (pCurrentDisplay->cols / 2) - 13;
#ifdef CMS_OSD_RIGHT_ALIGNED_VALUES
rightMenuColumn = pCurrentDisplay->cols - 2;
rightMenuColumn = (pCurrentDisplay->cols / 2) + 13;
#else
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN;
#endif
}
maxMenuItems = pCurrentDisplay->rows - 2;
}

Expand Down Expand Up @@ -999,7 +1014,7 @@ const void *cmsMenuExit(displayPort_t *pDisplay, const void *ptr)

if ((exitType == CMS_EXIT_SAVEREBOOT) || (exitType == CMS_POPUP_SAVEREBOOT) || (exitType == CMS_POPUP_EXITREBOOT)) {
displayClearScreen(pDisplay, DISPLAY_CLEAR_WAIT);
cmsDisplayWrite(pDisplay, 5, 3, DISPLAYPORT_ATTR_NONE, "REBOOTING...");
cmsDisplayWrite(pDisplay, 5, 3, DISPLAYPORT_SEVERITY_NORMAL, "REBOOTING...");

// Flush display
displayRedraw(pDisplay);
Expand Down
2 changes: 1 addition & 1 deletion src/main/cms/cms_menu_blackbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static const void *cmsx_EraseFlash(displayPort_t *pDisplay, const void *ptr)
}

displayClearScreen(pDisplay, DISPLAY_CLEAR_WAIT);
displayWrite(pDisplay, 5, 3, DISPLAYPORT_ATTR_INFO, "ERASING FLASH...");
displayWrite(pDisplay, 5, 3, DISPLAYPORT_SEVERITY_INFO, "ERASING FLASH...");
displayRedraw(pDisplay);

flashfsEraseCompletely();
Expand Down
12 changes: 10 additions & 2 deletions src/main/cms/cms_menu_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ const OSD_Entry menuOsdActiveElemsEntries[] =
{"RSSI", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_RSSI_VALUE]},
#ifdef USE_RX_RSSI_DBM
{"RSSI DBM", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_RSSI_DBM_VALUE]},
#endif
#ifdef USE_RX_RSNR
{"RSNR", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_RSNR_VALUE]},
#endif
{"BATTERY VOLTAGE", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_MAIN_BATT_VOLTAGE]},
{"BATTERY USAGE", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_MAIN_BATT_USAGE]},
Expand All @@ -105,7 +108,7 @@ const OSD_Entry menuOsdActiveElemsEntries[] =
#endif
{"ANTI GRAVITY", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_ANTI_GRAVITY]},
{"FLY MODE", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_FLYMODE]},
{"NAME", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_CRAFT_NAME]},
{"CRAFT NAME", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_CRAFT_NAME]},
{"THROTTLE", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_THROTTLE_POS]},
#ifdef USE_VTX_CONTROL
{"VTX CHAN", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_VTX_CHANNEL]},
Expand Down Expand Up @@ -161,10 +164,11 @@ const OSD_Entry menuOsdActiveElemsEntries[] =
{"STICK OVERLAY LEFT", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_STICK_OVERLAY_LEFT]},
{"STICK OVERLAY RIGHT",OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_STICK_OVERLAY_RIGHT]},
#endif
{"DISPLAY NAME", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_DISPLAY_NAME]},
{"PILOT NAME", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_PILOT_NAME]},
{"RC CHANNELS", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_RC_CHANNELS]},
{"CAMERA FRAME", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_CAMERA_FRAME]},
{"TOTAL FLIGHTS", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_TOTAL_FLIGHTS]},
{"AUX VALUE", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_AUX_VALUE]},
{"BACK", OME_Back, NULL, NULL},
{NULL, OME_END, NULL, NULL}
};
Expand All @@ -183,6 +187,7 @@ static CMS_Menu menuOsdActiveElems = {
static uint8_t osdConfig_rssi_alarm;
static uint16_t osdConfig_link_quality_alarm;
static int16_t osdConfig_rssi_dbm_alarm;
static int16_t osdConfig_rsnr_alarm;
static uint16_t osdConfig_cap_alarm;
static uint16_t osdConfig_alt_alarm;
static uint16_t osdConfig_distance_alarm;
Expand All @@ -196,6 +201,7 @@ static const void *menuAlarmsOnEnter(displayPort_t *pDisp)
osdConfig_rssi_alarm = osdConfig()->rssi_alarm;
osdConfig_link_quality_alarm = osdConfig()->link_quality_alarm;
osdConfig_rssi_dbm_alarm = osdConfig()->rssi_dbm_alarm;
osdConfig_rsnr_alarm = osdConfig()->rsnr_alarm;
osdConfig_cap_alarm = osdConfig()->cap_alarm;
osdConfig_alt_alarm = osdConfig()->alt_alarm;
osdConfig_distance_alarm = osdConfig()->distance_alarm;
Expand All @@ -213,6 +219,7 @@ static const void *menuAlarmsOnExit(displayPort_t *pDisp, const OSD_Entry *self)
osdConfigMutable()->rssi_alarm = osdConfig_rssi_alarm;
osdConfigMutable()->link_quality_alarm = osdConfig_link_quality_alarm;
osdConfigMutable()->rssi_dbm_alarm = osdConfig_rssi_dbm_alarm;
osdConfigMutable()->rsnr_alarm = osdConfig_rsnr_alarm;
osdConfigMutable()->cap_alarm = osdConfig_cap_alarm;
osdConfigMutable()->alt_alarm = osdConfig_alt_alarm;
osdConfigMutable()->distance_alarm = osdConfig_distance_alarm;
Expand All @@ -228,6 +235,7 @@ const OSD_Entry menuAlarmsEntries[] =
{"RSSI", OME_UINT8, NULL, &(OSD_UINT8_t){&osdConfig_rssi_alarm, 5, 90, 5}},
{"LINK QUALITY", OME_UINT16, NULL, &(OSD_UINT16_t){&osdConfig_link_quality_alarm, 5, 300, 5}},
{"RSSI DBM", OME_INT16, NULL, &(OSD_INT16_t){&osdConfig_rssi_dbm_alarm, CRSF_RSSI_MIN, CRSF_SNR_MAX, 5}},
{"RSNR", OME_INT16, NULL, &(OSD_INT16_t){&osdConfig_rsnr_alarm, CRSF_SNR_MIN, CRSF_SNR_MAX, 5}},
{"MAIN BAT", OME_UINT16, NULL, &(OSD_UINT16_t){&osdConfig_cap_alarm, 50, 30000, 50}},
{"MAX ALT", OME_UINT16, NULL, &(OSD_UINT16_t){&osdConfig_alt_alarm, 1, 200, 1}},
{"MAX DISTANCE", OME_UINT16, NULL, &(OSD_UINT16_t){&osdConfig_distance_alarm, 0, UINT16_MAX, 10}},
Expand Down
Loading

0 comments on commit a415d8b

Please sign in to comment.