Skip to content

Commit

Permalink
add pilot name (display_name) to the Configuration tab
Browse files Browse the repository at this point in the history
  - add handling for the 'MSP2_GET_DISPLAY_NAME' and 'MSP2_SET_DISPLAY_NAME' commands

  - add backup handling of the 'displayName' config prop (as 'PILOT_NAME')

  - 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_DISPLAY_NAME' / 'MSP2_SET_DISPLAY_NAME' MPS 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
  • Loading branch information
krasiyan committed Feb 7, 2022
1 parent 1af3537 commit 3473a6f
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 5 deletions.
15 changes: 12 additions & 3 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4920,7 +4920,7 @@
"description": "One of the elements of the OSD"
},
"osdDescElementCraftName": {
"message": "Craft name as set in Configuration tab"
"message": "Craft name as set in the Configuration tab.</br>Can also be set via the \"name\" CLI variable."
},
"osdTextElementAltitude": {
"message": "Altitude",
Expand Down Expand Up @@ -5264,11 +5264,11 @@
"message": "Overlay for the right transmitter stick position."
},
"osdTextElementDisplayName": {
"message": "Display name",
"message": "Display name (Pilot name)",
"description": "One of the elements of the OSD"
},
"osdDescElementDisplayName": {
"message": "Display name as set by the \"display_name\" cli command"
"message": "Pilot name as set in the Configuration tab.</br>Can also be set via the \"display_name\" CLI variable."
},
"osdTextElementEscRpmFreq": {
"message": "ESC RPM frequency",
Expand Down Expand Up @@ -6184,6 +6184,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>name</b> CLI variable."
},
"configurationPilotName": {
"message": "Pilot name"
},
"configurationPilotNameHelp": {
"message": "Can be show in the OSD.</br>Can be set via <b>display_name</b> CLI variable."
},
"configurationFpvCamAngleDegrees": {
"message": "FPV Camera Angle [degrees]"
},
Expand Down
12 changes: 12 additions & 0 deletions src/js/backup_restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ function configuration_backup(callback) {
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;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
configuration.PILOT_NAME = FC.CONFIG.displayName;
}
configuration.DISPLAY_NAME = FC.CONFIG.displayName;
configuration.MIXER_CONFIG = jQuery.extend(true, {}, FC.MIXER_CONFIG);
configuration.SENSOR_CONFIG = jQuery.extend(true, {}, FC.SENSOR_CONFIG);
Expand Down Expand Up @@ -191,6 +194,8 @@ function configuration_backup(callback) {
return MSP.promise(MSPCodes.MSP_SENSOR_CONFIG);
}).then(function() {
return MSP.promise(MSPCodes.MSP_NAME);
}).then(function() {
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_GET_DISPLAY_NAME) : true;
}).then(function() {
return MSP.promise(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG);
}).then(function() {
Expand Down Expand Up @@ -802,6 +807,10 @@ 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_DISPLAY_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 @@ -848,6 +857,9 @@ function configuration_restore(callback) {
FC.RSSI_CONFIG = configuration.RSSI_CONFIG;
FC.BOARD_ALIGNMENT_CONFIG = configuration.BOARD_ALIGNMENT_CONFIG;
FC.CONFIG.name = configuration.CRAFT_NAME;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
FC.CONFIG.displayName = configuration.PILOT_NAME;
}
FC.CONFIG.displayName = configuration.DISPLAY_NAME;
FC.MIXER_CONFIG = configuration.MIXER_CONFIG;
FC.SENSOR_CONFIG = configuration.SENSOR_CONFIG;
Expand Down
2 changes: 1 addition & 1 deletion src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const INITIAL_CONFIG = {
uid: [0, 0, 0],
accelerometerTrims: [0, 0],
name: '',
displayName: 'JOE PILOT',
displayName: '',
numProfiles: 3,
rateProfile: 0,
boardType: 0,
Expand Down
2 changes: 2 additions & 0 deletions src/js/msp/MSPCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,6 @@ const MSPCodes = {
MSP2_SET_MOTOR_OUTPUT_REORDERING: 0x3002,
MSP2_SEND_DSHOT_COMMAND: 0x3003,
MSP2_GET_VTX_DEVICE_STATUS: 0x3004,
MSP2_SET_DISPLAY_NAME: 0x3006,
MSP2_GET_DISPLAY_NAME: 0x3007,
};
17 changes: 17 additions & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,13 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
break;

case MSPCodes.MSP2_GET_DISPLAY_NAME:
FC.CONFIG.displayName = '';
while ((char = data.readU8()) !== null) {
FC.CONFIG.displayName += String.fromCharCode(char);
}
break;

case MSPCodes.MSP_SET_CHANNEL_FORWARDING:
console.log('Channel forwarding saved');
break;
Expand Down Expand Up @@ -1671,6 +1678,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_NAME:
console.log('Name set');
break;
case MSPCodes.MSP2_SET_DISPLAY_NAME:
console.log('Display name 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 @@ -2284,6 +2294,13 @@ MspHelper.prototype.crunch = function(code) {
}
break;

case MSPCodes.MSP2_SET_DISPLAY_NAME:
const MSP_DISPLAY_NAME_BUFFER_SIZE = 64;
for (let i = 0; i < FC.CONFIG.displayName.length && i < MSP_DISPLAY_NAME_BUFFER_SIZE; i++) {
buffer.push8(FC.CONFIG.displayName.charCodeAt(i));
}
break;

case MSPCodes.MSP_SET_BLACKBOX_CONFIG:
buffer.push8(FC.BLACKBOX.blackboxDevice)
.push8(FC.BLACKBOX.blackboxRateNum)
Expand Down
4 changes: 4 additions & 0 deletions src/js/tabs/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TABS.configuration.initialize = function (callback) {
.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, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_GET_DISPLAY_NAME) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31) ? MSP.promise(MSPCodes.MSP_RX_CONFIG) : true; })
.then(() => { return MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG); })
.then(() => { load_html(); });
Expand Down Expand Up @@ -368,6 +369,7 @@ TABS.configuration.initialize = function (callback) {
}

