From 837700165d08868a3e49702a26fead087810fc75 Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Sun, 17 Dec 2023 15:48:25 -0600 Subject: [PATCH] HDZero - 5bit backward compatible OSD positioning --- src/main/drivers/display_font_metadata.h | 10 +++++----- src/main/interface/msp_protocol.h | 2 +- src/main/interface/settings.c | 2 +- src/main/io/displayport_hdzero_osd.c | 4 ++-- src/main/io/osd.c | 4 ++-- src/main/io/osd.h | 18 +++++++++++------- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main/drivers/display_font_metadata.h b/src/main/drivers/display_font_metadata.h index ebef4b635a..961c6b0751 100644 --- a/src/main/drivers/display_font_metadata.h +++ b/src/main/drivers/display_font_metadata.h @@ -10,11 +10,11 @@ typedef struct displayFontMetadata_s { uint16_t charCount; } displayFontMetadata_t; -// 'I', 'N', 'A', 'V' -#define FONT_CHR_IS_METADATA(chr) ((chr)->data[0] == 'I' && \ - (chr)->data[1] == 'N' && \ - (chr)->data[2] == 'A' && \ - (chr)->data[3] == 'V') +// 'E', 'M', 'U', 'F' +#define FONT_CHR_IS_METADATA(chr) ((chr)->data[0] == 'E' && \ + (chr)->data[1] == 'M' && \ + (chr)->data[2] == 'U' && \ + (chr)->data[3] == 'F') #define FONT_METADATA_CHR_INDEX 255 // Used for runtime detection of display drivers that might diff --git a/src/main/interface/msp_protocol.h b/src/main/interface/msp_protocol.h index 0f7f5d3d7a..8716c30f0c 100644 --- a/src/main/interface/msp_protocol.h +++ b/src/main/interface/msp_protocol.h @@ -64,7 +64,7 @@ // API VERSION #define API_VERSION_MAJOR 1 // increment when major changes are made -#define API_VERSION_MINOR 52 // increment after a release, to set the version for all changes to go into the following release (if no changes to MSP are made between the releases, this can be reverted before the release) +#define API_VERSION_MINOR 53 // increment after a release, to set the version for all changes to go into the following release (if no changes to MSP are made between the releases, this can be reverted before the release) #define API_VERSION_LENGTH 2 diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index da26165c1e..3b7d50938c 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -368,7 +368,7 @@ static const char * const lookupTableRescueSanityType[] = { #ifdef USE_MAX7456 static const char * const lookupTableVideoSystem[] = { - "AUTO", "PAL", "NTSC", "HDZERO" + "AUTO", "PAL", "NTSC", "HD" }; #endif // USE_MAX7456 diff --git a/src/main/io/displayport_hdzero_osd.c b/src/main/io/displayport_hdzero_osd.c index 9bbcae6d0e..da5c54db27 100644 --- a/src/main/io/displayport_hdzero_osd.c +++ b/src/main/io/displayport_hdzero_osd.c @@ -388,8 +388,8 @@ static mspResult_e hdZeroProcessMspCommand(mspPacket_t *cmd, mspPacket_t *reply, const uint8_t cmdMSP = cmd->cmd; reply->cmd = cmd->cmd; if (cmdMSP == MSP_FC_VARIANT) { - //We advertise as ARDU on this port for the prettier font - sbufWriteData(dst, "ARDU", FLIGHT_CONTROLLER_IDENTIFIER_LENGTH); + //We advertise as EMUF on this port for the prettier font + sbufWriteData(dst, "EMUF", FLIGHT_CONTROLLER_IDENTIFIER_LENGTH); return MSP_RESULT_ACK; } diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 745ea9ce5f..937b71c694 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -220,7 +220,7 @@ static const uint8_t osdElementDisplayOrder[] = { OSD_COMPASS_BAR }; -PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 4); +PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 5); /** * Gets the correct altitude symbol for the current unit system @@ -1155,7 +1155,7 @@ void osdInit(displayPort_t *osdDisplayPortToUse) { if (!osdDisplayPortToUse) { return; } - BUILD_BUG_ON(OSD_POS_MAX != OSD_POS(63, 63)); + BUILD_BUG_ON(OSD_POS_MAX != OSD_POS(63, 31)); osdDisplayPort = osdDisplayPortToUse; #ifdef USE_CMS cmsDisplayPortRegister(osdDisplayPort); diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 4667716eb2..886a3080d6 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -28,16 +28,20 @@ extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES]; #define OSD_ELEMENT_BUFFER_LENGTH 32 -#define VISIBLE_FLAG 0x2000 +#define VISIBLE_FLAG 0x0800 #define VISIBLE(x) (x & VISIBLE_FLAG) -#define OSD_POS_MAX 0xFFF -#define OSD_POSCFG_MAX (VISIBLE_FLAG|0xFFF) // For CLI values + +#define OSD_POS_MAX 0x7FF +#define OSD_POSCFG_MAX (VISIBLE_FLAG|0x7FF) // For CLI values // Character coordinate -#define OSD_POSITION_BITS 6 // 6 bits gives a range 0-63 -#define OSD_POSITION_XY_MASK ((1 << OSD_POSITION_BITS) - 1) -#define OSD_POS(x,y) ((x & OSD_POSITION_XY_MASK) | ((y & OSD_POSITION_XY_MASK) << OSD_POSITION_BITS)) -#define OSD_X(x) (x & OSD_POSITION_XY_MASK) +#define OSD_POSITION_BITS 5 // 5 bits gives a range 0-31 +#define OSD_POSITION_BIT_XHD 10 // extra bit used to extend X range in a backward compatible manner for HD displays +#define OSD_POSITION_XHD_MASK (1 << OSD_POSITION_BIT_XHD) +#define OSD_POSITION_XY_MASK ((1 << OSD_POSITION_BITS) - 1) +#define OSD_POS(x,y) ((x & OSD_POSITION_XY_MASK) | ((x << (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS)) & OSD_POSITION_XHD_MASK) | \ + ((y & OSD_POSITION_XY_MASK) << OSD_POSITION_BITS)) +#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) // Timer configuration