Skip to content

Commit

Permalink
HDZERO - make it uint16 again
Browse files Browse the repository at this point in the history
* WIP
* definatly needs cleanup
* NEEDS osd_potition range range checks; especially in HD
  • Loading branch information
nerdCopter committed Nov 29, 2023
1 parent 9f3efcc commit 07e432d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/main/interface/msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/interface/msp_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/main/interface/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
30 changes: 24 additions & 6 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 07e432d

Please sign in to comment.