$('input[name="craftName"]').val(FC.CONFIG.name);
$('input[name="pilotName"]').val(FC.CONFIG.displayName);

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
$('input[name="fpvCamAngleDegrees"]').val(FC.RX_CONFIG.fpvCamAngleDegrees);
Expand Down Expand Up @@ -594,6 +596,7 @@ TABS.configuration.initialize = function (callback) {
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());
FC.CONFIG.displayName = $.trim($('input[name="pilotName"]').val());

function save_serial_config() {
mspHelper.sendSerialConfig(save_config);
Expand All @@ -617,6 +620,7 @@ TABS.configuration.initialize = function (callback) {
.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_DISPLAY_NAME, mspHelper.crunch(MSPCodes.MSP2_SET_DISPLAY_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
2 changes: 1 addition & 1 deletion src/js/tabs/osd.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ OSD.generateCraftName = function() {
};

OSD.generateDisplayName = function() {
let preview = 'DISPLAY_NAME';
let preview = 'PILOT_NAME';
if (FC.CONFIG.displayName !== '') {
preview = FC.CONFIG.displayName.toUpperCase();
}
Expand Down
7 changes: 7 additions & 0 deletions src/tabs/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@
<label> <input type="text" name="craftName" maxlength="32" style="width:100px;"/> <span
i18n="craftName"></span>
</label>
<div class="helpicon cf_tip" i18n_title="configurationCraftNameHelp"></div>
</div>
<div class="number">
<label> <input type="text" name="pilotName" maxlength="32" style="width:100px;"/> <span
i18n="configurationPilotName"></span>
</label>
<div class="helpicon cf_tip" i18n_title="configurationPilotNameHelp"></div>
</div>
</div>
</div> <!-- END PERSONALIZATION-->
Expand Down

0 comments on commit 3473a6f

Please sign in to comment.