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

@ -30,8 +30,15 @@ configuration.initialize = function (callback) {
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.17.0") ? MSP.promise(MSPCodes.MSP_RC_DEADBAND) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.16.0") ? MSP.promise(MSPCodes.MSP_SENSOR_CONFIG) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.15.0") ? MSP.promise(MSPCodes.MSP_SENSOR_ALIGNMENT) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.20.0") ? MSP.promise(MSPCodes.MSP_NAME) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.20.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP_NAME)
: Promise.resolve(true); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME))
: Promise.resolve(true); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31) ? MSP.promise(MSPCodes.MSP_RX_CONFIG) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); })
.then(() => { return MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG); })
.then(() => { load_html(); });
}
@ -368,7 +375,13 @@ configuration.initialize = function (callback) {
$('.hardwareSelection').hide();
}
$('input[name="craftName"]').val(FC.CONFIG.name);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
$('input[name="craftName"]').val(FC.CONFIG.craftName);
$('input[name="pilotName"]').val(FC.CONFIG.pilotName);
} else {
$('input[name="craftName"]').val(FC.CONFIG.name);
$('.pilotName').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
$('input[name="fpvCamAngleDegrees"]').val(FC.RX_CONFIG.fpvCamAngleDegrees);
@ -594,7 +607,12 @@ configuration.initialize = function (callback) {
FC.SENSOR_CONFIG.acc_hardware = $('input[id="accHardwareSwitch"]').is(':checked') ? 0 : 1;
FC.SENSOR_CONFIG.baro_hardware = $('input[id="baroHardwareSwitch"]').is(':checked') ? 0 : 1;
FC.SENSOR_CONFIG.mag_hardware = $('input[id="magHardwareSwitch"]').is(':checked') ? 0 : 1;
FC.CONFIG.name = $.trim($('input[name="craftName"]').val());
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
FC.CONFIG.craftName = $('input[name="craftName"]').val().trim();
FC.CONFIG.pilotName = $('input[name="pilotName"]').val().trim();
} else {
FC.CONFIG.name = $('input[name="craftName"]').val().trim();
}
function save_serial_config() {
mspHelper.sendSerialConfig(save_config);
@ -617,7 +635,11 @@ configuration.initialize = function (callback) {
.then(() => { return MSP.promise(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM)); })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_ARMING_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ARMING_CONFIG)); })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG)); })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME)); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME))
: MSP.promise(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME)); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ?
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); })
.then(() => { return (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) ? MSP.promise(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG)) : true; })
.then(() => { return MSP.promise(MSPCodes.MSP_EEPROM_WRITE); })
.then(() => { reboot(); });