Adding display name to OSD and CLI
This commit is contained in:
parent
ae194f2eb3
commit
09fce7f1fa
|
@ -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
|
||||
|
|
|
@ -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]) },
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue