mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Add OSD displayPort device configurability
This commit is contained in:
parent
e821fec341
commit
8494d6e634
5 changed files with 52 additions and 8 deletions
|
@ -481,6 +481,10 @@ static const char* const lookupTableDshotBitbangedTimer[] = {
|
|||
"AUTO", "TIM1", "TIM8"
|
||||
};
|
||||
|
||||
static const char * const lookupTableOsdDisplayPortDevice[] = {
|
||||
"NONE", "AUTO", "MAX7456", "MSP",
|
||||
};
|
||||
|
||||
|
||||
#define LOOKUP_TABLE_ENTRY(name) { name, ARRAYLEN(name) }
|
||||
|
||||
|
@ -599,6 +603,7 @@ const lookupTableEntry_t lookupTables[] = {
|
|||
LOOKUP_TABLE_ENTRY(lookupTableOffOnAuto),
|
||||
LOOKUP_TABLE_ENTRY(lookupTableInterpolatedSetpoint),
|
||||
LOOKUP_TABLE_ENTRY(lookupTableDshotBitbangedTimer),
|
||||
LOOKUP_TABLE_ENTRY(lookupTableOsdDisplayPortDevice),
|
||||
};
|
||||
|
||||
#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]) },
|
||||
#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_displayport_device", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OSD_DISPLAYPORT_DEVICE }, PG_OSD_CONFIG, offsetof(osdConfig_t, displayPortDevice) },
|
||||
#endif
|
||||
|
||||
{ "osd_rcchannels", VAR_INT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = OSD_RCCHANNELS_COUNT, PG_OSD_CONFIG, offsetof(osdConfig_t, rcChannels) },
|
||||
|
|
|
@ -138,6 +138,7 @@ typedef enum {
|
|||
TABLE_OFF_ON_AUTO,
|
||||
TABLE_INTERPOLATED_SP,
|
||||
TABLE_DSHOT_BITBANGED_TIMER,
|
||||
TABLE_OSD_DISPLAYPORT_DEVICE,
|
||||
|
||||
LOOKUP_TABLE_COUNT
|
||||
} lookupTableIndex_e;
|
||||
|
|
|
@ -753,16 +753,43 @@ void init(void)
|
|||
//The OSD need to be initialised after GYRO to avoid GYRO initialisation failure on some targets
|
||||
|
||||
if (featureIsEnabled(FEATURE_OSD)) {
|
||||
osdDisplayPortDevice_e device = osdConfig()->displayPortDevice;
|
||||
|
||||
switch(device) {
|
||||
|
||||
case OSD_DISPLAYPORT_DEVICE_AUTO:
|
||||
FALLTHROUGH;
|
||||
|
||||
#if defined(USE_MAX7456)
|
||||
// If there is a max7456 chip for the OSD then use it
|
||||
osdDisplayPort = max7456DisplayPortInit(vcdProfile());
|
||||
#elif defined(USE_CMS) && defined(USE_MSP_DISPLAYPORT) && defined(USE_OSD_OVER_MSP_DISPLAYPORT) // OSD over MSP; not supported (yet)
|
||||
osdDisplayPort = displayPortMspInit();
|
||||
case OSD_DISPLAYPORT_DEVICE_MAX7456:
|
||||
// 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) {
|
||||
break;
|
||||
}
|
||||
FALLTHROUGH;
|
||||
#endif
|
||||
// osdInit will register with CMS by itself.
|
||||
|
||||
#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(osdDisplayPort);
|
||||
}
|
||||
#endif
|
||||
#endif // USE_OSD
|
||||
|
||||
#if defined(USE_CMS) && defined(USE_MSP_DISPLAYPORT)
|
||||
// If BFOSD is not active, then register MSP_DISPLAYPORT as a CMS device.
|
||||
|
|
|
@ -307,6 +307,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
for (int i = 0; i < OSD_RCCHANNELS_COUNT; i++) {
|
||||
osdConfig->rcChannels[i] = -1;
|
||||
}
|
||||
|
||||
osdConfig->displayPortDevice = OSD_DISPLAYPORT_DEVICE_AUTO;
|
||||
}
|
||||
|
||||
static void osdDrawLogo(int x, int y)
|
||||
|
|
|
@ -222,6 +222,13 @@ typedef enum {
|
|||
OSD_WARNING_COUNT // MUST BE LAST
|
||||
} 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
|
||||
STATIC_ASSERT(OSD_WARNING_COUNT <= 32, osdwarnings_overflow);
|
||||
|
||||
|
@ -254,14 +261,15 @@ typedef struct osdConfig_s {
|
|||
int16_t esc_rpm_alarm;
|
||||
int16_t esc_current_alarm;
|
||||
uint8_t core_temp_alarm;
|
||||
uint8_t ahInvert; // invert the artificial horizon
|
||||
uint8_t ahInvert; // invert the artificial horizon
|
||||
uint8_t osdProfileIndex;
|
||||
uint8_t overlay_radio_mode;
|
||||
char profile[OSD_PROFILE_COUNT][OSD_PROFILE_NAME_LENGTH + 1];
|
||||
uint16_t link_quality_alarm;
|
||||
uint8_t rssi_dbm_alarm;
|
||||
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;
|
||||
|
||||
PG_DECLARE(osdConfig_t, osdConfig);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue