1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 13:25:30 +03:00

Add osd_canvas_width/height variables (#12164)

This commit is contained in:
Steve Evans 2023-01-10 02:25:22 +00:00 committed by GitHub
parent 7dd0f60544
commit 1e3fcbfcee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 11 deletions

View file

@ -1465,6 +1465,8 @@ const clivalue_t valueTable[] = {
{ "osd_aux_channel", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 1, MAX_SUPPORTED_RC_CHANNEL_COUNT }, PG_OSD_CONFIG, offsetof(osdConfig_t, aux_channel) }, { "osd_aux_channel", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 1, MAX_SUPPORTED_RC_CHANNEL_COUNT }, PG_OSD_CONFIG, offsetof(osdConfig_t, aux_channel) },
{ "osd_aux_scale", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 1, 1000 }, PG_OSD_CONFIG, offsetof(osdConfig_t, aux_scale) }, { "osd_aux_scale", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 1, 1000 }, PG_OSD_CONFIG, offsetof(osdConfig_t, aux_scale) },
{ "osd_aux_symbol", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 255 }, PG_OSD_CONFIG, offsetof(osdConfig_t, aux_symbol) }, { "osd_aux_symbol", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 255 }, PG_OSD_CONFIG, offsetof(osdConfig_t, aux_symbol) },
{ "osd_canvas_width", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 63 }, PG_OSD_CONFIG, offsetof(osdConfig_t, canvas_cols) },
{ "osd_canvas_height", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 31 }, PG_OSD_CONFIG, offsetof(osdConfig_t, canvas_rows) },
#endif // end of #ifdef USE_OSD #endif // end of #ifdef USE_OSD
#ifdef USE_CRAFTNAME_MSGS #ifdef USE_CRAFTNAME_MSGS

View file

@ -205,6 +205,8 @@ static displayPort_t *displayPortCrsfInit(void)
crsfDisplayPortSetDimensions(CRSF_DISPLAY_PORT_ROWS_MAX, CRSF_DISPLAY_PORT_COLS_MAX); crsfDisplayPortSetDimensions(CRSF_DISPLAY_PORT_ROWS_MAX, CRSF_DISPLAY_PORT_COLS_MAX);
displayInit(&crsfDisplayPort, &crsfDisplayPortVTable, DISPLAYPORT_DEVICE_TYPE_CRSF); displayInit(&crsfDisplayPort, &crsfDisplayPortVTable, DISPLAYPORT_DEVICE_TYPE_CRSF);
crsfRedraw(&crsfDisplayPort);
return &crsfDisplayPort; return &crsfDisplayPort;
} }

View file

@ -33,6 +33,8 @@
#include "io/displayport_frsky_osd.h" #include "io/displayport_frsky_osd.h"
#include "io/frsky_osd.h" #include "io/frsky_osd.h"
#include "osd/osd.h"
static displayPort_t frskyOsdDisplayPort; static displayPort_t frskyOsdDisplayPort;
static int grab(displayPort_t *displayPort) static int grab(displayPort_t *displayPort)
@ -496,6 +498,8 @@ displayPort_t *frskyOsdDisplayPortInit(const videoSystem_e videoSystem)
{ {
if (frskyOsdInit(videoSystem)) { if (frskyOsdInit(videoSystem)) {
displayInit(&frskyOsdDisplayPort, &frskyOsdVTable, DISPLAYPORT_DEVICE_TYPE_FRSKYOSD); displayInit(&frskyOsdDisplayPort, &frskyOsdVTable, DISPLAYPORT_DEVICE_TYPE_FRSKYOSD);
frskyOsdDisplayPort.cols = OSD_SD_COLS;
frskyOsdDisplayPort.rows = OSD_SD_ROWS;
redraw(&frskyOsdDisplayPort); redraw(&frskyOsdDisplayPort);
return &frskyOsdDisplayPort; return &frskyOsdDisplayPort;
} }

View file

@ -182,9 +182,6 @@ static bool checkReady(displayPort_t *displayPort, bool rescan)
} }
} }
displayPort->rows = max7456GetRowsCount() + displayPortProfileMax7456()->rowAdjust;
displayPort->cols = 30 + displayPortProfileMax7456()->colAdjust;
return true; return true;
} }
@ -247,6 +244,26 @@ bool max7456DisplayPortInit(const vcdProfile_t *vcdProfile, displayPort_t **disp
break; break;
} }
uint8_t displayRows;
switch(vcdProfile->video_system) {
default:
case VIDEO_SYSTEM_PAL:
displayRows = VIDEO_LINES_PAL;
break;
case VIDEO_SYSTEM_NTSC:
displayRows = VIDEO_LINES_NTSC;
break;
case VIDEO_SYSTEM_AUTO:
displayRows = max7456GetRowsCount();
break;
}
max7456DisplayPort.rows = displayRows + displayPortProfileMax7456()->rowAdjust;
max7456DisplayPort.cols = 30 + displayPortProfileMax7456()->colAdjust;
return true; return true;
} }
#endif // USE_MAX7456 #endif // USE_MAX7456

View file

@ -165,14 +165,6 @@ static bool isSynced(const displayPort_t *displayPort)
static void redraw(displayPort_t *displayPort) static void redraw(displayPort_t *displayPort)
{ {
if (vcdProfile()->video_system == VIDEO_SYSTEM_HD) {
displayPort->rows = osdConfig()->canvas_rows;
displayPort->cols = osdConfig()->canvas_cols;
} else {
const uint8_t displayRows = (vcdProfile()->video_system == VIDEO_SYSTEM_PAL) ? VIDEO_LINES_PAL : VIDEO_LINES_NTSC;
displayPort->rows = displayRows + displayPortProfileMsp()->rowAdjust;
displayPort->cols = OSD_SD_COLS + displayPortProfileMsp()->colAdjust;
}
drawScreen(displayPort); drawScreen(displayPort);
} }
@ -220,7 +212,17 @@ displayPort_t *displayPortMspInit(void)
} }
#endif #endif
if (vcdProfile()->video_system == VIDEO_SYSTEM_HD) {
mspDisplayPort.rows = osdConfig()->canvas_rows;
mspDisplayPort.cols = osdConfig()->canvas_cols;
} else {
const uint8_t displayRows = (vcdProfile()->video_system == VIDEO_SYSTEM_PAL) ? VIDEO_LINES_PAL : VIDEO_LINES_NTSC;
mspDisplayPort.rows = displayRows + displayPortProfileMsp()->rowAdjust;
mspDisplayPort.cols = OSD_SD_COLS + displayPortProfileMsp()->colAdjust;
}
redraw(&mspDisplayPort); redraw(&mspDisplayPort);
return &mspDisplayPort; return &mspDisplayPort;
} }

View file

@ -4087,6 +4087,14 @@ static mspResult_e mspCommonProcessInCommand(mspDescriptor_t srcDesc, int16_t cm
video_system = VIDEO_SYSTEM_AUTO; video_system = VIDEO_SYSTEM_AUTO;
} }
#endif #endif
if ((video_system == VIDEO_SYSTEM_HD) && (vcdProfile()->video_system != VIDEO_SYSTEM_HD)) {
// If switching to HD, don't wait for the VTX to communicate the correct resolution, just
// increase the canvas size to the HD default as that is what the user will expect
osdConfigMutable()->canvas_cols = OSD_HD_COLS;
osdConfigMutable()->canvas_rows = OSD_HD_ROWS;
}
vcdProfileMutable()->video_system = video_system; vcdProfileMutable()->video_system = video_system;
osdConfigMutable()->units = sbufReadU8(src); osdConfigMutable()->units = sbufReadU8(src);

View file

@ -512,6 +512,14 @@ void osdInit(displayPort_t *osdDisplayPortToUse, osdDisplayPortDevice_e displayP
#endif #endif
if (osdDisplayPort->cols && osdDisplayPort->rows) { if (osdDisplayPort->cols && osdDisplayPort->rows) {
// Ensure that osd_canvas_width/height are correct
if (osdConfig()->canvas_cols != osdDisplayPort->cols) {
osdConfigMutable()->canvas_cols = osdDisplayPort->cols;
}
if (osdConfig()->canvas_rows != osdDisplayPort->rows) {
osdConfigMutable()->canvas_rows = osdDisplayPort->rows;
}
// Ensure that all OSD elements are on the canvas once number of row/columns is known // Ensure that all OSD elements are on the canvas once number of row/columns is known
for (int i = 0; i < OSD_ITEM_COUNT; i++) { for (int i = 0; i < OSD_ITEM_COUNT; i++) {
uint16_t itemPos = osdElementConfig()->item_pos[i]; uint16_t itemPos = osdElementConfig()->item_pos[i];