mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
Fix OSD defaults based on SD/HD (#13320)
Fix OSD defaults based on SD/HD and validate changing video_system to/from HD
This commit is contained in:
parent
42267349db
commit
17e43e3363
4 changed files with 42 additions and 10 deletions
|
@ -891,7 +891,13 @@ void init(void)
|
|||
//The OSD need to be initialised after GYRO to avoid GYRO initialisation failure on some targets
|
||||
|
||||
if (featureIsEnabled(FEATURE_OSD)) {
|
||||
osdDisplayPortDevice_e device = osdConfig()->displayPortDevice;
|
||||
osdDisplayPortDevice_e device;
|
||||
|
||||
if (vcdProfile()->video_system == VIDEO_SYSTEM_HD) {
|
||||
device = OSD_DISPLAYPORT_DEVICE_MSP;
|
||||
} else {
|
||||
device = osdConfig()->displayPortDevice;
|
||||
}
|
||||
|
||||
switch(device) {
|
||||
|
||||
|
|
|
@ -4174,17 +4174,30 @@ static mspResult_e mspCommonProcessInCommand(mspDescriptor_t srcDesc, int16_t cm
|
|||
if ((int8_t)addr == -1) {
|
||||
/* Set general OSD settings */
|
||||
videoSystem_e video_system = sbufReadU8(src);
|
||||
#ifndef USE_OSD_HD
|
||||
if (video_system == VIDEO_SYSTEM_HD) {
|
||||
video_system = VIDEO_SYSTEM_AUTO;
|
||||
}
|
||||
#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
|
||||
#ifdef USE_OSD_HD
|
||||
// If an HD build, 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;
|
||||
// Also force use of MSP displayport
|
||||
osdConfigMutable()->displayPortDevice = OSD_DISPLAYPORT_DEVICE_MSP;
|
||||
#else
|
||||
// must have an SD build option, keep existing SD video_system, do not change canvas size
|
||||
video_system = vcdProfile()->video_system;
|
||||
#endif
|
||||
} else if ((video_system != VIDEO_SYSTEM_HD) && (vcdProfile()->video_system == VIDEO_SYSTEM_HD)) {
|
||||
// Switching away from HD to SD
|
||||
#ifdef USE_OSD_SD
|
||||
// SD is in the build; set canvas size to SD and displayport device to auto
|
||||
osdConfigMutable()->canvas_cols = OSD_SD_COLS;
|
||||
osdConfigMutable()->canvas_rows = (video_system == VIDEO_SYSTEM_NTSC) ? VIDEO_LINES_NTSC : VIDEO_LINES_PAL;
|
||||
osdConfigMutable()->displayPortDevice = OSD_DISPLAYPORT_DEVICE_AUTO;
|
||||
#else
|
||||
// must have an HD build option, keep existing HD video_system, do not change canvas size
|
||||
video_system = VIDEO_SYSTEM_HD;
|
||||
#endif
|
||||
}
|
||||
|
||||
vcdProfileMutable()->video_system = video_system;
|
||||
|
|
|
@ -401,8 +401,6 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
osdConfig->rcChannels[i] = -1;
|
||||
}
|
||||
|
||||
osdConfig->displayPortDevice = OSD_DISPLAYPORT_DEVICE_AUTO;
|
||||
|
||||
osdConfig->distance_alarm = 0;
|
||||
osdConfig->logo_on_arming = OSD_LOGO_ARMING_OFF;
|
||||
osdConfig->logo_on_arming_duration = 5; // 0.5 seconds
|
||||
|
@ -423,9 +421,11 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
|
||||
// Make it obvious on the configurator that the FC doesn't support HD
|
||||
#ifdef USE_OSD_HD
|
||||
osdConfig->displayPortDevice = OSD_DISPLAYPORT_DEVICE_MSP;
|
||||
osdConfig->canvas_cols = OSD_HD_COLS;
|
||||
osdConfig->canvas_rows = OSD_HD_ROWS;
|
||||
#else
|
||||
osdConfig->displayPortDevice = OSD_DISPLAYPORT_DEVICE_AUTO;
|
||||
osdConfig->canvas_cols = OSD_SD_COLS;
|
||||
osdConfig->canvas_rows = OSD_SD_ROWS;
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,20 @@
|
|||
#include "pg/pg.h"
|
||||
#include "pg/pg_ids.h"
|
||||
|
||||
#include "drivers/osd.h"
|
||||
|
||||
#include "vcd.h"
|
||||
|
||||
// no template required since defaults are zero
|
||||
PG_REGISTER(vcdProfile_t, vcdProfile, PG_VCD_CONFIG, 0);
|
||||
PG_REGISTER_WITH_RESET_FN(vcdProfile_t, vcdProfile, PG_VCD_CONFIG, 0);
|
||||
|
||||
void pgResetFn_vcdProfile(vcdProfile_t *vcdProfile)
|
||||
{
|
||||
// Make it obvious on the configurator that the FC doesn't support HD
|
||||
#ifdef USE_OSD_HD
|
||||
vcdProfile->video_system = VIDEO_SYSTEM_HD;
|
||||
#else
|
||||
vcdProfile->video_system = VIDEO_SYSTEM_AUTO;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue