Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4993,7 +4993,7 @@
"description": "One of the elements of the OSD"
},
"osdDescElementCraftName": {
"message": "Craft name as set in Configuration tab"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question to the reviewers:

Given that I changed some of the current en texts - should I do anything extra for all other translations?

Looking at #2791 I suspect I might have to manually remove them for now from all language files (so they can be re-translated in the future).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this will be done automatically. Crowdin will delete the translations in the next language files update.

"message": "Craft name as set in the Configuration tab.</br>Can also be set via the \"craft_name\" CLI variable."
},
"osdTextElementAltitude": {
"message": "Altitude",
Expand Down Expand Up @@ -5341,7 +5341,14 @@
"description": "One of the elements of the OSD"
},
"osdDescElementDisplayName": {
"message": "Display name as set by the \"display_name\" cli command"
"message": "Can also be set via the \"display_name\" CLI variable."
},
"osdTextElementPilotName": {
"message": "Pilot name",
"description": "One of the elements of the OSD"
},
"osdDescElementPilotName": {
"message": "Pilot name as set in the Configuration tab.</br>Can also be set via the \"pilot_name\" CLI variable."
},
"osdTextElementEscRpmFreq": {
"message": "ESC RPM frequency",
Expand Down Expand Up @@ -6279,6 +6286,15 @@
"craftName": {
"message": "Craft name"
},
"configurationCraftNameHelp": {
"message": "Can be show in logs, backup file names and the OSD.</br>Can be set via the <b>craft_name</b> CLI variable."
},
"configurationPilotName": {
"message": "Pilot name"
},
"configurationPilotNameHelp": {
"message": "Can be show in the OSD.</br>Can be set via <b>pilot_name</b> CLI variable."
},
"configurationFpvCamAngleDegrees": {
"message": "FPV Camera Angle [degrees]"
},
Expand Down
43 changes: 35 additions & 8 deletions src/js/backup_restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,13 @@ function configuration_backup(callback) {
configuration.LED_STRIP = jQuery.extend(true, [], FC.LED_STRIP);
configuration.LED_COLORS = jQuery.extend(true, [], FC.LED_COLORS);
configuration.BOARD_ALIGNMENT_CONFIG = jQuery.extend(true, {}, FC.BOARD_ALIGNMENT_CONFIG);
configuration.CRAFT_NAME = FC.CONFIG.name;
configuration.DISPLAY_NAME = FC.CONFIG.displayName;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
configuration.CRAFT_NAME = FC.CONFIG.craftName;
configuration.PILOT_NAME = FC.CONFIG.pilotName;
} else {
configuration.CRAFT_NAME = FC.CONFIG.name;
configuration.DISPLAY_NAME = FC.CONFIG.displayName;
}
Comment on lines +147 to +153
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno, might be a stupid suggestion. But given that we have different names for fields, we could avoid version check by doing something like:

Suggested change
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
configuration.CRAFT_NAME = FC.CONFIG.craftName;
configuration.PILOT_NAME = FC.CONFIG.pilotName;
} else {
configuration.CRAFT_NAME = FC.CONFIG.name;
configuration.DISPLAY_NAME = FC.CONFIG.displayName;
}
configuration.CRAFT_NAME = FC.CONFIG.craftName ?? FC.CONFIG.name;
configuration.PILOT_NAME = FC.CONFIG.pilotName ?? '';
configuration.DISPLAY_NAME = FC.CONFIG.displayName ?? '';

But this is up for discussion though.

