Skip to content

Commit

Permalink
Merge pull request #9807 from mikeller/fix_osd_device_reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeller committed May 27, 2020
2 parents 23a9ea4 + 98efe1a commit 6bada9c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/main/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -4741,10 +4741,10 @@ static void cliStatus(const char *cmdName, char *cmdline)
#endif /* USE_SENSOR_NAMES */

#if defined(USE_OSD)
osdDisplayPortDevice_e displayPortDevice;
osdGetDisplayPort(&displayPortDevice);
osdDisplayPortDevice_e displayPortDeviceType;
osdGetDisplayPort(&displayPortDeviceType);

cliPrintLinef("OSD: %s", lookupTableOsdDisplayPortDevice[displayPortDevice]);
cliPrintLinef("OSD: %s", lookupTableOsdDisplayPortDevice[displayPortDeviceType]);
#endif

// Uptime and wall clock
Expand Down
3 changes: 2 additions & 1 deletion src/main/fc/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,9 @@ void init(void)

#if defined(USE_CMS) && defined(USE_MSP_DISPLAYPORT)
// If BFOSD is not active, then register MSP_DISPLAYPORT as a CMS device.
if (!osdDisplayPort)
if (!osdDisplayPort) {
cmsDisplayPortRegister(displayPortMspInit());
}
#endif

#ifdef USE_DASHBOARD
Expand Down
38 changes: 18 additions & 20 deletions src/main/msp/msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,27 +886,25 @@ static bool mspCommonProcessOutCommand(int16_t cmdMSP, sbuf_t *dst, mspPostProce
#if defined(USE_OSD)
osdFlags |= OSD_FLAGS_OSD_FEATURE;

osdDisplayPortDevice_e device = OSD_DISPLAYPORT_DEVICE_NONE;
displayPort_t *osdDisplayPort = osdGetDisplayPort(&device);
if (osdDisplayPort) {
switch (device) {
case OSD_DISPLAYPORT_DEVICE_NONE:
case OSD_DISPLAYPORT_DEVICE_AUTO:
break;
case OSD_DISPLAYPORT_DEVICE_MAX7456:
osdFlags |= OSD_FLAGS_OSD_HARDWARE_MAX_7456;
break;
case OSD_DISPLAYPORT_DEVICE_MSP:
break;
case OSD_DISPLAYPORT_DEVICE_FRSKYOSD:
osdFlags |= OSD_FLAGS_OSD_HARDWARE_FRSKYOSD;
break;
}
if (osdFlags | (OSD_FLAGS_OSD_HARDWARE_MAX_7456 | OSD_FLAGS_OSD_HARDWARE_FRSKYOSD)) {
if (displayIsReady(osdDisplayPort)) {
osdFlags |= OSD_FLAGS_OSD_DEVICE_DETECTED;
}
osdDisplayPortDevice_e deviceType;
displayPort_t *osdDisplayPort = osdGetDisplayPort(&deviceType);
switch (deviceType) {
case OSD_DISPLAYPORT_DEVICE_MAX7456:
osdFlags |= OSD_FLAGS_OSD_HARDWARE_MAX_7456;
if (osdDisplayPort && displayIsReady(osdDisplayPort)) {
osdFlags |= OSD_FLAGS_OSD_DEVICE_DETECTED;
}

break;
case OSD_DISPLAYPORT_DEVICE_FRSKYOSD:
osdFlags |= OSD_FLAGS_OSD_HARDWARE_FRSKYOSD;
if (osdDisplayPort && displayIsReady(osdDisplayPort)) {
osdFlags |= OSD_FLAGS_OSD_DEVICE_DETECTED;
}

break;
default:
break;
}
#endif
sbufWriteU8(dst, osdFlags);
Expand Down
13 changes: 7 additions & 6 deletions src/main/osd/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static uint8_t armState;
static uint8_t osdProfile = 1;
#endif
static displayPort_t *osdDisplayPort;
static osdDisplayPortDevice_e osdDisplayPortDevice;
static osdDisplayPortDevice_e osdDisplayPortDeviceType;
static bool osdIsReady;

static bool suppressStatsDisplay = false;
Expand Down Expand Up @@ -415,14 +415,15 @@ static void osdCompleteInitialization(void)
osdIsReady = true;
}

void osdInit(displayPort_t *osdDisplayPortToUse, osdDisplayPortDevice_e displayPortDeviceToUse)
void osdInit(displayPort_t *osdDisplayPortToUse, osdDisplayPortDevice_e displayPortDeviceType)
{
osdDisplayPortDeviceType = displayPortDeviceType;

if (!osdDisplayPortToUse) {
return;
}

osdDisplayPort = osdDisplayPortToUse;
osdDisplayPortDevice = displayPortDeviceToUse;
#ifdef USE_CMS
cmsDisplayPortRegister(osdDisplayPort);
#endif
Expand Down Expand Up @@ -1078,10 +1079,10 @@ bool osdNeedsAccelerometer(void)
}
#endif // USE_ACC

displayPort_t *osdGetDisplayPort(osdDisplayPortDevice_e *displayPortDevice)
displayPort_t *osdGetDisplayPort(osdDisplayPortDevice_e *displayPortDeviceType)
{
if (displayPortDevice) {
*displayPortDevice = osdDisplayPortDevice;
if (displayPortDeviceType) {
*displayPortDeviceType = osdDisplayPortDeviceType;
}
return osdDisplayPort;
}
Expand Down

0 comments on commit 6bada9c

Please sign in to comment.