1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-14 03:49:53 +03:00

Merge branch 'release_7.1.0' into Autoland-7.0.1

This commit is contained in:
Andi Kanzler 2024-02-14 10:07:11 -03:00 committed by GitHub
commit 2a9a366a34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 384 additions and 20 deletions

View file

@ -850,7 +850,7 @@
"message": "External PWM servo driver" "message": "External PWM servo driver"
}, },
"featurePWM_SERVO_DRIVERTip": { "featurePWM_SERVO_DRIVERTip": {
"message": "Use external PCA9685 PMW driver to connect up to 16 servos to flight controller. PCA9685 has to be connected to enable this feature." "message": "Use external PCA9685 PWM driver to connect up to 16 servos to flight controller. PCA9685 has to be connected to enable this feature."
}, },
"featureRSSI_ADCTip": { "featureRSSI_ADCTip": {
"message": "RSSI is a measurement of signal strength and is very handy so you know when your aircraft is going out of range or if it is suffering RF interference." "message": "RSSI is a measurement of signal strength and is very handy so you know when your aircraft is going out of range or if it is suffering RF interference."
@ -3503,6 +3503,12 @@
"osd_hud_settings": { "osd_hud_settings": {
"message": "Heads up Display settings" "message": "Heads up Display settings"
}, },
"osd_custom_element_settings": {
"message": "Custom OSD elements"
},
"custom_element": {
"message": "Custom element"
},
"osd_hud_settings_HELP": { "osd_hud_settings_HELP": {
"message": "This section allows tweaking the behavior of HUD elements." "message": "This section allows tweaking the behavior of HUD elements."
}, },

View file

@ -66,7 +66,9 @@ var CONFIG,
CURRENT_METER_CONFIG, CURRENT_METER_CONFIG,
FEATURES, FEATURES,
RATE_DYNAMICS, RATE_DYNAMICS,
FW_APPROACH; FW_APPROACH,
OSD_CUSTOM_ELEMENTS;
var FC = { var FC = {
restartRequired: false, restartRequired: false,
@ -566,7 +568,14 @@ var FC = {
expo: null expo: null
}; };
FW_APPROACH = new FwApproachCollection(); FW_APPROACH = new FwApproachCollection();
OSD_CUSTOM_ELEMENTS = {
settings: {customElementsCount: 0, customElementTextSize: 0},
items: [],
};
}, },
getOutputUsages: function() { getOutputUsages: function() {
return { return {

View file

@ -249,8 +249,13 @@ var MSPCodes = {
MSP2_INAV_EZ_TUNE_SET: 0x2071, MSP2_INAV_EZ_TUNE_SET: 0x2071,
MSP2_INAV_SELECT_MIXER_PROFILE: 0x2080, MSP2_INAV_SELECT_MIXER_PROFILE: 0x2080,
MSP2_INAV_SET_LED_STRIP_CONFIG_EX: 0x2049, MSP2_INAV_SET_LED_STRIP_CONFIG_EX: 0x2049,
MSP2_INAV_FW_APPROACH: 0x204A, MSP2_INAV_FW_APPROACH: 0x204A,
MSP2_INAV_SET_FW_APPROACH: 0x204B MSP2_INAV_SET_FW_APPROACH: 0x204B
MSP2_INAV_CUSTOM_OSD_ELEMENTS: 0x2100,
MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS: 0x2101,
}; };

View file

@ -90,7 +90,7 @@ var mspHelper = (function (gui) {
CONFIG.armingFlags = data.getUint32(offset, true); CONFIG.armingFlags = data.getUint32(offset, true);
offset += 4; offset += 4;
//As there are 8 bytes for mspBoxModeFlags (number of bytes is actually variable) //As there are 8 bytes for mspBoxModeFlags (number of bytes is actually variable)
//read mixer profile as the last byte in the the message //read mixer profile as the last byte in the the message
profile_byte = data.getUint8(dataHandler.message_length_expected - 1); profile_byte = data.getUint8(dataHandler.message_length_expected - 1);
@ -1500,6 +1500,9 @@ var mspHelper = (function (gui) {
case MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE: case MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE:
console.log('Battery profile selected'); console.log('Battery profile selected');
break; break;
case MSPCodes.MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS:
console.log('OSD custom elements preferences saved');
break;
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING: case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING:
OUTPUT_MAPPING.flush(); OUTPUT_MAPPING.flush();
for (i = 0; i < data.byteLength; ++i) for (i = 0; i < data.byteLength; ++i)
@ -1627,6 +1630,48 @@ var mspHelper = (function (gui) {
console.log('EzTune settings saved'); console.log('EzTune settings saved');
break; break;
case MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS:
OSD_CUSTOM_ELEMENTS.items = [];
var index = 0;
OSD_CUSTOM_ELEMENTS.settings.customElementsCount = data.getUint8(index++);
OSD_CUSTOM_ELEMENTS.settings.customElementTextSize = data.getUint8(index++);
for (i = 0; i < OSD_CUSTOM_ELEMENTS.settings.customElementsCount; i++){
var customElement = {
customElementItems: [],
customElementVisibility: {type: 0, value: 0},
customElementText: [],
};
for (let ii = 0; ii < OSD_CUSTOM_ELEMENTS.settings.customElementsCount; ii++){
var customElementPart = {type: 0, value: 0,};
customElementPart.type = data.getUint8(index++);
customElementPart.value = data.getUint16(index, true);
index += 2;
customElement.customElementItems.push(customElementPart);
}
customElement.customElementVisibility.type = data.getUint8(index++);
customElement.customElementVisibility.value = data.getUint16(index, true);
index += 2;
for (let ii = 0; ii < OSD_CUSTOM_ELEMENTS.settings.customElementTextSize; ii++){
var char = data.getUint8(index++);
if(char === 0){
index += (OSD_CUSTOM_ELEMENTS.settings.customElementTextSize - 1) - ii;
break;
}
customElement.customElementText[ii] = char;
}
customElement.customElementText = String.fromCharCode(...customElement.customElementText);
OSD_CUSTOM_ELEMENTS.items.push(customElement)
}
break;
default: default:
console.log('Unknown code detected: ' + dataHandler.code); console.log('Unknown code detected: ' + dataHandler.code);
} else { } else {
@ -2571,6 +2616,10 @@ var mspHelper = (function (gui) {
} }
}; };
self.loadOsdCustomElements = function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS, false, false, callback);
}
self.sendModeRanges = function (onCompleteCallback) { self.sendModeRanges = function (onCompleteCallback) {
var nextFunction = send_next_mode_range; var nextFunction = send_next_mode_range;
@ -2948,7 +2997,7 @@ var mspHelper = (function (gui) {
MSP.send_message(MSPCodes.MSP2_INAV_TIMER_OUTPUT_MODE, false, false, callback); MSP.send_message(MSPCodes.MSP2_INAV_TIMER_OUTPUT_MODE, false, false, callback);
} }
self.sendTimerOutputModes = function(onCompleteCallback) { self.sendTimerOutputModes = function(callback) {
var nextFunction = send_next_output_mode; var nextFunction = send_next_output_mode;
var idIndex = 0; var idIndex = 0;
@ -2973,7 +3022,7 @@ var mspHelper = (function (gui) {
// prepare for next iteration // prepare for next iteration
idIndex++; idIndex++;
if (idIndex == overrideIds.length) { if (idIndex == overrideIds.length) {
nextFunction = onCompleteCallback; nextFunction = callback;
} }
MSP.send_message(MSPCodes.MSP2_INAV_SET_TIMER_OUTPUT_MODE, buffer, false, nextFunction); MSP.send_message(MSPCodes.MSP2_INAV_SET_TIMER_OUTPUT_MODE, buffer, false, nextFunction);
@ -3366,12 +3415,6 @@ var mspHelper = (function (gui) {
self.encodeSetting = function (name, value) { self.encodeSetting = function (name, value) {
return this._getSetting(name).then(function (setting) { return this._getSetting(name).then(function (setting) {
if (!setting) {
console.log("Setting invalid: " + name);
return null;
}
if (setting.table && !Number.isInteger(value)) { if (setting.table && !Number.isInteger(value)) {
var found = false; var found = false;
for (var ii = 0; ii < setting.table.values.length; ii++) { for (var ii = 0; ii < setting.table.values.length; ii++) {
@ -3419,11 +3462,7 @@ var mspHelper = (function (gui) {
self.setSetting = function (name, value, callback) { self.setSetting = function (name, value, callback) {
this.encodeSetting(name, value).then(function (data) { this.encodeSetting(name, value).then(function (data) {
if (data) { return MSP.promise(MSPCodes.MSPV2_SET_SETTING, data).then(callback);
return MSP.promise(MSPCodes.MSPV2_SET_SETTING, data).then(callback);
} else {
return Promise.resolve().then(callback);
}
}); });
}; };

View file

@ -719,4 +719,18 @@ button {
.tab-osd .osd_settings .switchery, .tab-osd .osd_settings .switchery,
.tab-osd .unit_wrapper { .tab-osd .unit_wrapper {
vertical-align: top; vertical-align: top;
}
.osdCustomElement_main_table {
width: 100%;
table-layout: fixed;
max-width: 400px;
}
.osdCustomElement_main_table td{
max-width: 80px;
}
.osdCustomElement_main_table select, .osdCustomElement_main_table input{
width: 100% !important;
} }

View file

@ -316,7 +316,17 @@
</label> </label>
</div> </div>
</div> </div>
<div class="gui_box grey pan-servo-container">
<div class="gui_box grey custom-element-container">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="osd_custom_element_settings"></div>
</div>
<div class="spacer_box settings" id="osdCustomElements"></div>
</div>
<div class="gui_box grey pan-servo-container">
<div class="gui_box_titlebar"> <div class="gui_box_titlebar">
<div for="osd_pan_servo_settings" class="helpicon cf_tip" data-i18n_title="osd_pan_servo_settings_HELP"></div> <div for="osd_pan_servo_settings" class="helpicon cf_tip" data-i18n_title="osd_pan_servo_settings_HELP"></div>
<div class="spacer_box_title" data-i18n="osd_pan_servo_settings"></div> <div class="spacer_box_title" data-i18n="osd_pan_servo_settings"></div>
@ -425,6 +435,12 @@
<a class="flash_font active" data-i18n="osd_font_upload"></a> <a class="flash_font active" data-i18n="osd_font_upload"></a>
</div> </div>
</div> </div>
<div id="fonttypeselectorcontent" style="display:none; width:712px;">
<div class="font-picker" style="margin-bottom: 10px;">
<h1 class="tab_title">Font:</h1>
<div class="content_wrapper font-preview"></div>
</div>
</div>
<div class="clear-both"></div> <div class="clear-both"></div>
</div> </div>
</div> </div>

View file

@ -340,7 +340,7 @@ FONT.preview = function ($el) {
$el.empty(); $el.empty();
for (var i = 1; i <= SYM.LAST_CHAR; i++) { for (var i = 1; i <= SYM.LAST_CHAR; i++) {
var url = FONT.data.character_image_urls[i]; var url = FONT.data.character_image_urls[i];
$el.append('<img src="' + url + '" title="0x' + i.toString(16) + '"></img> '); $el.append('<img src="' + url + '" title="0x' + i.toString(16) + ' (' + i.toString(10) + ') "></img> ');
} }
}; };
@ -1832,7 +1832,28 @@ OSD.constants = {
id: 116, id: 116,
positionable: true, positionable: true,
preview: 'G3:30126' preview: 'G3:30126'
} },
{
name: 'CUSTOM ELEMENT 1',
id: 147,
min_version: '7.1.0',
positionable: true,
preview: "CE_1",
},
{
name: 'CUSTOM ELEMENT 2',
id: 148,
min_version: '7.1.0',
positionable: true,
preview: "CE_2",
},
{
name: 'CUSTOM ELEMENT 3',
id: 149,
min_version: '7.1.0',
positionable: true,
preview: "CE_3",
},
] ]
}, },
{ {
@ -2125,6 +2146,8 @@ OSD.reload = function(callback) {
}); });
}); });
}); });
MSP.send_message(MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS);
}; };
OSD.updateSelectedLayout = function(new_layout) { OSD.updateSelectedLayout = function(new_layout) {
@ -3360,9 +3383,261 @@ TABS.osd.initialize = function (callback) {
usePitot = (SENSOR_CONFIG.pitot != 0); usePitot = (SENSOR_CONFIG.pitot != 0);
GUI.content_ready(callback); GUI.content_ready(callback);
}); });
mspHelper.loadOsdCustomElements(createCustomElements);
})); }));
}; };
function createCustomElements(){
if(OSD_CUSTOM_ELEMENTS.settings.customElementsCount == 0){
$('.custom-element-container').remove();
}
var customElementsContainer = $('#osdCustomElements');
for(var i = 0; i < OSD_CUSTOM_ELEMENTS.settings.customElementsCount; i++){
var label = $('<label>');
var customElementTable = $('<table>').addClass('osdCustomElement_main_table');
var customElementRowType = $('<tr>').data('row', i);
var customElementRowValue = $('<tr>').data('row', i);
var customElementLabel = $('<tr>');
for(var ii = 0; ii < 3; ii++){
var select = $('<select>').addClass('osdCustomElement-' + i + '-part-' + ii + '-type').data('valueCellClass', 'osdCustomElement-' + i + '-part-' + ii + '-value').html(`
<option value="0">none</option>
<option data-value="text" value="1">Text</option>
<option data-value="ico" value="2">Icon Static</option>
<option data-value="ico_gv" value="3">Icon Global Variable</option>
<option data-value="gv" value="4">Global Variable 00000</option>
<option data-value="gv" value="5">Global Variable 000.00</option>
<option data-value="gv" value="6">Global Variable 000</option>
<option data-value="gv" value="7">Global Variable 0.0</option>
`);
customElementRowType.append($('<td>').append(select));
customElementRowValue.append($('<td>').addClass('osdCustomElement-' + i + '-part-' + ii + '-value').append(
$('<input>').addClass('value').addClass('text').attr('type', 'text').attr('maxlength', OSD_CUSTOM_ELEMENTS.settings.customElementTextSize).hide()
).append(
$('<input>').addClass('value').addClass('ico').attr('min', 1).attr('max', 255).hide()
).append(
$('<select>').addClass('value').addClass('ico_gv').html(getGVoptions()).hide()
).append(
$('<select>').addClass('value').addClass('gv').html(getGVoptions()).hide()
));
select.change(function(){
var dataValue = $(this).find(':selected').data('value');
var valueBlock = $('.' + $(this).data('valueCellClass'))
valueBlock.find('.value').hide();
valueBlock.find('.' + dataValue).show();
});
}
var selectVisibility = $('<select>').addClass('osdCustomElement-' + i + '-visibility-type').data('valueCellClass', 'osdCustomElement-' + i + '-visibility-value').html(`
<option value="0">always</option>
<option data-value="gv" value="1">Global Variable</option>
<option data-value="lc" value="2">Logic Condition</option>
`);
customElementRowType.append($('<td>').append(selectVisibility));
customElementRowValue.append($('<td>').addClass('osdCustomElement-' + i + '-visibility-value').append(
$('<select>').addClass('value').addClass('gv').html(getGVoptions()).hide()
).append(
$('<select>').addClass('value').addClass('lc').html(getLCoptions()).hide()
));
selectVisibility.change(function(){
var dataValue = $(this).find(':selected').data('value');
var valueBlock = $('.' + $(this).data('valueCellClass'))
valueBlock.find('.value').hide();
valueBlock.find('.' + dataValue).show();
});
customElementLabel.append($('<td>').attr('colspan', 2).append($('<span>').html(chrome.i18n.getMessage("custom_element") + ' ' + (i + 1))));
customElementTable.append(customElementRowType).append(customElementRowValue).append(customElementLabel);
label.append(customElementTable);
customElementsContainer.append(label);
}
fillCustomElementsValues();
customElementsInitCallback();
}
function fillCustomElementsValues() {
for (var i = 0; i < OSD_CUSTOM_ELEMENTS.settings.customElementsCount; i++) {
for (var ii = 0; ii < 3; ii++) {
$('.osdCustomElement-' + i + '-part-' + ii + '-type').val(OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].type).trigger('change');
var valueCell = $('.osdCustomElement-' + i + '-part-' + ii + '-value');
switch (OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].type){
case 1:
valueCell.find('.text').val(OSD_CUSTOM_ELEMENTS.items[i].customElementText).trigger('change');
break;
case 2:
valueCell.find('.ico').val(OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].value).trigger('change');
break;
case 3:
valueCell.find('.ico_gv').val(OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].value).trigger('change');
break;
case 4:
case 5:
case 6:
case 7:
valueCell.find('.gv').val(OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].value).trigger('change');
break;
}
}
$('.osdCustomElement-' + i + '-visibility-type').val(OSD_CUSTOM_ELEMENTS.items[i].customElementVisibility.type).trigger('change');
var valueVisibilityCell = $('.osdCustomElement-' + i + '-visibility-value');
switch (OSD_CUSTOM_ELEMENTS.items[i].customElementVisibility.type){
case 1:
valueVisibilityCell.find('.gv').val(OSD_CUSTOM_ELEMENTS.items[i].customElementVisibility.value).trigger('change');
break;
case 2:
valueVisibilityCell.find('.lc').val(OSD_CUSTOM_ELEMENTS.items[i].customElementVisibility.value).trigger('change');
break;
}
customElementNormaliseRow(i);
customElementDisableNonValidOptionsRow(i);
}
}
function customElementsInitCallback() {
var callback = function(){
var row = $(this).closest('tr').data('row');
customElementNormaliseRow(row);
customElementDisableNonValidOptionsRow(row);
MSP.promise(MSPCodes.MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS, customElementGetDataForRow(row));
};
var customElements = $('#osdCustomElements')
customElements.find('input, select').change(callback);
customElements.find('input').keyup(callback);
}
function customElementNormaliseRow(row){
for(var i = 0; i < 3; i++){
var elementType = $('.osdCustomElement-' + row + '-part-' + i + '-type');
var valueCell = $('.' + elementType.data('valueCellClass'));
switch (parseInt(elementType.val())){
case 1:
valueCell.find('.text').val(valueCell.find('.text').val().toUpperCase());
valueCell.find('.text').val(valueCell.find('.text').val().replace(/[^A-Z0-9!.\* ]/g, ""));
break;
case 2:
valueCell.find('.ico').val(valueCell.find('.ico').val() > 255 ? 255 : valueCell.find('.ico').val());
valueCell.find('.ico').val(valueCell.find('.ico').val() < 1 ? 1 : valueCell.find('.ico').val());
}
}
}
function customElementDisableNonValidOptionsRow(row){
var selectedTextIndex = false;
for(let i = 0; i < 3; i++){
let elementType = $('.osdCustomElement-' + row + '-part-' + i + '-type');
if(parseInt(elementType.val()) === 1)
{
selectedTextIndex = i;
break;
}
}
for(let i = 0; i < 3; i++){
let elementType = $('.osdCustomElement-' + row + '-part-' + i + '-type');
if(i !== selectedTextIndex && selectedTextIndex !== false){
elementType.find('option[value="1"]').attr('disabled', 'disabled');
}else{
elementType.find('option[value="1"]').removeAttr('disabled');
}
}
}
function customElementGetDataForRow(row){
var data = [];
data.push8(row);
var text = "";
for(var ii = 0; ii < 3; ii++){
var elementType = $('.osdCustomElement-' + row + '-part-' + ii + '-type');
var valueCell = $('.' + elementType.data('valueCellClass'));
var partValue = 0;
switch (parseInt(elementType.val())){
case 1:
text = valueCell.find('.text').val();
break;
case 2:
partValue = parseInt(valueCell.find('.ico').val());
break;
case 3:
partValue = parseInt(valueCell.find('.ico_gv').find(':selected').val());
break;
case 4:
case 5:
case 6:
case 7:
partValue = parseInt(valueCell.find('.gv').find(':selected').val());
break;
}
data.push8(parseInt(elementType.val()));
data.push16(partValue);
}
var elementVisibilityType = $('.osdCustomElement-' + row + '-visibility-type');
var valueVisibilityCell = $('.' + elementVisibilityType.data('valueCellClass'));
var visibilityValue = null;
switch (parseInt(elementVisibilityType.val())){
case 1:
visibilityValue = parseInt(valueVisibilityCell.find('.gv').find(':selected').val());
case 2:
visibilityValue = parseInt(valueVisibilityCell.find('.lc').find(':selected').val());
break;
}
data.push8(parseInt(elementVisibilityType.val()));
data.push16(visibilityValue);
for(var i = 0; i < OSD_CUSTOM_ELEMENTS.settings.customElementTextSize; i++){
if(i < text.length){
data.push8(text.charCodeAt(i))
}else{
data.push8(0);
}
}
return data;
}
function getGVoptions(){
var result = '';
for(var i = 0; i < 8; i++){
result += `<option value="` + i + `">GV `+i+`</option>`;
}
return result;
}
function getLCoptions(){
var result = '';
for(var i = 0; i < 64; i++){
result += `<option value="` + i + `">LC `+i+`</option>`;
}
return result;
}
function refreshOSDSwitchIndicators() { function refreshOSDSwitchIndicators() {
let group = OSD.constants.ALL_DISPLAY_GROUPS.filter(function(e) { let group = OSD.constants.ALL_DISPLAY_GROUPS.filter(function(e) {
return e.name == "osdGroupSwitchIndicators"; return e.name == "osdGroupSwitchIndicators";
@ -3384,7 +3659,7 @@ function refreshOSDSwitchIndicators() {
} }
OSD.GUI.updatePreviews(); OSD.GUI.updatePreviews();
}; }
function updatePilotAndCraftNames() { function updatePilotAndCraftNames() {
let foundPilotName = ($('#pilot_name').val() == undefined); let foundPilotName = ($('#pilot_name').val() == undefined);