Removed Switch Indicators and increase custom to 8

Removed Switch indicators and increased the number of osd custom elements to 8.
pull/2159/head
Darren Lines 2 months ago
parent aadc459adf
commit 7a86b417c6

@ -597,7 +597,7 @@ var FC = {
this.FW_APPROACH = new FwApproachCollection(); this.FW_APPROACH = new FwApproachCollection();
this.OSD_CUSTOM_ELEMENTS = { this.OSD_CUSTOM_ELEMENTS = {
settings: {customElementsCount: 0, customElementTextSize: 0}, settings: {customElementsCount: 0, customElementTextSize: 0, customElementParts: 0},
items: [], items: [],
}; };

@ -238,7 +238,8 @@ var MSPCodes = {
MSP2_ADSB_VEHICLE_LIST: 0x2090, MSP2_ADSB_VEHICLE_LIST: 0x2090,
MSP2_INAV_CUSTOM_OSD_ELEMENTS: 0x2100, MSP2_INAV_CUSTOM_OSD_ELEMENTS: 0x2100,
MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS: 0x2101, MSP2_INAV_CUSTOM_OSD_ELEMENT: 0x2101,
MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS: 0x2102,
MSP2_INAV_SERVO_CONFIG: 0x2200, MSP2_INAV_SERVO_CONFIG: 0x2200,
MSP2_INAV_SET_SERVO_CONFIG: 0x2201, MSP2_INAV_SET_SERVO_CONFIG: 0x2201,

@ -1542,51 +1542,54 @@ var mspHelper = (function () {
break; break;
case MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS: case MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS:
FC.OSD_CUSTOM_ELEMENTS .items = []; FC.OSD_CUSTOM_ELEMENTS.items = [];
var index = 0; let settingsIdx = 0;
if(data.byteLength == 0){ if(data.byteLength == 0) {
FC.OSD_CUSTOM_ELEMENTS .settings.customElementsCount = 0; FC.OSD_CUSTOM_ELEMENTS.settings.customElementsCount = 0;
FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize = 0; FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize = 0;
FC.OSD_CUSTOM_ELEMENTS.settings.customElementParts = 0;
return; return;
} }
FC.OSD_CUSTOM_ELEMENTS .settings.customElementsCount = data.getUint8(index++); FC.OSD_CUSTOM_ELEMENTS.settings.customElementsCount = data.getUint8(settingsIdx++);
FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize = data.getUint8(index++); FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize = data.getUint8(settingsIdx++);
FC.OSD_CUSTOM_ELEMENTS.settings.customElementParts = data.getUint8(settingsIdx++);
for (i = 0; i < FC.OSD_CUSTOM_ELEMENTS .settings.customElementsCount; i++){ break;
var customElement = { case MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENT:
customElementItems: [], var customElement = {
customElementVisibility: {type: 0, value: 0}, customElementItems: [],
customElementText: [], customElementVisibility: {type: 0, value: 0},
}; customElementText: [],
};
for (let ii = 0; ii < FC.OSD_CUSTOM_ELEMENTS .settings.customElementsCount; ii++){ let index = 0;
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++); for (let ii = 0; ii < FC.OSD_CUSTOM_ELEMENTS.settings.customElementParts; ii++) {
customElement.customElementVisibility.value = data.getUint16(index, true); var customElementPart = {type: 0, value: 0,};
customElementPart.type = data.getUint8(index++);
customElementPart.value = data.getUint16(index, true);
index += 2; index += 2;
customElement.customElementItems.push(customElementPart);
}
for (let ii = 0; ii < FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize; ii++){ customElement.customElementVisibility.type = data.getUint8(index++);
var char = data.getUint8(index++); customElement.customElementVisibility.value = data.getUint16(index, true);
if(char === 0){ index += 2;
index += (FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize - 1) - ii;
break; for (let ii = 0; ii < FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize; ii++) {
} var char = data.getUint8(index++);
customElement.customElementText[ii] = char; if(char === 0) {
index += (FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize - 1) - ii;
break;
} }
customElement.customElementText[ii] = char;
}
customElement.customElementText = String.fromCharCode(...customElement.customElementText); customElement.customElementText = String.fromCharCode(...customElement.customElementText);
FC.OSD_CUSTOM_ELEMENTS .items.push(customElement) FC.OSD_CUSTOM_ELEMENTS.items.push(customElement);
}
break; break;
case MSPCodes.MSP2_INAV_GPS_UBLOX_COMMAND: case MSPCodes.MSP2_INAV_GPS_UBLOX_COMMAND:
// Just and ACK from the fc. // Just and ACK from the fc.
@ -2473,7 +2476,17 @@ var mspHelper = (function () {
}; };
self.loadOsdCustomElements = function (callback) { self.loadOsdCustomElements = function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS, false, false, callback); MSP.send_message(MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS, false, false, nextCustomOSDElement);
var cosdeIdx = 0;
function nextCustomOSDElement() {
if (cosdeIdx < FC.OSD_CUSTOM_ELEMENTS .settings.customElementsCount - 1) {
MSP.send_message(MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENT, [cosdeIdx++], false, nextCustomOSDElement);
} else {
MSP.send_message(MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENT, [cosdeIdx++], false, callback);
}
}
} }
self.sendModeRanges = function (onCompleteCallback) { self.sendModeRanges = function (onCompleteCallback) {

@ -301,41 +301,6 @@
</label> </label>
</div> </div>
</div> </div>
<div class="gui_box grey switch-indicator-container">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="osd_switch_indicator_settings"></div>
</div>
<div class="spacer_box settings">
<label>
<input type="checkbox" id="switchIndicators_alignLeft" data-setting="osd_switch_indicators_align_left" data-live="true" class="toggle"></select>
<span data-i18n="osd_switch_indicators_align_left"></span>
</label>
<label>
<input type="text" class="osdSwitchIndName" id="osdSwitchInd0_name" data-setting="osd_switch_indicator_zero_name" />
<select class="osdSwitchInd_channel" data-setting="osd_switch_indicator_zero_channel" data-live="true"></select>
<span data-i18n="osdSwitchInd0"></span>
</label>
<label>
<input type="text" class="osdSwitchIndName" id="osdSwitchInd1_name" data-setting="osd_switch_indicator_one_name" />
<select class="osdSwitchInd_channel" data-setting="osd_switch_indicator_one_channel" data-live="true"></select>
<span data-i18n="osdSwitchInd1"></span>
</label>
<label>
<input type="text" class="osdSwitchIndName" id="osdSwitchInd2_name" data-setting="osd_switch_indicator_two_name" />
<select class="osdSwitchInd_channel" data-setting="osd_switch_indicator_two_channel" data-live="true"></select>
<span data-i18n="osdSwitchInd2"></span>
</label>
<label>
<input type="text" class="osdSwitchIndName" id="osdSwitchInd3_name" data-setting="osd_switch_indicator_three_name" />
<select class="osdSwitchInd_channel" data-setting="osd_switch_indicator_three_channel" data-live="true"></select>
<span data-i18n="osdSwitchInd3"></span>
</label>
</div>
</div>
<div class="gui_box grey custom-element-container"> <div class="gui_box grey custom-element-container">
<div class="gui_box_titlebar"> <div class="gui_box_titlebar">

@ -19,6 +19,7 @@ const { globalSettings } = require('./../js/globalSettings');
const { PortHandler } = require('./../js/port_handler'); const { PortHandler } = require('./../js/port_handler');
const i18n = require('./../js/localization'); const i18n = require('./../js/localization');
const jBox = require('./../js/libraries/jBox/jBox.min'); const jBox = require('./../js/libraries/jBox/jBox.min');
const { Console } = require('console');
var SYM = SYM || {}; var SYM = SYM || {};
@ -553,7 +554,6 @@ OSD.DjiElements = {
"Timers", "Timers",
"VTX", "VTX",
"CRSF", "CRSF",
"SwitchIndicators",
"GVars", "GVars",
"PIDs", "PIDs",
"PIDOutputs", "PIDOutputs",
@ -1848,35 +1848,6 @@ OSD.constants = {
}, },
] ]
}, },
{
name: 'osdGroupSwitchIndicators',
items: [
{
name: 'SWITCH_INDICATOR_0',
id: 130,
positionable: true,
preview: 'SWI1' + FONT.symbol(SYM.SWITCH_INDICATOR_HIGH)
},
{
name: 'SWITCH_INDICATOR_1',
id: 131,
positionable: true,
preview: 'SWI2' + FONT.symbol(SYM.SWITCH_INDICATOR_HIGH)
},
{
name: 'SWITCH_INDICATOR_2',
id: 132,
positionable: true,
preview: 'SWI3' + FONT.symbol(SYM.SWITCH_INDICATOR_HIGH)
},
{
name: 'SWITCH_INDICATOR_3',
id: 133,
positionable: true,
preview: 'SWI4' + FONT.symbol(SYM.SWITCH_INDICATOR_HIGH)
}
]
},
{ {
name: 'osdGroupGVars', name: 'osdGroupGVars',
items: [ items: [
@ -2812,7 +2783,6 @@ OSD.GUI.updateFields = function() {
GUI.switchery(); GUI.switchery();
// Update the OSD preview // Update the OSD preview
refreshOSDSwitchIndicators();
updatePilotAndCraftNames(); updatePilotAndCraftNames();
updatePanServoPreview(); updatePanServoPreview();
}; };
@ -3290,6 +3260,7 @@ TABS.osd = {};
TABS.osd.initialize = function (callback) { TABS.osd.initialize = function (callback) {
mspHelper.loadServoMixRules(); mspHelper.loadServoMixRules();
mspHelper.loadLogicConditions();
if (GUI.active_tab != 'osd') { if (GUI.active_tab != 'osd') {
GUI.active_tab = 'osd'; GUI.active_tab = 'osd';
@ -3344,12 +3315,6 @@ TABS.osd.initialize = function (callback) {
} }
// Update the OSD preview // Update the OSD preview
refreshOSDSwitchIndicators();
});
// Function to update the OSD layout when the switch text alignment changes
$("#switchIndicators_alignLeft").on('change', function() {
refreshOSDSwitchIndicators();
}); });
// Functions for when pan servo settings change // Functions for when pan servo settings change
@ -3633,8 +3598,7 @@ function customElementNormaliseRow(row){
} }
} }
function customElementDisableNonValidOptionsRow(row){ function customElementDisableNonValidOptionsRow(row) {
var selectedTextIndex = false; var selectedTextIndex = false;
for(let i = 0; i < 3; i++){ for(let i = 0; i < 3; i++){
let elementType = $('.osdCustomElement-' + row + '-part-' + i + '-type'); let elementType = $('.osdCustomElement-' + row + '-part-' + i + '-type');
@ -3657,13 +3621,12 @@ function customElementDisableNonValidOptionsRow(row){
} }
function customElementGetDataForRow(row){ function customElementGetDataForRow(row){
var data = []; var data = [];
data.push8(row); data.push8(row);
var text = ""; var text = "";
for(var ii = 0; ii < 3; ii++){ for(var ii = 0; ii < FC.OSD_CUSTOM_ELEMENTS.settings.customElementParts; ii++){
var elementType = $('.osdCustomElement-' + row + '-part-' + ii + '-type'); var elementType = $('.osdCustomElement-' + row + '-part-' + ii + '-type');
var valueCell = $('.' + elementType.data('valueCellClass')); var valueCell = $('.' + elementType.data('valueCellClass'));
var partValue = 0; var partValue = 0;
@ -3705,7 +3668,9 @@ function customElementGetDataForRow(row){
data.push8(parseInt(elementVisibilityType.val())); data.push8(parseInt(elementVisibilityType.val()));
data.push16(visibilityValue); data.push16(visibilityValue);
for(var i = 0; i < FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize; i++){ console.log("Saving osd custom data for number " + row + " | data: " + data);
for(var i = 0; i < FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize; i++){
if(i < text.length){ if(i < text.length){
data.push8(text.charCodeAt(i)) data.push8(text.charCodeAt(i))
}else{ }else{
@ -3718,42 +3683,20 @@ function customElementGetDataForRow(row){
function getGVoptions(){ function getGVoptions(){
var result = ''; var result = '';
for(var i = 0; i < 8; i++){ for(var i = 0; i < 8; i++) {
result += `<option value="` + i + `">GV `+i+`</option>`; result += `<option value="` + i + `">GV ` + i + `</option>`;
} }
return result; return result;
} }
function getLCoptions(){ function getLCoptions(){
var result = ''; var result = '';
for(var i = 0; i < 64; i++){ for(var i = 0; i < FC.LOGIC_CONDITIONS.getMaxLogicConditionCount(); i++) {
result += `<option value="` + i + `">LC `+i+`</option>`; if (FC.LOGIC_CONDITIONS.isEnabled(i)) {
} result += `<option value="` + i + `">LC ` + i + `</option>`;
return result;
}
function refreshOSDSwitchIndicators() {
let group = OSD.constants.ALL_DISPLAY_GROUPS.filter(function(e) {
return e.name == "osdGroupSwitchIndicators";
})[0];
for (let si = 0; si < group.items.length; si++) {
let item = group.items[si];
if ($("#osdSwitchInd" + si +"_name").val() != undefined) {
let switchIndText = $("#osdSwitchInd" + si +"_name").val();
if (switchIndText == "") {
item.preview = FONT.symbol(SYM.SWITCH_INDICATOR_HIGH);
} else {
if ($("#switchIndicators_alignLeft").prop('checked')) {
item.preview = switchIndText + FONT.symbol(SYM.SWITCH_INDICATOR_HIGH);
} else {
item.preview = FONT.symbol(SYM.SWITCH_INDICATOR_HIGH) + switchIndText;
}
}
} }
} }
return result;
OSD.GUI.updatePreviews();
} }
function updatePilotAndCraftNames() { function updatePilotAndCraftNames() {

Loading…
Cancel
Save