diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index f9c05a8498..57d52ede6d 100644 --- a/src/main/cli/cli.c +++ b/src/main/cli/cli.c @@ -2296,6 +2296,26 @@ static void cliVtx(char *cmdline) #endif // VTX_CONTROL +#ifdef USE_OSD +static void printDisplayName(uint8_t dumpMask, const pilotConfig_t *pilotConfig) +{ + const bool equalsDefault = strlen(pilotConfig->displayName) == 0; + cliDumpPrintLinef(dumpMask, equalsDefault, "display_name %s", equalsDefault ? emptyName : pilotConfig->displayName); +} + +static void cliDisplayName(char *cmdline) +{ + const unsigned int len = strlen(cmdline); + if (len > 0) { + memset(pilotConfigMutable()->displayName, 0, ARRAYLEN(pilotConfig()->displayName)); + if (strncmp(cmdline, emptyName, len)) { + strncpy(pilotConfigMutable()->displayName, cmdline, MIN(len, MAX_NAME_LENGTH)); + } + } + printDisplayName(DUMP_MASTER, pilotConfig()); +} +#endif + static void printName(uint8_t dumpMask, const pilotConfig_t *pilotConfig) { const bool equalsDefault = strlen(pilotConfig->name) == 0; @@ -4614,6 +4634,11 @@ static void printConfig(char *cmdline, bool doDiff) cliPrintHashLine("name"); printName(dumpMask, &pilotConfig_Copy); +#ifdef USE_OSD + cliPrintHashLine("display_name"); + printDisplayName(dumpMask, &pilotConfig_Copy); +#endif + #ifdef USE_RESOURCE_MGMT cliPrintHashLine("resources"); printResource(dumpMask); @@ -4830,6 +4855,9 @@ const clicmd_t cmdTable[] = { #endif CLI_COMMAND_DEF("defaults", "reset to defaults and reboot", "[nosave]", cliDefaults), CLI_COMMAND_DEF("diff", "list configuration changes from default", "[master|profile|rates|all] {defaults}", cliDiff), +#ifdef USE_OSD + CLI_COMMAND_DEF("display_name", "display name of craft", NULL, cliDisplayName), +#endif #ifdef USE_RESOURCE_MGMT CLI_COMMAND_DEF("dma", "list dma utilisation", NULL, cliDma), #ifdef USE_DMA_SPEC diff --git a/src/main/cli/settings.c b/src/main/cli/settings.c index 431d51540f..c537016f53 100644 --- a/src/main/cli/settings.c +++ b/src/main/cli/settings.c @@ -1168,6 +1168,7 @@ const clivalue_t valueTable[] = { { "osd_mah_drawn_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_MAH_DRAWN]) }, { "osd_motor_diag_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_MOTOR_DIAG]) }, { "osd_craft_name_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CRAFT_NAME]) }, + { "osd_display_name_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_DISPLAY_NAME]) }, { "osd_gps_speed_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_GPS_SPEED]) }, { "osd_gps_lon_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_GPS_LON]) }, { "osd_gps_lat_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_GPS_LAT]) }, diff --git a/src/main/cms/cms_menu_osd.c b/src/main/cms/cms_menu_osd.c index 406987e520..930f10bbfb 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -132,6 +132,7 @@ OSD_Entry menuOsdActiveElemsEntries[] = {"STICK OVERLAY LEFT", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_STICK_OVERLAY_LEFT], DYNAMIC}, {"STICK OVERLAY RIGHT",OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_STICK_OVERLAY_RIGHT], DYNAMIC}, #endif + {"DISPLAY NAME", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_DISPLAY_NAME], 0}, {"BACK", OME_Back, NULL, NULL, 0}, {NULL, OME_END, NULL, NULL, 0} }; diff --git a/src/main/fc/config.c b/src/main/fc/config.c index 1eaf12fa8d..e45dfdd885 100644 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -74,10 +74,11 @@ pidProfile_t *currentPidProfile; #define DYNAMIC_FILTER_MAX_SUPPORTED_LOOP_TIME HZ_TO_INTERVAL_US(2000) -PG_REGISTER_WITH_RESET_TEMPLATE(pilotConfig_t, pilotConfig, PG_PILOT_CONFIG, 0); +PG_REGISTER_WITH_RESET_TEMPLATE(pilotConfig_t, pilotConfig, PG_PILOT_CONFIG, 1); PG_RESET_TEMPLATE(pilotConfig_t, pilotConfig, - .name = { 0 } + .name = { 0 }, + .displayName = { 0 }, ); PG_REGISTER_WITH_RESET_TEMPLATE(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 2); diff --git a/src/main/fc/config.h b/src/main/fc/config.h index 8413f38dd6..f1df0e54e2 100644 --- a/src/main/fc/config.h +++ b/src/main/fc/config.h @@ -29,6 +29,7 @@ typedef struct pilotConfig_s { char name[MAX_NAME_LENGTH + 1]; + char displayName[MAX_NAME_LENGTH + 1]; } pilotConfig_t; PG_DECLARE(pilotConfig_t, pilotConfig); diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 8711ff6071..90733ac510 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -247,6 +247,7 @@ static const uint8_t osdElementDisplayOrder[] = { OSD_ANTI_GRAVITY, OSD_MOTOR_DIAG, OSD_FLIP_ARROW, + OSD_DISPLAY_NAME, #ifdef USE_RTC_TIME OSD_RTC_DATETIME, #endif @@ -829,6 +830,26 @@ static bool osdDrawSingleElement(uint8_t item) break; + case OSD_DISPLAY_NAME: + // This does not strictly support iterative updating if the display name changes at run time. But since the display name is not supposed to be changing this should not matter, and blanking the entire length of the display name string on update will make it impossible to configure elements to be displayed on the right hand side of the display name. + //TODO: When iterative updating is implemented, change this so the display name is only printed once whenever the OSD 'flight' screen is entered. + + if (strlen(pilotConfig()->displayName) == 0) { + strcpy(buff, "DISPLAY_NAME"); + } else { + unsigned i; + for (i = 0; i < MAX_NAME_LENGTH; i++) { + if (pilotConfig()->displayName[i]) { + buff[i] = toupper((unsigned char)pilotConfig()->displayName[i]); + } else { + break; + } + } + buff[i] = '\0'; + } + + break; + case OSD_THROTTLE_POS: buff[0] = SYM_THR; buff[1] = SYM_THR1; diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 22794bdd98..dae1577604 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -121,6 +121,7 @@ typedef enum { OSD_FLIGHT_DIST, OSD_STICK_OVERLAY_LEFT, OSD_STICK_OVERLAY_RIGHT, + OSD_DISPLAY_NAME, OSD_ITEM_COUNT // MUST BE LAST } osd_items_e; diff --git a/src/main/target/common_post.h b/src/main/target/common_post.h index 708451f56f..d2dad6b657 100644 --- a/src/main/target/common_post.h +++ b/src/main/target/common_post.h @@ -124,12 +124,6 @@ #undef USE_MSP_OVER_TELEMETRY #endif -#if !defined(USE_OSD) -#undef USE_RX_LINK_QUALITY_INFO -#undef USE_OSD_PROFILES -#undef USE_OSD_STICK_OVERLAY -#endif - /* If either VTX_CONTROL or VTX_COMMON is undefined then remove common code and device drivers */ #if !defined(USE_VTX_COMMON) || !defined(USE_VTX_CONTROL) #undef USE_VTX_COMMON @@ -187,6 +181,12 @@ #define USE_OSD #endif +#if !defined(USE_OSD) +#undef USE_RX_LINK_QUALITY_INFO +#undef USE_OSD_PROFILES +#undef USE_OSD_STICK_OVERLAY +#endif + #if defined(USE_GPS_RESCUE) #define USE_GPS #endif