From 98efe1a972b55be910d9e5a8455c43cd4ca9625d Mon Sep 17 00:00:00 2001 From: mikeller Date: Sun, 17 May 2020 03:56:20 +1200 Subject: [PATCH] Fixed reporting of configured / detected OSD device. --- src/main/cli/cli.c | 6 +++--- src/main/fc/init.c | 3 ++- src/main/msp/msp.c | 38 ++++++++++++++++++-------------------- src/main/osd/osd.c | 13 +++++++------ 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index a0361528791..8c9952723a3 100644 --- a/src/main/cli/cli.c +++ b/src/main/cli/cli.c @@ -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 diff --git a/src/main/fc/init.c b/src/main/fc/init.c index f590e4b4416..ec2c6a84d60 100644 --- a/src/main/fc/init.c +++ b/src/main/fc/init.c @@ -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 diff --git a/src/main/msp/msp.c b/src/main/msp/msp.c index 5171cb8504f..25118a361e7 100644 --- a/src/main/msp/msp.c +++ b/src/main/msp/msp.c @@ -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); diff --git a/src/main/osd/osd.c b/src/main/osd/osd.c index 8b4c8e47f66..874c3cc4977 100644 --- a/src/main/osd/osd.c +++ b/src/main/osd/osd.c @@ -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; @@ -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 @@ -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; }