configuration.MIXER_CONFIG = jQuery.extend(true, {}, FC.MIXER_CONFIG);
configuration.SENSOR_CONFIG = jQuery.extend(true, {}, FC.SENSOR_CONFIG);
configuration.PID_ADVANCED_CONFIG = jQuery.extend(true, {}, FC.PID_ADVANCED_CONFIG);
Expand Down Expand Up @@ -190,7 +195,12 @@ function configuration_backup(callback) {
MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG).then(function() {
return MSP.promise(MSPCodes.MSP_SENSOR_CONFIG);
}).then(function() {
return MSP.promise(MSPCodes.MSP_NAME);
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))
: MSP.promise(MSPCodes.MSP_NAME);
}).then(function() {
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);
Comment on lines +202 to +203
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything returned from Promise is automatically wrapped in promise. Hence resolve is redundant.

Suggested change
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);
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)) : true;

}).then(function() {
return MSP.promise(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG);
}).then(function() {
Expand Down Expand Up @@ -801,7 +811,13 @@ function configuration_restore(callback) {
];

function update_unique_data_list() {
uniqueData.push(MSPCodes.MSP_SET_NAME);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
uniqueData.push([MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME]);
uniqueData.push([MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME]);
} else {
uniqueData.push(MSPCodes.MSP_SET_NAME);
}

uniqueData.push(MSPCodes.MSP_SET_SENSOR_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_MIXER_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_BEEPER_CONFIG);
Expand Down Expand Up @@ -847,8 +863,13 @@ function configuration_restore(callback) {
FC.GPS_CONFIG = configuration.GPS_CONFIG;
FC.RSSI_CONFIG = configuration.RSSI_CONFIG;
FC.BOARD_ALIGNMENT_CONFIG = configuration.BOARD_ALIGNMENT_CONFIG;
FC.CONFIG.name = configuration.CRAFT_NAME;
FC.CONFIG.displayName = configuration.DISPLAY_NAME;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
FC.CONFIG.craftName = configuration.CRAFT_NAME;
FC.CONFIG.pilotName = configuration.PILOT_NAME;
} else {
FC.CONFIG.name = configuration.CRAFT_NAME;
FC.CONFIG.displayName = configuration.DISPLAY_NAME;
}
Comment on lines +866 to +872
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one could similary be refactored to use ?? and defaulting to things. Again up for discussion.

FC.MIXER_CONFIG = configuration.MIXER_CONFIG;
FC.SENSOR_CONFIG = configuration.SENSOR_CONFIG;
FC.PID_ADVANCED_CONFIG = configuration.PID_ADVANCED_CONFIG;
Expand All @@ -862,10 +883,16 @@ function configuration_restore(callback) {

function send_unique_data_item() {
if (codeKey < uniqueData.length) {
MSP.send_message(uniqueData[codeKey], mspHelper.crunch(uniqueData[codeKey]), false, function () {
const callback = () => {
codeKey++;
send_unique_data_item();
});
};

if (Array.isArray(uniqueData[codeKey])) {
MSP.send_message(uniqueData[codeKey][0], mspHelper.crunch(...uniqueData[codeKey]), false, callback);
} else {
MSP.send_message(uniqueData[codeKey], mspHelper.crunch(uniqueData[codeKey]), false, callback);
}
} else {
send_led_strip_config();
}
Expand Down
6 changes: 4 additions & 2 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ const INITIAL_CONFIG = {
profile: 0,
uid: [0, 0, 0],
accelerometerTrims: [0, 0],
name: '',
displayName: 'JOE PILOT',
name: '', // present for backwards compatibility before MSP v1.45
craftName: '',
displayName: '', // present for backwards compatibility before MSP v1.45
pilotName: '',
haslinghuis marked this conversation as resolved.
Show resolved Hide resolved
numProfiles: 3,
rateProfile: 0,
boardType: 0,
Expand Down
7 changes: 5 additions & 2 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,11 @@ function generateFilename(prefix, suffix) {
if (FC.CONFIG.flightControllerIdentifier) {
filename = `${FC.CONFIG.flightControllerIdentifier}_${filename}`;
}
if(FC.CONFIG.name && FC.CONFIG.name.trim() !== '') {
filename = `${filename}_${FC.CONFIG.name.trim().replace(' ', '_')}`;
const craftName = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? FC.CONFIG.craftName
: FC.CONFIG.name;
Comment on lines +760 to +762
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar here, technically these two are mutually exclusive

Suggested change
const craftName = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? FC.CONFIG.craftName
: FC.CONFIG.name;
const craftName = FC.CONFIG.craftName ?? FC.CONFIG.name;

if (craftName.trim() !== '') {
filename = `${filename}_${craftName.trim().replace(' ', '_')}`;
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/js/msp/MSPCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const MSPCodes = {
MSP_BOARD_INFO: 4,
MSP_BUILD_INFO: 5,

MSP_NAME: 10,
MSP_SET_NAME: 11,
MSP_NAME: 10, // DEPRECATED IN MSP 1.45
MSP_SET_NAME: 11, // DEPRECATED IN MSP 1.45
Comment on lines +11 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno if it will work straight away, but we could use jsdoc to add some intelissense about these.

Suggested change
MSP_NAME: 10, // DEPRECATED IN MSP 1.45
MSP_SET_NAME: 11, // DEPRECATED IN MSP 1.45
/**
* @deprecated in MSP >= 1.45
*/
MSP_NAME: 10,
/**
* @deprecated in MSP >= 1.45
*/
MSP_SET_NAME: 11,


MSP_BATTERY_CONFIG: 32,
MSP_SET_BATTERY_CONFIG: 33,
Expand Down Expand Up @@ -192,4 +192,10 @@ const MSPCodes = {
MSP2_SET_MOTOR_OUTPUT_REORDERING: 0x3002,
MSP2_SEND_DSHOT_COMMAND: 0x3003,
MSP2_GET_VTX_DEVICE_STATUS: 0x3004,
MSP2_GET_TEXT: 0x3006,
MSP2_SET_TEXT: 0x3007,

// MSP2_GET_TEXT and MSP2_SET_TEXT variable types
MSP2TEXT_PILOT_NAME: 1,
MSP2TEXT_CRAFT_NAME: 2,
};
66 changes: 64 additions & 2 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,25 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
break;

case MSPCodes.MSP2_GET_TEXT:
// type byte
const textType = data.readU8();
// length byte followed by the actual characters
const textLength = data.readU8() || 0;

if (textType === MSPCodes.MSP2TEXT_PILOT_NAME) {
FC.CONFIG.pilotName = '';
for (let i = 0; i < textLength; i++) {
FC.CONFIG.pilotName += String.fromCharCode(data.readU8());
}
} else if (textType === MSPCodes.MSP2TEXT_CRAFT_NAME) {
FC.CONFIG.craftName = '';
for (let i = 0; i < textLength; i++) {
FC.CONFIG.craftName += String.fromCharCode(data.readU8());
}
}
Comment on lines +928 to +938
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick

Suggested change
if (textType === MSPCodes.MSP2TEXT_PILOT_NAME) {
FC.CONFIG.pilotName = '';
for (let i = 0; i < textLength; i++) {
FC.CONFIG.pilotName += String.fromCharCode(data.readU8());
}
} else if (textType === MSPCodes.MSP2TEXT_CRAFT_NAME) {
FC.CONFIG.craftName = '';
for (let i = 0; i < textLength; i++) {
FC.CONFIG.craftName += String.fromCharCode(data.readU8());
}
}
if (textType === MSPCodes.MSP2TEXT_PILOT_NAME) {
FC.CONFIG.pilotName = '';
for (let i = 0; i < textLength; i++) {
FC.CONFIG.pilotName += String.fromCharCode(data.readU8());
}
}
if (textType === MSPCodes.MSP2TEXT_CRAFT_NAME) {
FC.CONFIG.craftName = '';
for (let i = 0; i < textLength; i++) {
FC.CONFIG.craftName += String.fromCharCode(data.readU8());
}
}

break;

case MSPCodes.MSP_SET_CHANNEL_FORWARDING:
console.log('Channel forwarding saved');
break;
Expand Down Expand Up @@ -1687,6 +1706,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_NAME:
console.log('Name set');
break;
case MSPCodes.MSP2_SET_TEXT:
console.log('Text set');
break;
case MSPCodes.MSP_SET_FILTER_CONFIG:
// removed as this fires a lot with firmware sliders console.log('Filter config set');
break;
Expand Down Expand Up @@ -1793,8 +1815,10 @@ MspHelper.prototype.process_data = function(dataHandler) {

/**
* Encode the request body for the MSP request with the given code and return it as an array of bytes.
* The second (optional) 'modifierCode' argument can be used to extend/specify the behavior of certain MSP codes
* (e.g. 'MSPCodes.MSP2_GET_TEXT' and 'MSPCodes.MSP2_SET_TEXT')
*/
MspHelper.prototype.crunch = function(code) {
MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this undefined is redundant, the only way = works in function arguments is if you don't pass anything or pass undefined. This is equivalent to:

Suggested change
MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
MspHelper.prototype.crunch = function(code, modifierCode) {

const buffer = [];
const self = this;

Expand Down Expand Up @@ -2319,6 +2343,44 @@ MspHelper.prototype.crunch = function(code) {
}
break;

case MSPCodes.MSP2_GET_TEXT:
if (modifierCode === MSPCodes.MSP2TEXT_PILOT_NAME) {
// type byte
buffer.push8(MSPCodes.MSP2TEXT_PILOT_NAME);
} else if (modifierCode === MSPCodes.MSP2TEXT_CRAFT_NAME) {
// type byte
Comment on lines +2350 to +2351
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (modifierCode === MSPCodes.MSP2TEXT_CRAFT_NAME) {
// type byte
}
if (modifierCode === MSPCodes.MSP2TEXT_CRAFT_NAME) {
// type byte

buffer.push8(MSPCodes.MSP2TEXT_CRAFT_NAME);
}
break;

case MSPCodes.MSP2_SET_TEXT:
if (modifierCode === MSPCodes.MSP2TEXT_PILOT_NAME) {
// type byte
buffer.push8(MSPCodes.MSP2TEXT_PILOT_NAME);

const MAX_NAME_LENGTH = 16;
const pilotNameLength = Math.min(MAX_NAME_LENGTH, FC.CONFIG.pilotName.length);
// length byte followed by the actual characters
buffer.push8(pilotNameLength);

for (let i = 0; i < pilotNameLength; i++) {
buffer.push8(FC.CONFIG.pilotName.charCodeAt(i));
}
} else if (modifierCode === MSPCodes.MSP2TEXT_CRAFT_NAME) {
// type byte
Comment on lines +2369 to +2370
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (modifierCode === MSPCodes.MSP2TEXT_CRAFT_NAME) {
// type byte
}
if (modifierCode === MSPCodes.MSP2TEXT_CRAFT_NAME) {
// type byte

buffer.push8(MSPCodes.MSP2TEXT_CRAFT_NAME);

const MAX_NAME_LENGTH = 16;
const craftNameLength = Math.min(MAX_NAME_LENGTH, FC.CONFIG.craftName.length);
// length byte followed by the actual characters
buffer.push8(craftNameLength);

for (let i = 0; i < craftNameLength; i++) {
buffer.push8(FC.CONFIG.craftName.charCodeAt(i));
}
}
break;

case MSPCodes.MSP_SET_BLACKBOX_CONFIG:
buffer.push8(FC.BLACKBOX.blackboxDevice)
.push8(FC.BLACKBOX.blackboxRateNum)
Expand Down Expand Up @@ -2473,7 +2535,7 @@ MspHelper.prototype.crunch = function(code) {
break;

default:
return false;
return buffer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity why this change?

}

return buffer;
Expand Down
31 changes: 24 additions & 7 deletions src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,20 +445,37 @@ function processUid() {
GUI.log(i18n.getMessage('uniqueDeviceIdReceived', [uniqueDeviceIdentifier]));

if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
processName();
processCraftName();
} else {
setRtc();
}
});
}

function processName() {
MSP.send_message(MSPCodes.MSP_NAME, false, false, function () {
GUI.log(i18n.getMessage('craftNameReceived', [FC.CONFIG.name]));
async function processCraftName() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
await MSP.promise(
MSPCodes.MSP2_GET_TEXT,
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME),
);
} else {
await MSP.promise(MSPCodes.MSP_NAME);
}

FC.CONFIG.armingDisabled = false;
mspHelper.setArmingEnabled(false, false, setRtc);
});
GUI.log(i18n.getMessage('craftNameReceived', semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? [FC.CONFIG.craftName]
: [FC.CONFIG.name],
));
Comment on lines +465 to +468
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GUI.log(i18n.getMessage('craftNameReceived', semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? [FC.CONFIG.craftName]
: [FC.CONFIG.name],
));
GUI.log(i18n.getMessage('craftNameReceived', [FC.CONFIG.craftName ?? FC.CONFIG.name]));


if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
await MSP.promise(
MSPCodes.MSP2_GET_TEXT,
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME),
);
}

FC.CONFIG.armingDisabled = false;
mspHelper.setArmingEnabled(false, false, setRtc);
}

function setRtc() {
Expand Down
30 changes: 26 additions & 4 deletions src/js/tabs/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
: Promise.resolve(true); })
: 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); })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
: Promise.resolve(true); })
: 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); })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); })
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : true; })

