From 07e432dfffebf1d1619ee2bacfa4583d0d836c24 Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:29:27 -0600 Subject: [PATCH] HDZERO - make it uint16 again * WIP * definatly needs cleanup * NEEDS osd_potition range range checks; especially in HD --- src/main/interface/msp.c | 6 +++--- src/main/interface/msp_protocol.h | 2 +- src/main/interface/settings.c | 2 +- src/main/io/osd.c | 4 ++-- src/main/io/osd.h | 30 ++++++++++++++++++++++++------ 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/main/interface/msp.c b/src/main/interface/msp.c index bdffb85b36..684b85e213 100644 --- a/src/main/interface/msp.c +++ b/src/main/interface/msp.c @@ -1084,7 +1084,7 @@ bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst) { continue; }; sbufWriteU8(dst, serialConfig()->portConfigs[i].identifier); - sbufWriteU32(dst, serialConfig()->portConfigs[i].functionMask); + sbufWriteU16(dst, serialConfig()->portConfigs[i].functionMask); sbufWriteU8(dst, serialConfig()->portConfigs[i].msp_baudrateIndex); sbufWriteU8(dst, serialConfig()->portConfigs[i].gps_baudrateIndex); sbufWriteU8(dst, serialConfig()->portConfigs[i].telemetry_baudrateIndex); @@ -2219,7 +2219,7 @@ mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src) { } break; case MSP_SET_CF_SERIAL_CONFIG: { - uint8_t portConfigSize = sizeof(uint8_t) + sizeof(uint32_t) + (sizeof(uint8_t) * 4); + uint8_t portConfigSize = sizeof(uint8_t) + sizeof(uint16_t) + (sizeof(uint8_t) * 4); if (dataSize % portConfigSize != 0) { return MSP_RESULT_ERROR; } @@ -2231,7 +2231,7 @@ mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src) { return MSP_RESULT_ERROR; } portConfig->identifier = identifier; - portConfig->functionMask = sbufReadU32(src); + portConfig->functionMask = sbufReadU16(src); portConfig->msp_baudrateIndex = sbufReadU8(src); portConfig->gps_baudrateIndex = sbufReadU8(src); portConfig->telemetry_baudrateIndex = sbufReadU8(src); 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/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..0afd15309e 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -28,18 +28,36 @@ extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES]; #define OSD_ELEMENT_BUFFER_LENGTH 32 -#define VISIBLE_FLAG 0x2000 +//#define VISIBLE_FLAG 0x2000 +#define VISIBLE_FLAG 0x0800 #define VISIBLE(x) (x & VISIBLE_FLAG) -#define OSD_POS_MAX 0xFFF +//#define OSD_POS_MAX 0xFFF +#define OSD_POS_MAX 0x7FF +//#define OSD_POSCFG_MAX (VISIBLE_FLAG|0xFFF) // For CLI values + +//just testing +//#define OSD_POSCFG_MAX UINT16_MAX // element positions now use all 16 bits #define OSD_POSCFG_MAX (VISIBLE_FLAG|0xFFF) // 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 6 // 6 bits gives a range 0-63 +#define OSD_POSITION_BITS 5 // 5 bits gives a range 0-31 +//#define OSD_POSITION_XY_MASK ((1 << OSD_POSITION_BITS) - 1) +#define OSD_POSITION_BIT_XHD 10 // extra bit used to extend X range in a backward compatible manner for HD displays +#define OSD_POSITIION_XHD_MASK (1 << OSD_POSITION_BIT_XHD) +#define OSD_POSITION_XY_MASK ((1 << OSD_POSITION_BITS) - 1) + +//#define OSD_TYPE_MASK 0xC000 // bits 14-15 //maybe not used + +//#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_POS(x,y) ((x & OSD_POSITION_XY_MASK) | ((x << (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS)) & OSD_POSITIION_XHD_MASK) | \ + ((y & OSD_POSITION_XY_MASK) << OSD_POSITION_BITS)) +#define OSD_X(x) ((x & OSD_POSITION_XY_MASK) | ((x & OSD_POSITION_BIT_XHD) >> (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS))) #define OSD_Y(x) ((x >> OSD_POSITION_BITS) & OSD_POSITION_XY_MASK) +//#define OSD_TYPE(x) ((x & OSD_TYPE_MASK) >> 14) //maybe not used + // 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))