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 authored and Ivan Efimov committed Aug 6, 2022
1 parent 25394c5 commit b332096
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/cli/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,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
4 changes: 4 additions & 0 deletions src/main/osd/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)

osdConfig->cms_background_type = DISPLAY_BACKGROUND_BLACK;
osdConfig->extra_osd_use_quick_menu = true;

#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
4 changes: 4 additions & 0 deletions src/main/osd/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ typedef struct osdConfig_s {
uint8_t cms_background_type; // For supporting devices, determines whether the CMS background is transparent or opaque
uint8_t stat_show_cell_value;
uint8_t extra_osd_use_quick_menu; // use QUICK menu YES/NO

#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
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,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
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,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 b332096

Please sign in to comment.