mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 16:55:22 +03:00
Removed Switch Indicators and increase custom to 8
Removed Switch indicators and increased the number of osd custom elements to 8.
This commit is contained in:
parent
aadc459adf
commit
7a86b417c6
5 changed files with 66 additions and 144 deletions
2
js/fc.js
2
js/fc.js
|
@ -597,7 +597,7 @@ var FC = {
|
|||
this.FW_APPROACH = new FwApproachCollection();
|
||||
|
||||
this.OSD_CUSTOM_ELEMENTS = {
|
||||
settings: {customElementsCount: 0, customElementTextSize: 0},
|
||||
settings: {customElementsCount: 0, customElementTextSize: 0, customElementParts: 0},
|
||||
items: [],
|
||||
};
|
||||
|
||||
|
|
|
@ -238,7 +238,8 @@ var MSPCodes = {
|
|||
MSP2_ADSB_VEHICLE_LIST: 0x2090,
|
||||
|
||||
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_SET_SERVO_CONFIG: 0x2201,
|
||||
|
|
|
@ -1542,51 +1542,54 @@ var mspHelper = (function () {
|
|||
break;
|
||||
|
||||
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){
|
||||
FC.OSD_CUSTOM_ELEMENTS .settings.customElementsCount = 0;
|
||||
FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize = 0;
|
||||
if(data.byteLength == 0) {
|
||||
FC.OSD_CUSTOM_ELEMENTS.settings.customElementsCount = 0;
|
||||
FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize = 0;
|
||||
FC.OSD_CUSTOM_ELEMENTS.settings.customElementParts = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
FC.OSD_CUSTOM_ELEMENTS .settings.customElementsCount = data.getUint8(index++);
|
||||
FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize = data.getUint8(index++);
|
||||
FC.OSD_CUSTOM_ELEMENTS.settings.customElementsCount = data.getUint8(settingsIdx++);
|
||||
FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize = data.getUint8(settingsIdx++);
|
||||
FC.OSD_CUSTOM_ELEMENTS.settings.customElementParts = data.getUint8(settingsIdx++);
|
||||
break;
|
||||
case MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENT:
|
||||
var customElement = {
|
||||
customElementItems: [],
|
||||
customElementVisibility: {type: 0, value: 0},
|
||||
customElementText: [],
|
||||
};
|
||||
|
||||
for (i = 0; i < FC.OSD_CUSTOM_ELEMENTS .settings.customElementsCount; i++){
|
||||
var customElement = {
|
||||
customElementItems: [],
|
||||
customElementVisibility: {type: 0, value: 0},
|
||||
customElementText: [],
|
||||
};
|
||||
let index = 0;
|
||||
|
||||
for (let ii = 0; ii < FC.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);
|
||||
for (let ii = 0; ii < FC.OSD_CUSTOM_ELEMENTS.settings.customElementParts; ii++) {
|
||||
var customElementPart = {type: 0, value: 0,};
|
||||
customElementPart.type = data.getUint8(index++);
|
||||
customElementPart.value = data.getUint16(index, true);
|
||||
index += 2;
|
||||
|
||||
for (let ii = 0; ii < FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize; ii++){
|
||||
var char = data.getUint8(index++);
|
||||
if(char === 0){
|
||||
index += (FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize - 1) - ii;
|
||||
break;
|
||||
}
|
||||
customElement.customElementText[ii] = char;
|
||||
}
|
||||
|
||||
customElement.customElementText = String.fromCharCode(...customElement.customElementText);
|
||||
|
||||
FC.OSD_CUSTOM_ELEMENTS .items.push(customElement)
|
||||
customElement.customElementItems.push(customElementPart);
|
||||
}
|
||||
|
||||
customElement.customElementVisibility.type = data.getUint8(index++);
|
||||
customElement.customElementVisibility.value = data.getUint16(index, true);
|
||||
index += 2;
|
||||
|
||||
for (let ii = 0; ii < FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize; ii++) {
|
||||
var char = data.getUint8(index++);
|
||||
if(char === 0) {
|
||||
index += (FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize - 1) - ii;
|
||||
break;
|
||||
}
|
||||
customElement.customElementText[ii] = char;
|
||||
}
|
||||
|
||||
customElement.customElementText = String.fromCharCode(...customElement.customElementText);
|
||||
|
||||
FC.OSD_CUSTOM_ELEMENTS.items.push(customElement);
|
||||
break;
|
||||
case MSPCodes.MSP2_INAV_GPS_UBLOX_COMMAND:
|
||||
// Just and ACK from the fc.
|
||||
|
@ -2473,7 +2476,17 @@ var mspHelper = (function () {
|
|||
};
|
||||
|
||||
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) {
|
||||
|
|
|
@ -301,41 +301,6 @@
|
|||
</label>
|
||||
</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_titlebar">
|
||||
|
|
83
tabs/osd.js
83
tabs/osd.js
|
@ -19,6 +19,7 @@ const { globalSettings } = require('./../js/globalSettings');
|
|||
const { PortHandler } = require('./../js/port_handler');
|
||||
const i18n = require('./../js/localization');
|
||||
const jBox = require('./../js/libraries/jBox/jBox.min');
|
||||
const { Console } = require('console');
|
||||
|
||||
|
||||
var SYM = SYM || {};
|
||||
|
@ -553,7 +554,6 @@ OSD.DjiElements = {
|
|||
"Timers",
|
||||
"VTX",
|
||||
"CRSF",
|
||||
"SwitchIndicators",
|
||||
"GVars",
|
||||
"PIDs",
|
||||
"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',
|
||||
items: [
|
||||
|
@ -2812,7 +2783,6 @@ OSD.GUI.updateFields = function() {
|
|||
GUI.switchery();
|
||||
|
||||
// Update the OSD preview
|
||||
refreshOSDSwitchIndicators();
|
||||
updatePilotAndCraftNames();
|
||||
updatePanServoPreview();
|
||||
};
|
||||
|
@ -3290,6 +3260,7 @@ TABS.osd = {};
|
|||
TABS.osd.initialize = function (callback) {
|
||||
|
||||
mspHelper.loadServoMixRules();
|
||||
mspHelper.loadLogicConditions();
|
||||
|
||||
if (GUI.active_tab != 'osd') {
|
||||
GUI.active_tab = 'osd';
|
||||
|
@ -3344,12 +3315,6 @@ TABS.osd.initialize = function (callback) {
|
|||
}
|
||||
|
||||
// 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
|
||||
|
@ -3633,8 +3598,7 @@ function customElementNormaliseRow(row){
|
|||
}
|
||||
}
|
||||
|
||||
function customElementDisableNonValidOptionsRow(row){
|
||||
|
||||
function customElementDisableNonValidOptionsRow(row) {
|
||||
var selectedTextIndex = false;
|
||||
for(let i = 0; i < 3; i++){
|
||||
let elementType = $('.osdCustomElement-' + row + '-part-' + i + '-type');
|
||||
|
@ -3657,13 +3621,12 @@ function customElementDisableNonValidOptionsRow(row){
|
|||
}
|
||||
|
||||
function customElementGetDataForRow(row){
|
||||
|
||||
var data = [];
|
||||
data.push8(row);
|
||||
|
||||
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 valueCell = $('.' + elementType.data('valueCellClass'));
|
||||
var partValue = 0;
|
||||
|
@ -3705,7 +3668,9 @@ function customElementGetDataForRow(row){
|
|||
data.push8(parseInt(elementVisibilityType.val()));
|
||||
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){
|
||||
data.push8(text.charCodeAt(i))
|
||||
}else{
|
||||
|
@ -3718,42 +3683,20 @@ function customElementGetDataForRow(row){
|
|||
|
||||
function getGVoptions(){
|
||||
var result = '';
|
||||
for(var i = 0; i < 8; i++){
|
||||
result += `<option value="` + i + `">GV `+i+`</option>`;
|
||||
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() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
for(var i = 0; i < FC.LOGIC_CONDITIONS.getMaxLogicConditionCount(); i++) {
|
||||
if (FC.LOGIC_CONDITIONS.isEnabled(i)) {
|
||||
result += `<option value="` + i + `">LC ` + i + `</option>`;
|
||||
}
|
||||
}
|
||||
|
||||
OSD.GUI.updatePreviews();
|
||||
return result;
|
||||
}
|
||||
|
||||
function updatePilotAndCraftNames() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue