mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 11:59:58 +03:00
[MSP] Correctly report the configured and active OSD type (#9333)
[MSP] Correctly report the configured and active OSD type
This commit is contained in:
commit
f53d812fc8
7 changed files with 49 additions and 19 deletions
|
@ -921,6 +921,7 @@ void init(void)
|
||||||
|
|
||||||
#if (defined(USE_OSD) || (defined(USE_MSP_DISPLAYPORT) && defined(USE_CMS)))
|
#if (defined(USE_OSD) || (defined(USE_MSP_DISPLAYPORT) && defined(USE_CMS)))
|
||||||
displayPort_t *osdDisplayPort = NULL;
|
displayPort_t *osdDisplayPort = NULL;
|
||||||
|
osdDisplayPortDevice_e osdDisplayPortDevice = OSD_DISPLAYPORT_DEVICE_NONE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_OSD)
|
#if defined(USE_OSD)
|
||||||
|
@ -941,6 +942,7 @@ void init(void)
|
||||||
case OSD_DISPLAYPORT_DEVICE_FRSKYOSD:
|
case OSD_DISPLAYPORT_DEVICE_FRSKYOSD:
|
||||||
osdDisplayPort = frskyOsdDisplayPortInit(vcdProfile()->video_system);
|
osdDisplayPort = frskyOsdDisplayPortInit(vcdProfile()->video_system);
|
||||||
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_FRSKYOSD) {
|
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_FRSKYOSD) {
|
||||||
|
osdDisplayPortDevice = OSD_DISPLAYPORT_DEVICE_FRSKYOSD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
@ -951,6 +953,7 @@ void init(void)
|
||||||
// If there is a max7456 chip for the OSD configured and detectd then use it.
|
// If there is a max7456 chip for the OSD configured and detectd then use it.
|
||||||
osdDisplayPort = max7456DisplayPortInit(vcdProfile());
|
osdDisplayPort = max7456DisplayPortInit(vcdProfile());
|
||||||
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_MAX7456) {
|
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_MAX7456) {
|
||||||
|
osdDisplayPortDevice = OSD_DISPLAYPORT_DEVICE_MAX7456;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
@ -960,6 +963,7 @@ void init(void)
|
||||||
case OSD_DISPLAYPORT_DEVICE_MSP:
|
case OSD_DISPLAYPORT_DEVICE_MSP:
|
||||||
osdDisplayPort = displayPortMspInit();
|
osdDisplayPort = displayPortMspInit();
|
||||||
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_MSP) {
|
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_MSP) {
|
||||||
|
osdDisplayPortDevice = OSD_DISPLAYPORT_DEVICE_MSP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
@ -973,7 +977,7 @@ void init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// osdInit will register with CMS by itself.
|
// osdInit will register with CMS by itself.
|
||||||
osdInit(osdDisplayPort);
|
osdInit(osdDisplayPort, osdDisplayPortDevice);
|
||||||
}
|
}
|
||||||
#endif // USE_OSD
|
#endif // USE_OSD
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,13 @@ static bool writeFontCharacter(displayPort_t *instance, uint16_t addr, const osd
|
||||||
return max7456WriteNvm(addr, (const uint8_t *)chr);
|
return max7456WriteNvm(addr, (const uint8_t *)chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isReady(displayPort_t *instance)
|
||||||
|
{
|
||||||
|
UNUSED(instance);
|
||||||
|
|
||||||
|
return max7456IsDeviceDetected();
|
||||||
|
}
|
||||||
|
|
||||||
static const displayPortVTable_t max7456VTable = {
|
static const displayPortVTable_t max7456VTable = {
|
||||||
.grab = grab,
|
.grab = grab,
|
||||||
.release = release,
|
.release = release,
|
||||||
|
@ -181,6 +188,7 @@ static const displayPortVTable_t max7456VTable = {
|
||||||
.layerSelect = layerSelect,
|
.layerSelect = layerSelect,
|
||||||
.layerCopy = layerCopy,
|
.layerCopy = layerCopy,
|
||||||
.writeFontCharacter = writeFontCharacter,
|
.writeFontCharacter = writeFontCharacter,
|
||||||
|
.isReady = isReady,
|
||||||
};
|
};
|
||||||
|
|
||||||
displayPort_t *max7456DisplayPortInit(const vcdProfile_t *vcdProfile)
|
displayPort_t *max7456DisplayPortInit(const vcdProfile_t *vcdProfile)
|
||||||
|
|
|
@ -52,10 +52,10 @@
|
||||||
#include "drivers/bus_i2c.h"
|
#include "drivers/bus_i2c.h"
|
||||||
#include "drivers/camera_control.h"
|
#include "drivers/camera_control.h"
|
||||||
#include "drivers/compass/compass.h"
|
#include "drivers/compass/compass.h"
|
||||||
|
#include "drivers/display.h"
|
||||||
#include "drivers/dshot.h"
|
#include "drivers/dshot.h"
|
||||||
#include "drivers/flash.h"
|
#include "drivers/flash.h"
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
#include "drivers/max7456.h"
|
|
||||||
#include "drivers/motor.h"
|
#include "drivers/motor.h"
|
||||||
#include "drivers/osd.h"
|
#include "drivers/osd.h"
|
||||||
#include "drivers/pwm_output.h"
|
#include "drivers/pwm_output.h"
|
||||||
|
@ -111,7 +111,6 @@
|
||||||
#include "pg/beeper.h"
|
#include "pg/beeper.h"
|
||||||
#include "pg/board.h"
|
#include "pg/board.h"
|
||||||
#include "pg/gyrodev.h"
|
#include "pg/gyrodev.h"
|
||||||
#include "pg/max7456.h"
|
|
||||||
#include "pg/motor.h"
|
#include "pg/motor.h"
|
||||||
#include "pg/rx.h"
|
#include "pg/rx.h"
|
||||||
#include "pg/rx_spi.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_FEATURE (1 << 0)
|
||||||
//#define OSD_FLAGS_OSD_SLAVE (1 << 1)
|
//#define OSD_FLAGS_OSD_SLAVE (1 << 1)
|
||||||
#define OSD_FLAGS_RESERVED_1 (1 << 2)
|
#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_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;
|
uint8_t osdFlags = 0;
|
||||||
#if defined(USE_OSD)
|
#if defined(USE_OSD)
|
||||||
osdFlags |= OSD_FLAGS_OSD_FEATURE;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
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);
|
sbufWriteU8(dst, osdFlags);
|
||||||
|
|
||||||
#ifdef USE_MAX7456
|
#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++) {
|
for (unsigned ii = 0; ii < MIN(osdCharacterBytes, sizeof(chr.data)); ii++) {
|
||||||
chr.data[ii] = sbufReadU8(src);
|
chr.data[ii] = sbufReadU8(src);
|
||||||
}
|
}
|
||||||
displayPort_t *osdDisplayPort = osdGetDisplayPort();
|
displayPort_t *osdDisplayPort = osdGetDisplayPort(NULL);
|
||||||
if (!osdDisplayPort) {
|
if (!osdDisplayPort) {
|
||||||
return MSP_RESULT_ERROR;
|
return MSP_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,7 @@ static uint8_t armState;
|
||||||
static uint8_t osdProfile = 1;
|
static uint8_t osdProfile = 1;
|
||||||
#endif
|
#endif
|
||||||
static displayPort_t *osdDisplayPort;
|
static displayPort_t *osdDisplayPort;
|
||||||
|
static osdDisplayPortDevice_e osdDisplayPortDevice;
|
||||||
static bool osdIsReady;
|
static bool osdIsReady;
|
||||||
|
|
||||||
static bool suppressStatsDisplay = false;
|
static bool suppressStatsDisplay = false;
|
||||||
|
@ -408,13 +409,14 @@ static void osdCompleteInitialization(void)
|
||||||
osdIsReady = true;
|
osdIsReady = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void osdInit(displayPort_t *osdDisplayPortToUse)
|
void osdInit(displayPort_t *osdDisplayPortToUse, osdDisplayPortDevice_e displayPortDeviceToUse)
|
||||||
{
|
{
|
||||||
if (!osdDisplayPortToUse) {
|
if (!osdDisplayPortToUse) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
osdDisplayPort = osdDisplayPortToUse;
|
osdDisplayPort = osdDisplayPortToUse;
|
||||||
|
osdDisplayPortDevice = displayPortDeviceToUse;
|
||||||
#ifdef USE_CMS
|
#ifdef USE_CMS
|
||||||
cmsDisplayPortRegister(osdDisplayPort);
|
cmsDisplayPortRegister(osdDisplayPort);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1042,8 +1044,11 @@ bool osdNeedsAccelerometer(void)
|
||||||
}
|
}
|
||||||
#endif // USE_ACC
|
#endif // USE_ACC
|
||||||
|
|
||||||
displayPort_t *osdGetDisplayPort(void)
|
displayPort_t *osdGetDisplayPort(osdDisplayPortDevice_e *displayPortDevice)
|
||||||
{
|
{
|
||||||
|
if (displayPortDevice) {
|
||||||
|
*displayPortDevice = osdDisplayPortDevice;
|
||||||
|
}
|
||||||
return osdDisplayPort;
|
return osdDisplayPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,7 +320,7 @@ extern escSensorData_t *osdEscDataCombined;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct displayPort_s;
|
struct displayPort_s;
|
||||||
void osdInit(struct displayPort_s *osdDisplayPort);
|
void osdInit(struct displayPort_s *osdDisplayPort, osdDisplayPortDevice_e displayPortDevice);
|
||||||
bool osdInitialized(void);
|
bool osdInitialized(void);
|
||||||
void osdUpdate(timeUs_t currentTimeUs);
|
void osdUpdate(timeUs_t currentTimeUs);
|
||||||
void osdStatSetState(uint8_t statIndex, bool enabled);
|
void osdStatSetState(uint8_t statIndex, bool enabled);
|
||||||
|
@ -336,4 +336,4 @@ bool osdElementVisible(uint16_t value);
|
||||||
bool osdGetVisualBeeperState(void);
|
bool osdGetVisualBeeperState(void);
|
||||||
statistic_t *osdGetStats(void);
|
statistic_t *osdGetStats(void);
|
||||||
bool osdNeedsAccelerometer(void);
|
bool osdNeedsAccelerometer(void);
|
||||||
struct displayPort_s *osdGetDisplayPort(void);
|
struct displayPort_s *osdGetDisplayPort(osdDisplayPortDevice_e *displayPortDevice);
|
||||||
|
|
|
@ -200,7 +200,7 @@ TEST(LQTest, TestInit)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
// OSD is initialised
|
// OSD is initialised
|
||||||
osdInit(&testDisplayPort);
|
osdInit(&testDisplayPort, OSD_DISPLAYPORT_DEVICE_AUTO);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
// display buffer should contain splash screen
|
// display buffer should contain splash screen
|
||||||
|
|
|
@ -223,7 +223,7 @@ TEST(OsdTest, TestInit)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
// OSD is initialised
|
// OSD is initialised
|
||||||
osdInit(&testDisplayPort);
|
osdInit(&testDisplayPort, OSD_DISPLAYPORT_DEVICE_AUTO);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
// display buffer should contain splash screen
|
// display buffer should contain splash screen
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue