1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

Add OSD displayPort device configurability

This commit is contained in:
jflyper 2019-09-28 04:03:06 +09:00
parent e821fec341
commit 8494d6e634
5 changed files with 52 additions and 8 deletions

View file

@ -481,6 +481,10 @@ static const char* const lookupTableDshotBitbangedTimer[] = {
"AUTO", "TIM1", "TIM8" "AUTO", "TIM1", "TIM8"
}; };
static const char * const lookupTableOsdDisplayPortDevice[] = {
"NONE", "AUTO", "MAX7456", "MSP",
};
#define LOOKUP_TABLE_ENTRY(name) { name, ARRAYLEN(name) } #define LOOKUP_TABLE_ENTRY(name) { name, ARRAYLEN(name) }
@ -599,6 +603,7 @@ const lookupTableEntry_t lookupTables[] = {
LOOKUP_TABLE_ENTRY(lookupTableOffOnAuto), LOOKUP_TABLE_ENTRY(lookupTableOffOnAuto),
LOOKUP_TABLE_ENTRY(lookupTableInterpolatedSetpoint), LOOKUP_TABLE_ENTRY(lookupTableInterpolatedSetpoint),
LOOKUP_TABLE_ENTRY(lookupTableDshotBitbangedTimer), LOOKUP_TABLE_ENTRY(lookupTableDshotBitbangedTimer),
LOOKUP_TABLE_ENTRY(lookupTableOsdDisplayPortDevice),
}; };
#undef LOOKUP_TABLE_ENTRY #undef LOOKUP_TABLE_ENTRY
@ -1355,6 +1360,7 @@ const clivalue_t valueTable[] = {
{ "osd_profile_3_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, OSD_PROFILE_NAME_LENGTH, STRING_FLAGS_NONE }, PG_OSD_CONFIG, offsetof(osdConfig_t, profile[2]) }, { "osd_profile_3_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, OSD_PROFILE_NAME_LENGTH, STRING_FLAGS_NONE }, PG_OSD_CONFIG, offsetof(osdConfig_t, profile[2]) },
#endif #endif
{ "osd_gps_sats_show_hdop", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, gps_sats_show_hdop) }, { "osd_gps_sats_show_hdop", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, gps_sats_show_hdop) },
{ "osd_displayport_device", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OSD_DISPLAYPORT_DEVICE }, PG_OSD_CONFIG, offsetof(osdConfig_t, displayPortDevice) },
#endif #endif
{ "osd_rcchannels", VAR_INT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = OSD_RCCHANNELS_COUNT, PG_OSD_CONFIG, offsetof(osdConfig_t, rcChannels) }, { "osd_rcchannels", VAR_INT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = OSD_RCCHANNELS_COUNT, PG_OSD_CONFIG, offsetof(osdConfig_t, rcChannels) },

View file

@ -138,6 +138,7 @@ typedef enum {
TABLE_OFF_ON_AUTO, TABLE_OFF_ON_AUTO,
TABLE_INTERPOLATED_SP, TABLE_INTERPOLATED_SP,
TABLE_DSHOT_BITBANGED_TIMER, TABLE_DSHOT_BITBANGED_TIMER,
TABLE_OSD_DISPLAYPORT_DEVICE,
LOOKUP_TABLE_COUNT LOOKUP_TABLE_COUNT
} lookupTableIndex_e; } lookupTableIndex_e;

View file

