Skip to content

Commit 3335565

Browse files
authored
modding HDZero PR #755 to revert to 5bit compatible OSD element positioning. (#958)
* HDZero - 5bit backward compatible OSD positioning * hdzero - 30hz OSD and dont periodically force-advertise fc-variant * hdzero - comment out unused code * hdzero - unneeded comma * hdzero - stupid alignment
1 parent 91c5ad7 commit 3335565

File tree

7 files changed

+45
-35
lines changed

7 files changed

+45
-35
lines changed

src/main/drivers/display_font_metadata.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ typedef struct displayFontMetadata_s {
1010
uint16_t charCount;
1111
} displayFontMetadata_t;
1212

13-
// 'I', 'N', 'A', 'V'
14-
#define FONT_CHR_IS_METADATA(chr) ((chr)->data[0] == 'I' && \
15-
(chr)->data[1] == 'N' && \
16-
(chr)->data[2] == 'A' && \
17-
(chr)->data[3] == 'V')
13+
// 'E', 'M', 'U', 'F'
14+
#define FONT_CHR_IS_METADATA(chr) ((chr)->data[0] == 'E' && \
15+
(chr)->data[1] == 'M' && \
16+
(chr)->data[2] == 'U' && \
17+
(chr)->data[3] == 'F')
1818

1919
#define FONT_METADATA_CHR_INDEX 255
2020
// Used for runtime detection of display drivers that might

src/main/interface/msp_protocol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
// API VERSION
6565

6666
#define API_VERSION_MAJOR 1 // increment when major changes are made
67-
#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)
67+
#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)
6868

6969
#define API_VERSION_LENGTH 2
7070

src/main/interface/settings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static const char * const lookupTableRescueSanityType[] = {
368368

369369
#ifdef USE_MAX7456
370370
static const char * const lookupTableVideoSystem[] = {
371-
"AUTO", "PAL", "NTSC", "HDZERO"
371+
"AUTO", "PAL", "NTSC", "HD"
372372
};
373373
#endif // USE_MAX7456
374374

src/main/io/displayport_hdzero_osd.c

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ FILE_COMPILE_FOR_SPEED
5656
#define MSP_WRITE_STRING 3
5757
#define MSP_DRAW_SCREEN 4
5858
#define MSP_SET_OPTIONS 5
59-
#define DRAW_FREQ_DENOM 4 // 60Hz
59+
//#define DRAW_FREQ_DENOM 4 // 60Hz
60+
#define DRAW_FREQ_DENOM 8 // 30Hz
6061
#define TX_BUFFER_SIZE 1024
6162
#define VTX_TIMEOUT 1000 // 1 second timer
6263

@@ -279,25 +280,27 @@ static uint32_t txBytesFree(const displayPort_t *displayPort)
279280
return mspSerialTxBytesFree();
280281
}
281282

282-
static bool getFontMetadata(displayFontMetadata_t *metadata, const displayPort_t *displayPort)
283-
{
284-
UNUSED(displayPort);
285-
metadata->charCount = 512;
286-
metadata->version = FONT_VERSION;
287-
return true;
288-
}
283+
//Commented out as compiler reports unused.
284+
//static bool getFontMetadata(displayFontMetadata_t *metadata, const displayPort_t *displayPort)
285+
//{
286+
// UNUSED(displayPort);
287+
// metadata->charCount = 512;
288+
// metadata->version = FONT_VERSION;
289+
// return true;
290+
//}
289291

290292
static bool isTransferInProgress(const displayPort_t *displayPort)
291293
{
292294
UNUSED(displayPort);
293295
return false;
294296
}
295297

296-
static bool isReady(displayPort_t *displayPort)
297-
{
298-
UNUSED(displayPort);
299-
return vtxActive;
300-
}
298+
//Commented out as compiler reports unused.
299+
//static bool isReady(displayPort_t *displayPort)
300+
//{
301+
// UNUSED(displayPort);
302+
// return vtxActive;
303+
//}
301304

302305
static int grab(displayPort_t *displayPort)
303306
{
@@ -383,15 +386,18 @@ static mspResult_e hdZeroProcessMspCommand(mspPacket_t *cmd, mspPacket_t *reply,
383386
vtxSeen = vtxActive = true;
384387
vtxHeartbeat = millis();
385388

386-
sbuf_t *dst = &reply->buf;
389+
//Commented out as compiler reports unused.
390+
//sbuf_t *dst = &reply->buf;
387391

388392
const uint8_t cmdMSP = cmd->cmd;
389393
reply->cmd = cmd->cmd;
390-
if (cmdMSP == MSP_FC_VARIANT) {
391-
//We advertise as ARDU on this port for the prettier font
392-
sbufWriteData(dst, "ARDU", FLIGHT_CONTROLLER_IDENTIFIER_LENGTH);
393-
return MSP_RESULT_ACK;
394-
}
394+
395+
//Apparently no longer required as HDZero will send the MSP/EEPROM value of "EMUF" fc_variant
396+
//if (cmdMSP == MSP_FC_VARIANT) {
397+
// //We advertise as EMUF on this port for the prettier font
398+
// sbufWriteData(dst, "EMUF", FLIGHT_CONTROLLER_IDENTIFIER_LENGTH);
399+
// return MSP_RESULT_ACK;
400+
//}
395401

396402
// #define MSP_SET_VTXTABLE_BAND 227
397403
// #define MSP_SET_VTXTABLE_POWERLEVEL 228

src/main/io/osd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static const uint8_t osdElementDisplayOrder[] = {
220220
OSD_COMPASS_BAR
221221
};
222222

223-
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 4);
223+
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 5);
224224

225225
/**
226226
* Gets the correct altitude symbol for the current unit system
@@ -1155,7 +1155,7 @@ void osdInit(displayPort_t *osdDisplayPortToUse) {
11551155
if (!osdDisplayPortToUse) {
11561156
return;
11571157
}
1158-
BUILD_BUG_ON(OSD_POS_MAX != OSD_POS(63, 63));
1158+
BUILD_BUG_ON(OSD_POS_MAX != OSD_POS(63, 31));
11591159
osdDisplayPort = osdDisplayPortToUse;
11601160
#ifdef USE_CMS
11611161
cmsDisplayPortRegister(osdDisplayPort);

src/main/io/osd.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES];
3030

3131
#define VISIBLE_FLAG 0x2000
3232
#define VISIBLE(x) (x & VISIBLE_FLAG)
33-
#define OSD_POS_MAX 0xFFF
34-
#define OSD_POSCFG_MAX (VISIBLE_FLAG|0xFFF) // For CLI values
33+
34+
#define OSD_POS_MAX 0x7FF
35+
#define OSD_POSCFG_MAX (VISIBLE_FLAG|0x7FF) // For CLI values
3536

3637
// Character coordinate
37-
#define OSD_POSITION_BITS 6 // 6 bits gives a range 0-63
38-
#define OSD_POSITION_XY_MASK ((1 << OSD_POSITION_BITS) - 1)
39-
#define OSD_POS(x,y) ((x & OSD_POSITION_XY_MASK) | ((y & OSD_POSITION_XY_MASK) << OSD_POSITION_BITS))
40-
#define OSD_X(x) (x & OSD_POSITION_XY_MASK)
38+
#define OSD_POSITION_BITS 5 // 5 bits gives a range 0-31
39+
#define OSD_POSITION_BIT_XHD 10 // extra bit used to extend X range in a backward compatible manner for HD displays
40+
#define OSD_POSITION_XHD_MASK (1 << OSD_POSITION_BIT_XHD)
41+
#define OSD_POSITION_XY_MASK ((1 << OSD_POSITION_BITS) - 1)
42+
#define OSD_POS(x,y) ((x & OSD_POSITION_XY_MASK) | ((x << (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS)) & OSD_POSITION_XHD_MASK) | \
43+
((y & OSD_POSITION_XY_MASK) << OSD_POSITION_BITS))
44+
#define OSD_X(x) ((x & OSD_POSITION_XY_MASK) | ((x & OSD_POSITION_XHD_MASK) >> (OSD_POSITION_BIT_XHD - OSD_POSITION_BITS)))
4145
#define OSD_Y(x) ((x >> OSD_POSITION_BITS) & OSD_POSITION_XY_MASK)
4246

4347
// Timer configuration

src/main/io/serial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef enum {
5050
FUNCTION_VTX_TRAMP = (1 << 13), // 8192
5151
FUNCTION_RCDEVICE = (1 << 14), // 16384
5252
FUNCTION_LIDAR_TF = (1 << 15), // 32768
53-
FUNCTION_HDZERO_OSD = (1 << 16), // 65536
53+
FUNCTION_HDZERO_OSD = (1 << 16) // 65536
5454
} serialPortFunction_e;
5555

5656
#define TELEMETRY_SHAREABLE_PORT_FUNCTIONS_MASK (FUNCTION_TELEMETRY_FRSKY_HUB | FUNCTION_TELEMETRY_LTM | FUNCTION_TELEMETRY_MAVLINK)

0 commit comments

Comments
 (0)