Merge pull request #1506 from iNavFlight/MrD_Variable-length-craft-name

Craft name enhancments
pull/1507/head
Darren Lines 2 years ago committed by GitHub
commit aa21987b25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1037,15 +1037,6 @@
"configurationSPIProtocol": { "configurationSPIProtocol": {
"message": "RX SPI protocol" "message": "RX SPI protocol"
}, },
"configurationPersonalization": {
"message": "Personalization"
},
"configurationCraftName": {
"message": "Craft Name"
},
"configurationCraftNameHelp": {
"message": "Craft name. Can be displayed by OSD and by compatible RC systems."
},
"configurationEepromSaved": { "configurationEepromSaved": {
"message": "EEPROM <span style=\"color: #37a8db\">saved</span>: Configuration" "message": "EEPROM <span style=\"color: #37a8db\">saved</span>: Configuration"
}, },
@ -2967,6 +2958,9 @@
"osd_video_format": { "osd_video_format": {
"message" : "Video Format" "message" : "Video Format"
}, },
"osd_craft_name": {
"message" : "Craft Name"
},
"osd_units": { "osd_units": {
"message" : "Units" "message" : "Units"
}, },

@ -403,7 +403,7 @@ button {
font-family: 'open_sansregular', 'Segoe UI', Tahoma, sans-serif; font-family: 'open_sansregular', 'Segoe UI', Tahoma, sans-serif;
} }
.spacer_box div input { .spacer_box div input[type="radio"] {
margin-right: 5px; margin-right: 5px;
} }

@ -103,22 +103,6 @@
</div> </div>
</div> </div>
<div class="config-section gui_box grey config-personalization">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="configurationPersonalization"></div>
</div>
<div class="spacer_box">
<div class="string">
<input maxlength="16" id="craft_name" name="craft_name" />
<label for="craft_name">
<span data-i18n="configurationCraftName"></span>
</label>
<div class="helpicon cf_tip" data-i18n_title="configurationCraftNameHelp"></div>
</div>
</div>
</div>
<div class="config-section gui_box grey config-vtx"> <div class="config-section gui_box grey config-vtx">
<div class="gui_box_titlebar"> <div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="configurationVTX"></div> <div class="spacer_box_title" data-i18n="configurationVTX"></div>

@ -10,23 +10,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
googleAnalytics.sendAppView('Configuration'); googleAnalytics.sendAppView('Configuration');
} }
var craftName = null;
var loadCraftName = function (callback) {
if (!CONFIG.name || CONFIG.name.trim() === '') {
mspHelper.getCraftName(function (name) {
craftName = name;
callback();
});
} else {
craftName = CONFIG.name;
callback();
}
};
var saveCraftName = function (callback) {
mspHelper.setCraftName(craftName, callback);
};
var loadChainer = new MSPChainerClass(); var loadChainer = new MSPChainerClass();
var loadChain = [ var loadChain = [
@ -40,7 +23,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
mspHelper.loadMixerConfig, mspHelper.loadMixerConfig,
mspHelper.loadBoardAlignment, mspHelper.loadBoardAlignment,
mspHelper.loadCurrentMeterConfig, mspHelper.loadCurrentMeterConfig,
loadCraftName,
mspHelper.loadMiscV2 mspHelper.loadMiscV2
]; ];
@ -60,7 +42,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
mspHelper.saveVTXConfig, mspHelper.saveVTXConfig,
mspHelper.saveBoardAlignment, mspHelper.saveBoardAlignment,
mspHelper.saveCurrentMeterConfig, mspHelper.saveCurrentMeterConfig,
saveCraftName,
mspHelper.saveMiscV2, mspHelper.saveMiscV2,
saveSettings, saveSettings,
mspHelper.saveToEeprom mspHelper.saveToEeprom
@ -291,15 +272,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('#3ddeadbandhigh').val(REVERSIBLE_MOTORS.deadband_high); $('#3ddeadbandhigh').val(REVERSIBLE_MOTORS.deadband_high);
$('#3dneutral').val(REVERSIBLE_MOTORS.neutral); $('#3dneutral').val(REVERSIBLE_MOTORS.neutral);
// Craft name
if (craftName != null) {
$('.config-personalization').show();
$('input[name="craft_name"]').val(craftName);
} else {
// craft name not supported by the firmware
$('.config-personalization').hide();
}
$('a.save').click(function () { $('a.save').click(function () {
MISC.mag_declination = parseFloat($('#mag_declination').val()); MISC.mag_declination = parseFloat($('#mag_declination').val());
@ -324,8 +296,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val()); SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val());
craftName = $('input[name="craft_name"]').val();
googleAnalytics.sendEvent('Setting', 'I2CSpeed', $('#i2c_speed').children("option:selected").text()); googleAnalytics.sendEvent('Setting', 'I2CSpeed', $('#i2c_speed').children("option:selected").text());
googleAnalytics.sendEvent('Board', 'Accelerometer', $('#sensor-acc').children("option:selected").text()); googleAnalytics.sendEvent('Board', 'Accelerometer', $('#sensor-acc').children("option:selected").text());

@ -53,6 +53,10 @@
</div> </div>
<div class="spacer_box"> <div class="spacer_box">
<div class="settings"> <div class="settings">
<label class="craft_name">
<input type="text" id="craft_name" data-setting="name" data-live="true" />
<span data-i18n="osd_craft_name"></span>
</label>
<label class="units"> <label class="units">
<select id="unit_mode" name="unit_mode"></select> <select id="unit_mode" name="unit_mode"></select>
<span data-i18n="osd_units"></span> <span data-i18n="osd_units"></span>

@ -492,6 +492,7 @@ OSD.DjiElements = {
"PowerLimits" "PowerLimits"
], ],
supportedSettings: [ supportedSettings: [
"craft_name",
"units" "units"
], ],
supportedAlarms: [ supportedAlarms: [
@ -2482,6 +2483,7 @@ OSD.GUI.updateFields = function() {
// Update the OSD preview // Update the OSD preview
refreshOSDSwitchIndicators(); refreshOSDSwitchIndicators();
updateCraftName();
}; };
OSD.GUI.removeBottomLines = function(){ OSD.GUI.removeBottomLines = function(){
@ -2501,6 +2503,8 @@ OSD.GUI.removeBottomLines = function(){
}); });
}; };
OSD.GUI.updateDjiMessageElements = function(on) { OSD.GUI.updateDjiMessageElements = function(on) {
$('.display-field').each(function(index, element) { $('.display-field').each(function(index, element) {
var name = $(element).find('input').attr('name'); var name = $(element).find('input').attr('name');
@ -2862,6 +2866,21 @@ TABS.osd.initialize = function (callback) {
refreshOSDSwitchIndicators(); refreshOSDSwitchIndicators();
}); });
// Function for when text for craft name changes
$('#craft_name').on('keyup', function() {
// Make sure that the craft name only contains A to Z, 0-9, spaces, and basic ASCII symbols
let testExp = new RegExp('^[A-Za-z0-9 !_,:;=@#\\%\\&\\-\\*\\^\\(\\)\\.\\+\\<\\>\\[\\]]');
let testText = $(this).val();
if (testExp.test(testText.slice(-1))) {
$(this).val(testText.toUpperCase());
} else {
$(this).val(testText.slice(0, -1));
}
// Update the OSD preview
updateCraftName();
});
// font preview window // font preview window
var $preview = $('.font-preview'); var $preview = $('.font-preview');
@ -3024,6 +3043,30 @@ function refreshOSDSwitchIndicators() {
OSD.GUI.updatePreviews(); OSD.GUI.updatePreviews();
} }
function updateCraftName() {
let generalGroup = OSD.constants.ALL_DISPLAY_GROUPS.filter(function(e) {
return e.name == "osdGroupGeneral";
})[0];
if ($('#craft_name').val() != undefined) {
for (let si = 0; si < generalGroup.items.length; si++) {
if (generalGroup.items[si].name == "CRAFT_NAME") {
let craftNameText = $('#craft_name').val();
if (craftNameText == "") {
generalGroup.items[si].preview = "CRAFT_NAME";
} else {
generalGroup.items[si].preview = craftNameText;
}
break;
}
}
}
OSD.GUI.updatePreviews();
}
TABS.osd.cleanup = function (callback) { TABS.osd.cleanup = function (callback) {
PortHandler.flush_callbacks(); PortHandler.flush_callbacks();

Loading…
Cancel
Save