1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 13:25:30 +03:00

Merge pull request #6924 from smoriarty21/pilot_name

Pilot Name
This commit is contained in:
Michael Keller 2019-02-02 21:20:08 +13:00 committed by GitHub
commit fd297b6b2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 8 deletions

View file

@ -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

View file

@ -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]) },

View file

@ -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}
};

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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