Skip to content

Commit

Permalink
Add USE_CRAFTNAME_MSGS to insert additional data into CraftName when …
Browse files Browse the repository at this point in the history
…osd_craftname_msgs is true
  • Loading branch information
howels committed Aug 4, 2022
1 parent d1bf5db commit 04994e5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/cli/settings.c
Expand Up @@ -1438,6 +1438,10 @@ const clivalue_t valueTable[] = {
{ "osd_menu_background", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_CMS_BACKGROUND }, PG_OSD_CONFIG, offsetof(osdConfig_t, cms_background_type) },
#endif // end of #ifdef USE_OSD

#ifdef USE_CRAFTNAME_MSGS
{ "osd_craftname_msgs", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, osd_craftname_msgs) },
#endif //USE_CRAFTNAME_MSGS

// PG_SYSTEM_CONFIG
#if defined(STM32F4) || defined(STM32G4)
{ "system_hse_mhz", VAR_UINT8 | HARDWARE_VALUE, .config.minmaxUnsigned = { 0, 30 }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, hseMhz) },
Expand Down
3 changes: 3 additions & 0 deletions src/main/osd/osd.c
Expand Up @@ -387,6 +387,9 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
osdConfig->stat_show_cell_value = false;
osdConfig->framerate_hz = OSD_FRAMERATE_DEFAULT_HZ;
osdConfig->cms_background_type = DISPLAY_BACKGROUND_TRANSPARENT;
#ifdef USE_CRAFTNAME_MSGS
osdConfig->osd_craftname_msgs = false; // Insert LQ/RSSI-dBm and warnings into CraftName
#endif //USE_CRAFTNAME_MSGS
}

void pgResetFn_osdElementConfig(osdElementConfig_t *osdElementConfig)
Expand Down
3 changes: 3 additions & 0 deletions src/main/osd/osd.h
Expand Up @@ -303,6 +303,9 @@ typedef struct osdConfig_s {
uint16_t framerate_hz;
uint8_t cms_background_type; // For supporting devices, determines whether the CMS background is transparent or opaque
uint8_t stat_show_cell_value;
#ifdef USE_CRAFTNAME_MSGS
uint8_t osd_craftname_msgs; // Insert LQ/RSSI-dBm and warnings into CraftName
#endif //USE_CRAFTNAME_MSGS
} osdConfig_t;

PG_DECLARE(osdConfig_t, osdConfig);
Expand Down
29 changes: 29 additions & 0 deletions src/main/osd/osd_elements.c
Expand Up @@ -1443,6 +1443,35 @@ static void osdElementWarnings(osdElementParms_t *element)
} else {
CLR_BLINK(OSD_WARNINGS);
}

#ifdef USE_CRAFTNAME_MSGS
// Injects data into the CraftName variable for systems which limit
// the available MSP data field in their OSD.
if (osdConfig()->osd_craftname_msgs == true) {
// if warning is not set, or blink is off, then display LQ & RSSI
if (blinkState || (strlen(element->buff) == 0)) {
#ifdef USE_RX_LINK_QUALITY_INFO
// replicate the LQ functionality without the special font symbols
uint16_t osdLinkQuality = 0;
if (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_CRSF) { // 0-99
osdLinkQuality = rxGetLinkQuality();
const uint8_t osdRfMode = rxGetRfMode();
tfp_sprintf(element->buff, "LQ %2d:%03d %3d", osdRfMode, osdLinkQuality, getRssiDbm());
} else if (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_GHST) { // 0-100
osdLinkQuality = rxGetLinkQuality();
tfp_sprintf(element->buff, "LQ %03d %3d", osdLinkQuality, getRssiDbm());
} else { // 0-9
osdLinkQuality = rxGetLinkQuality() * 10 / LINK_QUALITY_MAX_VALUE;
if (osdLinkQuality >= 10) {
osdLinkQuality = 9;
}
tfp_sprintf(element->buff, "LQ %1d", osdLinkQuality);
}
#endif // USE_RX_LINK_QUALITY_INFO
}
strncpy(pilotConfigMutable()->name, element->buff, MAX_NAME_LENGTH);
}
#endif // USE_CRAFTNAME_MSGS
}

// Define the order in which the elements are drawn.
Expand Down
1 change: 1 addition & 0 deletions src/main/target/common_pre.h
Expand Up @@ -407,6 +407,7 @@ extern uint8_t _dmaram_end__;
#define USE_SIMPLIFIED_TUNING
#define USE_RX_LINK_UPLINK_POWER
#define USE_CRSF_V3
#define USE_CRAFTNAME_MSGS
#endif

#if (TARGET_FLASH_SIZE > 512)
Expand Down

0 comments on commit 04994e5

Please sign in to comment.