Skip to content

Commit

Permalink
HDZero - 5bit backward compatible OSD positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdCopter committed Dec 17, 2023
1 parent e6aab0f commit 8377001
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/main/drivers/display_font_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
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/displayport_hdzero_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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
18 changes: 11 additions & 7 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8377001

Please sign in to comment.