[MSP] Correctly report the configured and active OSD type (#9333)

[MSP] Correctly report the configured and active OSD type
This commit is contained in:
Michael Keller 2020-01-14 11:42:06 +13:00 committed by GitHub
commit f53d812fc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 19 deletions

View File

@ -921,6 +921,7 @@ void init(void)
#if (defined(USE_OSD) || (defined(USE_MSP_DISPLAYPORT) && defined(USE_CMS)))
displayPort_t *osdDisplayPort = NULL;
osdDisplayPortDevice_e osdDisplayPortDevice = OSD_DISPLAYPORT_DEVICE_NONE;
#endif
#if defined(USE_OSD)
@ -941,6 +942,7 @@ void init(void)
case OSD_DISPLAYPORT_DEVICE_FRSKYOSD:
osdDisplayPort = frskyOsdDisplayPortInit(vcdProfile()->video_system);
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_FRSKYOSD) {
osdDisplayPortDevice = OSD_DISPLAYPORT_DEVICE_FRSKYOSD;
break;
}
FALLTHROUGH;
@ -951,6 +953,7 @@ void init(void)
// If there is a max7456 chip for the OSD configured and detectd then use it.
osdDisplayPort = max7456DisplayPortInit(vcdProfile());
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_MAX7456) {
osdDisplayPortDevice = OSD_DISPLAYPORT_DEVICE_MAX7456;
break;
}
FALLTHROUGH;
@ -960,6 +963,7 @@ void init(void)
case OSD_DISPLAYPORT_DEVICE_MSP:
osdDisplayPort = displayPortMspInit();
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_MSP) {
osdDisplayPortDevice = OSD_DISPLAYPORT_DEVICE_MSP;
break;
}
FALLTHROUGH;
@ -973,7 +977,7 @@ void init(void)
}
// osdInit will register with CMS by itself.
osdInit(osdDisplayPort);
osdInit(osdDisplayPort, osdDisplayPortDevice);
}
#endif // USE_OSD

View File

