diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index f9c05a8498..14390b5269 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,9 @@ static void printConfig(char *cmdline, bool doDiff) cliPrintHashLine("name"); printName(dumpMask, &pilotConfig_Copy); + cliPrintHashLine("display_name"); + printDisplayName(dumpMask, &pilotConfig_Copy); + #ifdef USE_RESOURCE_MGMT cliPrintHashLine("resources"); printResource(dumpMask); @@ -4830,6 +4853,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 e83107806b..9313b51a79 100644 --- a/src/main/cli/settings.c +++ b/src/main/cli/settings.c @@ -1161,6 +1161,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..c35db7ee13 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -131,6 +131,11 @@ OSD_Entry menuOsdActiveElemsEntries[] = #ifdef USE_OSD_STICK_OVERLAY {"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 + {"G-FORCE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_G_FORCE], 0}, + {"FLIP ARROW", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_FLIP_ARROW], 0}, +#ifdef USE_OSD + {"DISPLAY NAME", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_DISPLAY_NAME], 0}, #endif {"BACK", OME_Back, NULL, NULL, 0}, {NULL, OME_END, NULL, NULL, 0} 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;