1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 16:25:22 +03:00

Add 'Pilot name' to the Configurator UI; rename 'Display name' to 'Pilot name'; rename 'name' to 'craft_name'

- add pilot name (display_name) to the Configuration tab

  - add handling for the 'MSP2_GET_TEXT' and 'MSP2_SET_TEXT' commands

    - with support for the 'MSP2TEXT_PILOT_DISPLAY_NAME' ('displayName') config prop

  - backup handling of the 'displayName' config prop

  - add a text field to configure the pilot name in the 'Configuration/Personalization' box

    - using the 'display_name' FC config prop and the 'MSP2_GET_TEXT' / 'MSP2_SET_TEXT' MSP commands
    - add tooltips for both the 'Craft name' and 'Pilot name' fileds

  - rename the 'Display name' OSD element to 'Display name (Pilot name)'

    - expand the tooltip descriptions of 'Craft name' and 'Display name (Pilot name)'
    - change the default 'DISPLAY_NAME' OSD element preview to 'PILOT_NAME'

  - remove the default 'JOE PILOT' string value of the 'displayName' FC initial config

  - backwards compatibility handling for 'display_name' pre MSP v1.45

- rename 'display name' to 'pilot name'

  - add 'FC.CONFIG.pilotName' in place of 'FC.CONFIG.displayName'
  - add the 'PILOT_NAME' OSD element and keep backwards compatibility
    for the 'DISPLAY_NAME' OSD element (depending on the MSP version)

- rename 'FC.CONFIG.name' to 'FC.CONFIG.craftName'

  - add the 'MSP2TEXT_CRAFT_NAME' const for 'MSP2_GET_TEXT' / 'MSP2_SET_TEXT'
  - use 'MSP2_GET_TEXT' / 'MSP2_SET_TEXT' to get/set 'FC.CONFIG.craftName'
  - keep full backwards compatibility pre MSP v1.45 (using the legacy 'MSP_NAME' / 'MSP_SET_NAME')
This commit is contained in:
Krasiyan Nedelchev 2022-02-07 00:49:21 +01:00
parent 3c776758a3
commit 3873f82c23
11 changed files with 254 additions and 47 deletions

View file

@ -423,16 +423,30 @@ OSD.generateLQPreview = function() {
OSD.generateCraftName = function() {
let preview = 'CRAFT_NAME';
if (FC.CONFIG.name !== '') {
preview = FC.CONFIG.name.toUpperCase();
const craftName = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? FC.CONFIG.craftName
: FC.CONFIG.name;
if (craftName !== '') {
preview = craftName.toUpperCase();
}
return preview;
};
// for backwards compatibility before API_VERSION_1_45
OSD.generateDisplayName = function() {
let preview = 'DISPLAY_NAME';
if (FC.CONFIG.displayName !== '') {
preview = FC.CONFIG.displayName.toUpperCase();
if (FC.CONFIG.displayName) {
preview = FC.CONFIG.displayName?.toUpperCase();
}
return preview;
};
// added in API_VERSION_1_45
OSD.generatePilotName = function() {
let preview = 'PILOT_NAME';
if (FC.CONFIG.pilotName) {
preview = FC.CONFIG.pilotName?.toUpperCase();
}
return preview;
};
@ -1203,17 +1217,38 @@ OSD.loadDisplayFields = function() {
positionable: true,
preview: OSD.drawStickOverlayPreview,
},
DISPLAY_NAME: {
name: 'DISPLAY_NAME',
text: 'osdTextElementDisplayName',
desc: 'osdDescElementDisplayName',
defaultPosition: -77,
draw_order: 350,
positionable: true,
preview(osdData) {
return OSD.generateDisplayName(osdData, 1);
},
},
...(semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)
? {
DISPLAY_NAME: {
name: 'DISPLAY_NAME',
text: 'osdTextElementDisplayName',
desc: 'osdDescElementDisplayName',
defaultPosition: -77,
draw_order: 350,
positionable: true,
preview(osdData) {
return OSD.generateDisplayName(osdData, 1);
},
},
}
: {}
),
...(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? {
PILOT_NAME: {
name: 'PILOT_NAME',
text: 'osdTextElementPilotName',
desc: 'osdDescElementPilotName',
defaultPosition: -77,
draw_order: 350,
positionable: true,
preview(osdData) {
return OSD.generatePilotName(osdData, 1);
},
},
}
: {}
),
ESC_RPM_FREQ: {
name: 'ESC_RPM_FREQ',
text: 'osdTextElementEscRpmFreq',
@ -1742,7 +1777,8 @@ OSD.chooseFields = function() {
F.FLIGHT_DIST,
F.STICK_OVERLAY_LEFT,
F.STICK_OVERLAY_RIGHT,
F.DISPLAY_NAME,
// show either DISPLAY_NAME or PILOT_NAME depending on the MSP version
(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? F.PILOT_NAME : F.DISPLAY_NAME),
F.ESC_RPM_FREQ,
]);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {