diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index 8c05b768a..d72b206c0 100755
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -3452,6 +3452,12 @@
"osd_hud_settings": {
"message": "Heads up Display settings"
},
+ "osd_custom_element_settings": {
+ "message": "Custom OSD elements"
+ },
+ "custom_element": {
+ "message": "Custom element"
+ },
"osd_hud_settings_HELP": {
"message": "This section allows tweaking the behavior of HUD elements."
},
diff --git a/js/fc.js b/js/fc.js
index 447eb114a..639efe22e 100644
--- a/js/fc.js
+++ b/js/fc.js
@@ -65,7 +65,9 @@ var CONFIG,
BOARD_ALIGNMENT,
CURRENT_METER_CONFIG,
FEATURES,
- RATE_DYNAMICS;
+ RATE_DYNAMICS,
+ OSD_CUSTOM_ELEMENTS
+;
var FC = {
restartRequired: false,
@@ -564,6 +566,11 @@ var FC = {
rate: null,
expo: null
};
+
+ OSD_CUSTOM_ELEMENTS = {
+ settings: {customElementsCount: 0, customElementTextSize: 0},
+ items: [],
+ };
},
getOutputUsages: function() {
return {
diff --git a/js/msp/MSPCodes.js b/js/msp/MSPCodes.js
index fe28c2a3c..d2bef502f 100644
--- a/js/msp/MSPCodes.js
+++ b/js/msp/MSPCodes.js
@@ -245,5 +245,8 @@ var MSPCodes = {
MSP2_INAV_EZ_TUNE: 0x2070,
MSP2_INAV_EZ_TUNE_SET: 0x2071,
- MSP2_INAV_SELECT_MIXER_PROFILE: 0x2080
+ MSP2_INAV_SELECT_MIXER_PROFILE: 0x2080,
+
+ MSP2_INAV_CUSTOM_OSD_ELEMENTS: 0x2090,
+ MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS: 0x2091,
};
diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js
index fc88f6042..738fd9dc9 100644
--- a/js/msp/MSPHelper.js
+++ b/js/msp/MSPHelper.js
@@ -90,7 +90,7 @@ var mspHelper = (function (gui) {
CONFIG.armingFlags = data.getUint32(offset, true);
offset += 4;
-
+
//As there are 8 bytes for mspBoxModeFlags (number of bytes is actually variable)
//read mixer profile as the last byte in the the message
profile_byte = data.getUint8(dataHandler.message_length_expected - 1);
@@ -1500,6 +1500,9 @@ var mspHelper = (function (gui) {
case MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE:
console.log('Battery profile selected');
break;
+ case MSPCodes.MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS:
+ console.log('OSD custom elements preferences saved');
+ break;
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING:
OUTPUT_MAPPING.flush();
for (i = 0; i < data.byteLength; ++i)
@@ -1607,6 +1610,48 @@ var mspHelper = (function (gui) {
console.log('EzTune settings saved');
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:
console.log('Unknown code detected: ' + dataHandler.code);
} else {
@@ -2551,6 +2596,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) {
var nextFunction = send_next_mode_range;
@@ -2928,7 +2977,7 @@ var mspHelper = (function (gui) {
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 idIndex = 0;
@@ -2953,7 +3002,7 @@ var mspHelper = (function (gui) {
// prepare for next iteration
idIndex++;
if (idIndex == overrideIds.length) {
- nextFunction = onCompleteCallback;
+ nextFunction = callback;
}
MSP.send_message(MSPCodes.MSP2_INAV_SET_TIMER_OUTPUT_MODE, buffer, false, nextFunction);
@@ -3315,12 +3364,6 @@ var mspHelper = (function (gui) {
self.encodeSetting = function (name, value) {
return this._getSetting(name).then(function (setting) {
-
- if (!setting) {
- console.log("Setting invalid: " + name);
- return null;
- }
-
if (setting.table && !Number.isInteger(value)) {
var found = false;
for (var ii = 0; ii < setting.table.values.length; ii++) {
@@ -3368,11 +3411,7 @@ var mspHelper = (function (gui) {
self.setSetting = function (name, value, callback) {
this.encodeSetting(name, value).then(function (data) {
- if (data) {
- return MSP.promise(MSPCodes.MSPV2_SET_SETTING, data).then(callback);
- } else {
- return Promise.resolve().then(callback);
- }
+ return MSP.promise(MSPCodes.MSPV2_SET_SETTING, data).then(callback);
});
};
diff --git a/tabs/osd.html b/tabs/osd.html
index 99d215b5e..062a56ea0 100644
--- a/tabs/osd.html
+++ b/tabs/osd.html
@@ -316,7 +316,17 @@
-
+
+
+
+
+
+
@@ -425,6 +435,12 @@
Font:
+
diff --git a/tabs/osd.js b/tabs/osd.js
index 95393953d..cd1f57263 100644
--- a/tabs/osd.js
+++ b/tabs/osd.js
@@ -340,7 +340,7 @@ FONT.preview = function ($el) {
$el.empty();
for (var i = 1; i <= SYM.LAST_CHAR; i++) {
var url = FONT.data.character_image_urls[i];
- $el.append(' ');
+ $el.append(' ');
}
};
@@ -1832,7 +1832,25 @@ OSD.constants = {
id: 116,
positionable: true,
preview: 'G3:30126'
- }
+ },
+ {
+ name: 'CUSTOM ELEMENT 1',
+ id: 147,
+ min_version: '7.0.0',
+ preview: "CE_1",
+ },
+ {
+ name: 'CUSTOM ELEMENT 2',
+ id: 148,
+ min_version: '7.0.0',
+ preview: "CE_2",
+ },
+ {
+ name: 'CUSTOM ELEMENT 3',
+ id: 149,
+ min_version: '7.0.0',
+ preview: "CE_3",
+ },
]
},
{
@@ -2125,6 +2143,8 @@ OSD.reload = function(callback) {
});
});
});
+
+ MSP.send_message(MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS);
};
OSD.updateSelectedLayout = function(new_layout) {
@@ -3360,9 +3380,261 @@ TABS.osd.initialize = function (callback) {
usePitot = (SENSOR_CONFIG.pitot != 0);
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 = $('