Skip to content

Commit

Permalink
OSD custom elements
Browse files Browse the repository at this point in the history
  • Loading branch information
error414 committed Dec 21, 2023
1 parent be88b5a commit fd17c4a
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 6 deletions.
6 changes: 6 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3449,6 +3449,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."
},
Expand Down
9 changes: 8 additions & 1 deletion js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ var CONFIG,
BOARD_ALIGNMENT,
CURRENT_METER_CONFIG,
FEATURES,
RATE_DYNAMICS;
RATE_DYNAMICS,
OSD_CUSTOM_ELEMENTS
;

var FC = {
restartRequired: false,
Expand Down Expand Up @@ -564,6 +566,11 @@ var FC = {
rate: null,
expo: null
};

OSD_CUSTOM_ELEMENTS = {
settings: {customElementsCount: 0, customElementTextSize: 0},
items: [],
};
},
getOutputUsages: function() {
return {
Expand Down
5 changes: 4 additions & 1 deletion js/msp/MSPCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
49 changes: 49 additions & 0 deletions js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,9 @@ var mspHelper = (function (gui) {
case MSPCodes.MSP2_INAV_OSD_SET_PREFERENCES:
console.log('OSD preferences saved');
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)
Expand Down Expand Up @@ -1589,6 +1592,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 {
Expand Down Expand Up @@ -2533,6 +2578,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;

Expand Down
18 changes: 17 additions & 1 deletion tabs/osd.html
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,17 @@ <h1 class="tab_title" data-i18n="tabOSD"></h1>
</label>
</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 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>
Expand Down Expand Up @@ -425,6 +435,12 @@ <h1 class="tab_title">Font:</h1>
<a class="flash_font active" data-i18n="osd_font_upload"></a>
</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>
</div>
Expand Down
Loading

0 comments on commit fd17c4a

Please sign in to comment.