@ -164,6 +164,13 @@ static bool writeFontCharacter(displayPort_t *instance, uint16_t addr, const osd
return max7456WriteNvm(addr, (const uint8_t *)chr);
}
static bool isReady(displayPort_t *instance)
{
UNUSED(instance);
return max7456IsDeviceDetected();
}
static const displayPortVTable_t max7456VTable = {
.grab = grab,
.release = release,
@ -181,6 +188,7 @@ static const displayPortVTable_t max7456VTable = {
.layerSelect = layerSelect,
.layerCopy = layerCopy,
.writeFontCharacter = writeFontCharacter,
.isReady = isReady,
};
displayPort_t *max7456DisplayPortInit(const vcdProfile_t *vcdProfile)

View File

@ -52,10 +52,10 @@
#include "drivers/bus_i2c.h"
#include "drivers/camera_control.h"
#include "drivers/compass/compass.h"
#include "drivers/display.h"
#include "drivers/dshot.h"
#include "drivers/flash.h"
#include "drivers/io.h"
#include "drivers/max7456.h"
#include "drivers/motor.h"
#include "drivers/osd.h"
#include "drivers/pwm_output.h"
@ -111,7 +111,6 @@
#include "pg/beeper.h"
#include "pg/board.h"
#include "pg/gyrodev.h"
#include "pg/max7456.h"
#include "pg/motor.h"
#include "pg/rx.h"
#include "pg/rx_spi.h"
@ -847,23 +846,37 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
#define OSD_FLAGS_OSD_FEATURE (1 << 0)
//#define OSD_FLAGS_OSD_SLAVE (1 << 1)
#define OSD_FLAGS_RESERVED_1 (1 << 2)
#define OSD_FLAGS_RESERVED_2 (1 << 3)
#define OSD_FLAGS_OSD_HARDWARE_FRSKYOSD (1 << 3)
#define OSD_FLAGS_OSD_HARDWARE_MAX_7456 (1 << 4)
#define OSD_FLAGS_MAX7456_DETECTED (1 << 5)
#define OSD_FLAGS_OSD_DEVICE_DETECTED (1 << 5)
uint8_t osdFlags = 0;
#if defined(USE_OSD)
osdFlags |= OSD_FLAGS_OSD_FEATURE;
#endif
#ifdef USE_MAX7456
if (max7456Config()->csTag && max7456Config()->spiDevice) {
osdFlags |= OSD_FLAGS_OSD_HARDWARE_MAX_7456;
if (max7456IsDeviceDetected()) {
osdFlags |= OSD_FLAGS_MAX7456_DETECTED;
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;
}
}
}
#endif
sbufWriteU8(dst, osdFlags);
#ifdef USE_MAX7456
@ -3386,7 +3399,7 @@ static mspResult_e mspCommonProcessInCommand(mspDescriptor_t srcDesc, uint8_t cm
for (unsigned ii = 0; ii < MIN(osdCharacterBytes, sizeof(chr.data)); ii++) {
chr.data[ii] = sbufReadU8(src);
}
displayPort_t *osdDisplayPort = osdGetDisplayPort();
displayPort_t *osdDisplayPort = osdGetDisplayPort(NULL);
if (!osdDisplayPort) {
return MSP_RESULT_ERROR;
}

View File

@ -126,6 +126,7 @@ static uint8_t armState;
static uint8_t osdProfile = 1;
#endif
static displayPort_t *osdDisplayPort;
static osdDisplayPortDevice_e osdDisplayPortDevice;
static bool osdIsReady;
static bool suppressStatsDisplay = false;
@ -408,13 +409,14 @@ static void osdCompleteInitialization(void)
osdIsReady = true;
}
void osdInit(displayPort_t *osdDisplayPortToUse)
void osdInit(displayPort_t *osdDisplayPortToUse, osdDisplayPortDevice_e displayPortDeviceToUse)
{
if (!osdDisplayPortToUse) {
return;
}
osdDisplayPort = osdDisplayPortToUse;
osdDisplayPortDevice = displayPortDeviceToUse;
#ifdef USE_CMS
cmsDisplayPortRegister(osdDisplayPort);
#endif
@ -1042,8 +1044,11 @@ bool osdNeedsAccelerometer(void)
}
#endif // USE_ACC
displayPort_t *osdGetDisplayPort(void)
displayPort_t *osdGetDisplayPort(osdDisplayPortDevice_e *displayPortDevice)
{
if (displayPortDevice) {
*displayPortDevice = osdDisplayPortDevice;
}
return osdDisplayPort;
}

View File

@ -320,7 +320,7 @@ extern escSensorData_t *osdEscDataCombined;
#endif
struct displayPort_s;
void osdInit(struct displayPort_s *osdDisplayPort);
void osdInit(struct displayPort_s *osdDisplayPort, osdDisplayPortDevice_e displayPortDevice);
bool osdInitialized(void);
void osdUpdate(timeUs_t currentTimeUs);
void osdStatSetState(uint8_t statIndex, bool enabled);
@ -336,4 +336,4 @@ bool osdElementVisible(uint16_t value);
bool osdGetVisualBeeperState(void);
statistic_t *osdGetStats(void);
bool osdNeedsAccelerometer(void);
struct displayPort_s *osdGetDisplayPort(void);
struct displayPort_s *osdGetDisplayPort(osdDisplayPortDevice_e *displayPortDevice);

View File

@ -200,7 +200,7 @@ TEST(LQTest, TestInit)
// when
// OSD is initialised
osdInit(&testDisplayPort);
osdInit(&testDisplayPort, OSD_DISPLAYPORT_DEVICE_AUTO);
// then
// display buffer should contain splash screen

View File

@ -223,7 +223,7 @@ TEST(OsdTest, TestInit)
// when
// OSD is initialised
osdInit(&testDisplayPort);
osdInit(&testDisplayPort, OSD_DISPLAYPORT_DEVICE_AUTO);
// then
// display buffer should contain splash screen