@ -753,16 +753,43 @@ void init(void)
//The OSD need to be initialised after GYRO to avoid GYRO initialisation failure on some targets //The OSD need to be initialised after GYRO to avoid GYRO initialisation failure on some targets
if (featureIsEnabled(FEATURE_OSD)) { if (featureIsEnabled(FEATURE_OSD)) {
osdDisplayPortDevice_e device = osdConfig()->displayPortDevice;
switch(device) {
case OSD_DISPLAYPORT_DEVICE_AUTO:
FALLTHROUGH;
#if defined(USE_MAX7456) #if defined(USE_MAX7456)
// If there is a max7456 chip for the OSD then use it case OSD_DISPLAYPORT_DEVICE_MAX7456:
// If there is a max7456 chip for the OSD configured and detectd then use it.
osdDisplayPort = max7456DisplayPortInit(vcdProfile()); osdDisplayPort = max7456DisplayPortInit(vcdProfile());
#elif defined(USE_CMS) && defined(USE_MSP_DISPLAYPORT) && defined(USE_OSD_OVER_MSP_DISPLAYPORT) // OSD over MSP; not supported (yet) if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_MAX7456) {
osdDisplayPort = displayPortMspInit(); break;
}
FALLTHROUGH;
#endif #endif
#if defined(USE_CMS) && defined(USE_MSP_DISPLAYPORT) && defined(USE_OSD_OVER_MSP_DISPLAYPORT)
case OSD_DISPLAYPORT_DEVICE_MSP:
osdDisplayPort = displayPortMspInit();
if (osdDisplayPort || device == OSD_DISPLAYPORT_DEVICE_MSP) {
break;
}
FALLTHROUGH;
#endif
// Other device cases can be added here
case OSD_DISPLAYPORT_DEVICE_NONE:
default:
break;
}
// osdInit will register with CMS by itself. // osdInit will register with CMS by itself.
osdInit(osdDisplayPort); osdInit(osdDisplayPort);
} }
#endif #endif // USE_OSD
#if defined(USE_CMS) && defined(USE_MSP_DISPLAYPORT) #if defined(USE_CMS) && defined(USE_MSP_DISPLAYPORT)
// If BFOSD is not active, then register MSP_DISPLAYPORT as a CMS device. // If BFOSD is not active, then register MSP_DISPLAYPORT as a CMS device.

View file

@ -307,6 +307,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
for (int i = 0; i < OSD_RCCHANNELS_COUNT; i++) { for (int i = 0; i < OSD_RCCHANNELS_COUNT; i++) {
osdConfig->rcChannels[i] = -1; osdConfig->rcChannels[i] = -1;
} }
osdConfig->displayPortDevice = OSD_DISPLAYPORT_DEVICE_AUTO;
} }
static void osdDrawLogo(int x, int y) static void osdDrawLogo(int x, int y)

View file

@ -222,6 +222,13 @@ typedef enum {
OSD_WARNING_COUNT // MUST BE LAST OSD_WARNING_COUNT // MUST BE LAST
} osdWarningsFlags_e; } osdWarningsFlags_e;
typedef enum {
OSD_DISPLAYPORT_DEVICE_NONE = 0,
OSD_DISPLAYPORT_DEVICE_AUTO,
OSD_DISPLAYPORT_DEVICE_MAX7456,
OSD_DISPLAYPORT_DEVICE_MSP,
} osdDisplayPortDevice_e;
// Make sure the number of warnings do not exceed the available 32bit storage // Make sure the number of warnings do not exceed the available 32bit storage
STATIC_ASSERT(OSD_WARNING_COUNT <= 32, osdwarnings_overflow); STATIC_ASSERT(OSD_WARNING_COUNT <= 32, osdwarnings_overflow);
@ -262,6 +269,7 @@ typedef struct osdConfig_s {
uint8_t rssi_dbm_alarm; uint8_t rssi_dbm_alarm;
uint8_t gps_sats_show_hdop; uint8_t gps_sats_show_hdop;
int8_t rcChannels[OSD_RCCHANNELS_COUNT]; // RC channel values to display, -1 if none int8_t rcChannels[OSD_RCCHANNELS_COUNT]; // RC channel values to display, -1 if none
uint8_t displayPortDevice; // osdDisplayPortDevice_e
} osdConfig_t; } osdConfig_t;
PG_DECLARE(osdConfig_t, osdConfig); PG_DECLARE(osdConfig_t, osdConfig);