Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MSP_OSD_CANVAS/MSP_SET_OSD_CANVAS for completeness #10465

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/drivers/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 29 additions & 0 deletions src/main/fc/fc_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2044,6 +2057,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
Expand Down
2 changes: 1 addition & 1 deletion src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
37 changes: 9 additions & 28 deletions src/main/io/displayport_msp_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -289,18 +269,18 @@ 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;

int next = BITARRAY_FIND_FIRST_SET(dirty, 0);
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]);

Expand Down Expand Up @@ -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;
Expand Down
24 changes: 23 additions & 1 deletion src/main/io/displayport_msp_osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
uint8_t setAttrVersion(uint8_t origAttr, uint8_t page);
4 changes: 4 additions & 0 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ typedef struct osdConfig_s {
uint16_t adsb_ignore_plane_above_me_limit; // in metres
#endif
uint8_t radar_peers_display_time; // in seconds
#ifdef USE_MSP_DISPLAYPORT
uint8_t osd_autohd_cols;
uint8_t osd_autohd_rows;
#endif
} osdConfig_t;

PG_DECLARE(osdConfig_t, osdConfig);
Expand Down
3 changes: 3 additions & 0 deletions src/main/msp/msp_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down