From d743e8e225f86eccbbfa3b76f645bb86e66cb56b Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:58:14 -0500 Subject: [PATCH] HDZERO - OSD Init/Menu/Stats Centering (#992) --- src/main/cms/cms.c | 17 +++++++++++++--- src/main/cms/cms_menu_blackbox.c | 2 +- src/main/io/osd.c | 34 ++++++++++++++++++++------------ src/main/io/osd.h | 4 ++++ src/main/pg/vcd.h | 3 ++- 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/main/cms/cms.c b/src/main/cms/cms.c index 3a4730f66f..f5259d23b5 100644 --- a/src/main/cms/cms.c +++ b/src/main/cms/cms.c @@ -66,6 +66,7 @@ // For VISIBLE* #include "io/osd.h" #include "io/rcdevice_cam.h" +#include "pg/vcd.h" #include "rx/rx.h" @@ -597,9 +598,19 @@ void cmsMenuOpen(void) { } else { smallScreen = false; linesPerMenuItem = 1; - leftMenuColumn = 2; +#if defined(USE_HDZERO_OSD) + if ((vcdProfile()->video_system == VIDEO_SYSTEM_HD) && (pCurrentDisplay->cols > 30)) + { leftMenuColumn = HDINDENT + 2; } + else +#endif + { leftMenuColumn = SDINDENT + 2; } #ifdef CMS_OSD_RIGHT_ALIGNED_VALUES - rightMenuColumn = pCurrentDisplay->cols - 2; +#if defined(USE_HDZERO_OSD) + if ((vcdProfile()->video_system == VIDEO_SYSTEM_HD) && (pCurrentDisplay->cols > 30)) + { rightMenuColumn = pCurrentDisplay->cols - 2 - HDINDENT; } + else +#endif + { rightMenuColumn = pCurrentDisplay->cols - 2; } #else rightMenuColumn = pCurrentDisplay->cols - CMS_DRAW_BUFFER_LEN; #endif @@ -634,7 +645,7 @@ long cmsMenuExit(displayPort_t *pDisplay, const void *ptr) { currentCtx.menu = NULL; if (exitType == CMS_EXIT_SAVEREBOOT) { displayClearScreen(pDisplay); - displayWrite(pDisplay, 5, 3, "REBOOTING..."); + displayWrite(pDisplay, (pCurrentDisplay->cols % 2) - 6, 3, "REBOOTING..."); displayResync(pDisplay); // Was max7456RefreshAll(); why at this timing? stopMotors(); stopPwmAllMotors(); diff --git a/src/main/cms/cms_menu_blackbox.c b/src/main/cms/cms_menu_blackbox.c index 56adfed277..84f11531c3 100644 --- a/src/main/cms/cms_menu_blackbox.c +++ b/src/main/cms/cms_menu_blackbox.c @@ -140,7 +140,7 @@ static long cmsx_EraseFlash(displayPort_t *pDisplay, const void *ptr) { return 0; } displayClearScreen(pDisplay); - displayWrite(pDisplay, 5, 3, "ERASING FLASH..."); + displayWrite(pDisplay, (pCurrentDisplay->cols % 2) - 7, 3, "ERASING FLASH..."); displayResync(pDisplay); // Was max7456RefreshAll(); Why at this timing? flashfsEraseCompletely(); while (!flashfsIsReady()) { diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 937b71c694..c13d3da510 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -169,6 +169,8 @@ static escSensorData_t *escDataCombined; #define AH_SIDEBAR_WIDTH_POS 7 #define AH_SIDEBAR_HEIGHT_POS 3 +static uint8_t leftScreen; + static const char compassBar[] = { SYM_HEADING_W, SYM_HEADING_LINE, SYM_HEADING_DIVIDED_LINE, SYM_HEADING_LINE, @@ -1163,19 +1165,25 @@ void osdInit(displayPort_t *osdDisplayPortToUse) { armState = ARMING_FLAG(ARMED); memset(blinkBits, 0, sizeof(blinkBits)); displayClearScreen(osdDisplayPort); - osdDrawLogo(3, 1); +#if defined(USE_HDZERO_OSD) + if ((vcdProfile()->video_system == VIDEO_SYSTEM_HD) && (pCurrentDisplay->cols > 30)) + { leftScreen = HDINDENT; } + else +#endif + { leftScreen = SDINDENT; } + osdDrawLogo(leftScreen + 3, 1); char string_buffer[30]; tfp_sprintf(string_buffer, "V%s", FC_VERSION_STRING); - displayWrite(osdDisplayPort, 20, 6, string_buffer); + displayWrite(osdDisplayPort, leftScreen + 20, 6, string_buffer); #ifdef USE_CMS - displayWrite(osdDisplayPort, 7, 8, CMS_STARTUP_HELP_TEXT1); - displayWrite(osdDisplayPort, 11, 9, CMS_STARTUP_HELP_TEXT2); - displayWrite(osdDisplayPort, 11, 10, CMS_STARTUP_HELP_TEXT3); + displayWrite(osdDisplayPort, leftScreen + 7, 8, CMS_STARTUP_HELP_TEXT1); + displayWrite(osdDisplayPort, leftScreen + 11, 9, CMS_STARTUP_HELP_TEXT2); + displayWrite(osdDisplayPort, leftScreen + 11, 10, CMS_STARTUP_HELP_TEXT3); #endif #ifdef USE_RTC_TIME char dateTimeBuffer[FORMATTED_DATE_TIME_BUFSIZE]; if (osdFormatRtcDateTime(&dateTimeBuffer[0])) { - displayWrite(osdDisplayPort, 5, 12, dateTimeBuffer); + displayWrite(osdDisplayPort, leftScreen + 5, 12, dateTimeBuffer); } #endif displayResync(osdDisplayPort); @@ -1376,9 +1384,9 @@ static void osdGetBlackboxStatusString(char * buff) { #endif static void osdDisplayStatisticLabel(uint8_t y, const char * text, const char * value) { - displayWrite(osdDisplayPort, 2, y, text); - displayWrite(osdDisplayPort, 20, y, ":"); - displayWrite(osdDisplayPort, 22, y, value); + displayWrite(osdDisplayPort, leftScreen + 2, y, text); + displayWrite(osdDisplayPort, leftScreen + 20, y, ":"); + displayWrite(osdDisplayPort, leftScreen + 22, y, value); } /* @@ -1400,7 +1408,7 @@ static void osdShowStats(uint16_t endBatteryVoltage) { uint8_t top = 2; char buff[OSD_ELEMENT_BUFFER_LENGTH]; displayClearScreen(osdDisplayPort); - displayWrite(osdDisplayPort, 2, top++, " --- STATS ---"); + displayWrite(osdDisplayPort, leftScreen + 2, top++, " --- STATS ---"); if (osdStatGetState(OSD_STAT_RTC_DATE_TIME)) { bool success = false; #ifdef USE_RTC_TIME @@ -1409,7 +1417,7 @@ static void osdShowStats(uint16_t endBatteryVoltage) { if (!success) { tfp_sprintf(buff, "NO RTC"); } - displayWrite(osdDisplayPort, 2, top++, buff); + displayWrite(osdDisplayPort, leftScreen + 2, top++, buff); } if (osdStatGetState(OSD_STAT_TIMER_1)) { osdFormatTimer(buff, false, (OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_1]) == OSD_TIMER_SRC_ON ? false : true), OSD_TIMER_1); @@ -1483,12 +1491,12 @@ static timeDelta_t osdShowArmed(void) timeDelta_t ret; displayClearScreen(osdDisplayPort); if ((osdConfig()->logo_on_arming == OSD_LOGO_ARMING_ON) || ((osdConfig()->logo_on_arming == OSD_LOGO_ARMING_FIRST) && !everArmed)) { - osdDrawLogo(3, 1); + osdDrawLogo(leftScreen + 3, 1); ret = osdConfig()->logo_on_arming_duration * 1e5; } else { ret = (REFRESH_1S / 2); } - displayWrite(osdDisplayPort, 12, 7, "ARMED"); + displayWrite(osdDisplayPort, leftScreen + 12, 7, "ARMED"); everArmed = true; return ret; } diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 886a3080d6..15ffb20cc6 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -22,6 +22,7 @@ #include "common/time.h" #include "pg/pg.h" +#include "pg/vcd.h" #define OSD_NUM_TIMER_TYPES 3 extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES]; @@ -44,6 +45,9 @@ extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES]; #define OSD_X(x) ((x & OSD_POSITION_XY_MASK) | ((x & OSD_POSITION_XHD_MASK) >> (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS))) #define OSD_Y(x) ((x >> OSD_POSITION_BITS) & OSD_POSITION_XY_MASK) +#define SDINDENT 0 //Analog leftmost character for OSD Init and Menus +#define HDINDENT 10 //HD leftmost character for OSD Init and Menus + // Timer configuration // Stored as 15[alarm:8][precision:4][source:4]0 #define OSD_TIMER(src, prec, alarm) ((src & 0x0F) | ((prec & 0x0F) << 4) | ((alarm & 0xFF ) << 8)) diff --git a/src/main/pg/vcd.h b/src/main/pg/vcd.h index df3ed8001d..33ff77155a 100644 --- a/src/main/pg/vcd.h +++ b/src/main/pg/vcd.h @@ -27,7 +27,8 @@ enum VIDEO_SYSTEMS { VIDEO_SYSTEM_AUTO = 0, VIDEO_SYSTEM_PAL, - VIDEO_SYSTEM_NTSC + VIDEO_SYSTEM_NTSC, + VIDEO_SYSTEM_HD }; typedef struct vcdProfile_s {