.then(() => { return MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG); })
.then(() => { load_html(); });
}
Expand Down Expand Up @@ -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();
}
Comment on lines +378 to +384
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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();
}
$('input[name="craftName"]').val(FC.CONFIG.craftName ?? FC.CONFIG.name);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
$('input[name="pilotName"]').val(FC.CONFIG.pilotName);
} else {
$('.pilotName').hide();
}


if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
$('input[name="fpvCamAngleDegrees"]').val(FC.RX_CONFIG.fpvCamAngleDegrees);
Expand Down Expand Up @@ -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);
Expand All @@ -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); })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); })
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : 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(); });
Expand Down
11 changes: 10 additions & 1 deletion src/js/tabs/onboard_logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ onboard_logging.initialize = function (callback) {
MSP.send_message(MSPCodes.MSP_SDCARD_SUMMARY, false, false, function() {
MSP.send_message(MSPCodes.MSP_BLACKBOX_CONFIG, false, false, function() {
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, function() {
MSP.send_message(MSPCodes.MSP_NAME, false, false, load_html);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
MSP.send_message(
MSPCodes.MSP2_GET_TEXT,
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME),
false,
load_html,
);
} else {
MSP.send_message(MSPCodes.MSP_NAME, false, false, load_html);
}
});
});
});
Expand Down
Loading