diff --git a/src/main/drivers/osd.h b/src/main/drivers/osd.h index a8b0bbc8e42..e1f2658c200 100644 --- a/src/main/drivers/osd.h +++ b/src/main/drivers/osd.h @@ -50,7 +50,8 @@ typedef enum { VIDEO_SYSTEM_DJIWTF, VIDEO_SYSTEM_AVATAR, VIDEO_SYSTEM_DJICOMPAT, - VIDEO_SYSTEM_DJICOMPAT_HD + VIDEO_SYSTEM_DJICOMPAT_HD, + VIDEO_SYSTEM_AUTOHD } videoSystem_e; typedef enum { diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 0125b4ce914..acbaa71160c 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -87,6 +87,7 @@ #include "io/adsb.h" #include "io/asyncfatfs/asyncfatfs.h" +#include "io/displayport_msp_osd.h" #include "io/flashfs.h" #include "io/gps.h" #include "io/gps_ublox.h" @@ -1186,6 +1187,18 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF serializeSDCardSummaryReply(dst); break; +#ifdef USE_MSP_DISPLAYPORT + case MSP_OSD_CANVAS: + { + displayPort_t *dp = osdGetDisplayPort(); + if(dp != NULL) { + sbufWriteU8(dst, dp->cols); + sbufWriteU8(dst, dp->rows); + } + } + break; +#endif + #if defined (USE_DJI_HD_OSD) || defined (USE_MSP_DISPLAYPORT) case MSP_BATTERY_STATE: // Battery characteristics @@ -2099,6 +2112,22 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; +#ifdef USE_MSP_DISPLAYPORT + case MSP_SET_OSD_CANVAS: + { + if (osdConfig()->video_system == VIDEO_SYSTEM_AUTOHD) { + displayPort_t *dp = osdGetDisplayPort(); + if (dp != NULL) { + dp->cols = constrain(sbufReadU8(src), 30, MSP_DISPLAYPORT_MAX_COLS); + dp->rows = constrain(sbufReadU8(src), 16, MSP_DISPLAYPORT_MAX_ROWS); + } else { + return MSP_RESULT_ERROR; + } + } + } + break; +#endif + case MSP2_INAV_SET_MISC: if (dataSize == 41) { sbufReadU16(src); // midrc diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index cb27208091e..72da50f8510 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -67,7 +67,7 @@ tables: values: ["MAH", "WH"] enum: osd_stats_energy_unit_e - name: osd_video_system - values: ["AUTO", "PAL", "NTSC", "HDZERO", "DJIWTF", "AVATAR", "BF43COMPAT", "BFHDCOMPAT"] + values: ["AUTO", "PAL", "NTSC", "HDZERO", "DJIWTF", "AVATAR", "BF43COMPAT", "BFHDCOMPAT", "AUTOHD"] enum: videoSystem_e - name: osd_telemetry values: ["OFF", "ON","TEST"] diff --git a/src/main/io/displayport_msp_osd.c b/src/main/io/displayport_msp_osd.c index 0b9be8c6d86..abf5e4a2133 100644 --- a/src/main/io/displayport_msp_osd.c +++ b/src/main/io/displayport_msp_osd.c @@ -74,28 +74,8 @@ static bool vtxSeen, vtxActive, vtxReset; static timeMs_t vtxHeartbeat; static timeMs_t sendSubFrameMs = 0; -// PAL screen size -#define PAL_COLS 30 -#define PAL_ROWS 16 -// NTSC screen size -#define NTSC_COLS 30 -#define NTSC_ROWS 13 -// HDZERO screen size -#define HDZERO_COLS 50 -#define HDZERO_ROWS 18 -// Avatar screen size -#define AVATAR_COLS 53 -#define AVATAR_ROWS 20 -// DJIWTF screen size -#define DJI_COLS 60 -#define DJI_ROWS 22 - -// set COLS and ROWS to largest size available -#define COLS DJI_COLS -#define ROWS DJI_ROWS - // set screen size -#define SCREENSIZE (ROWS*COLS) +#define SCREENSIZE (MSP_DISPLAYPORT_MAX_ROWS * MSP_DISPLAYPORT_MAX_COLS) static uint8_t currentOsdMode; // HDZero screen mode can change across layouts @@ -212,7 +192,7 @@ static bool readChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint1 { UNUSED(displayPort); - uint16_t pos = (row * COLS) + col; + uint16_t pos = (row * MSP_DISPLAYPORT_MAX_COLS) + col; if (pos >= SCREENSIZE) { return false; } @@ -248,14 +228,14 @@ static int writeChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint1 { UNUSED(displayPort); - return setChar((row * COLS) + col, c, attr); + return setChar((row * MSP_DISPLAYPORT_MAX_COLS) + col, c, attr); } static int writeString(displayPort_t *displayPort, uint8_t col, uint8_t row, const char *string, textAttributes_t attr) { UNUSED(displayPort); - uint16_t pos = (row * COLS) + col; + uint16_t pos = (row * MSP_DISPLAYPORT_MAX_COLS) + col; while (*string) { setChar(pos++, *string++, attr); } @@ -289,7 +269,7 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz sendSubFrameMs = (osdConfig()->msp_displayport_fullframe_interval > 0) ? (millis() + DS2MS(osdConfig()->msp_displayport_fullframe_interval)) : 0; } - uint8_t subcmd[COLS + 4]; + uint8_t subcmd[MSP_DISPLAYPORT_MAX_COLS + 4]; uint8_t updateCount = 0; subcmd[0] = MSP_DP_WRITE_STRING; @@ -297,10 +277,10 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz while (next >= 0) { // Look for sequential dirty characters on the same line for the same font page int pos = next; - uint8_t row = pos / COLS; - uint8_t col = pos % COLS; + uint8_t row = pos / MSP_DISPLAYPORT_MAX_COLS; + uint8_t col = pos % MSP_DISPLAYPORT_MAX_COLS; uint8_t attributes = 0; - int endOfLine = row * COLS + screenCols; + int endOfLine = row * MSP_DISPLAYPORT_MAX_COLS + screenCols; uint8_t page = getAttrPage(attrs[pos]); uint8_t blink = getAttrBlink(attrs[pos]); @@ -481,6 +461,7 @@ displayPort_t* mspOsdDisplayPortInit(const videoSystem_e videoSystem) screenRows = HDZERO_ROWS; screenCols = HDZERO_COLS; break; + case VIDEO_SYSTEM_AUTOHD: case VIDEO_SYSTEM_DJIWTF: currentOsdMode = HD_6022; screenRows = DJI_ROWS; diff --git a/src/main/io/displayport_msp_osd.h b/src/main/io/displayport_msp_osd.h index affd5b39be5..5d8db7bd608 100644 --- a/src/main/io/displayport_msp_osd.h +++ b/src/main/io/displayport_msp_osd.h @@ -36,6 +36,28 @@ #define DISPLAYPORT_MSP_ATTR_BLINK_MASK (1 << DISPLAYPORT_MSP_ATTR_BLINK) #define DISPLAYPORT_MSP_ATTR_VERSION_MASK (1 << DISPLAYPORT_MSP_ATTR_VERSION) +// PAL screen size +#define PAL_COLS 30 +#define PAL_ROWS 16 +// NTSC screen size +#define NTSC_COLS 30 +#define NTSC_ROWS 13 +// HDZERO screen size +#define HDZERO_COLS 50 +#define HDZERO_ROWS 18 +// Avatar screen size +#define AVATAR_COLS 53 +#define AVATAR_ROWS 20 +// DJIWTF screen size +#define DJI_COLS 60 +#define DJI_ROWS 22 + +// set COLS and ROWS to largest size available +#define MSP_DISPLAYPORT_MAX_COLS DJI_COLS +#define MSP_DISPLAYPORT_MAX_ROWS DJI_ROWS + + + typedef struct displayPort_s displayPort_t; displayPort_t *mspOsdDisplayPortInit(const videoSystem_e videoSystem); @@ -48,4 +70,4 @@ mspPort_t *getMspOsdPort(void); uint8_t setAttrPage(uint8_t origAttr, uint8_t page); uint8_t setAttrBlink(uint8_t origAttr, uint8_t page); -uint8_t setAttrVersion(uint8_t origAttr, uint8_t page); \ No newline at end of file +uint8_t setAttrVersion(uint8_t origAttr, uint8_t page); diff --git a/src/main/io/osd.c b/src/main/io/osd.c index a88bfc0012c..59f156ac1e5 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -224,7 +224,7 @@ static bool osdDisplayHasCanvas; #define AH_MAX_PITCH_DEFAULT 20 // Specify default maximum AHI pitch value displayed (degrees) -PG_REGISTER_WITH_RESET_TEMPLATE(osdConfig_t, osdConfig, PG_OSD_CONFIG, 14); +PG_REGISTER_WITH_RESET_TEMPLATE(osdConfig_t, osdConfig, PG_OSD_CONFIG, 15); PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 3); void osdStartedSaveProcess(void) { diff --git a/src/main/io/osd.h b/src/main/io/osd.h index a8e74e4d651..a59ff377f76 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -497,7 +497,11 @@ typedef struct osdConfig_s { uint8_t radar_peers_display_time; // in seconds #ifdef USE_GEOZONE uint8_t geozoneDistanceWarning; // Distance to fence or action - bool geozoneDistanceType; // Shows a countdown timer or distance to fence/action + bool geozoneDistanceType; // Shows a countdown timer or distance to fence/action +#endif +#ifdef USE_MSP_DISPLAYPORT + uint8_t osd_autohd_cols; + uint8_t osd_autohd_rows; #endif } osdConfig_t; diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index ac847afeaec..7bdd11fcc28 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -257,6 +257,9 @@ #define MSP_LED_STRIP_MODECOLOR 127 //out message Get LED strip mode_color settings #define MSP_BATTERY_STATE 130 // DJI googles fc battery info +#define MSP_SET_OSD_CANVAS 188 // Sent from VTX to inform OSD canvas size +#define MSP_OSD_CANVAS 189 // Sent from FC to inform configurator about canvas size + #define MSP_SET_RAW_RC 200 //in message 8 rc chan #define MSP_SET_RAW_GPS 201 //in message fix, numsat, lat, lon, alt, speed #define MSP_SET_BOX 203 //in message BOX setup (number is dependant of your setup)