mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-26 01:35:28 +03:00
Added version gating (apiVersion >= 1.21) for altitude in OSD.
This commit is contained in:
parent
43284b6fe7
commit
170aa39e70
1 changed files with 19 additions and 10 deletions
29
tabs/osd.js
29
tabs/osd.js
|
@ -188,7 +188,7 @@ FONT.preview = function($el) {
|
||||||
$el.empty()
|
$el.empty()
|
||||||
for (var i = 0; i < SYM.LOGO; i++) {
|
for (var i = 0; i < SYM.LOGO; 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)+'"/>');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -339,7 +339,12 @@ OSD.updateDisplaySize = function() {
|
||||||
|
|
||||||
OSD.msp = {
|
OSD.msp = {
|
||||||
encodeOther: function() {
|
encodeOther: function() {
|
||||||
return [-1, OSD.data.video_system, OSD.data.unit_mode];
|
var result = [-1, OSD.data.video_system];
|
||||||
|
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
|
||||||
|
result.push(OSD.data.unit_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
encode: function(display_item) {
|
encode: function(display_item) {
|
||||||
return [
|
return [
|
||||||
|
@ -352,12 +357,16 @@ OSD.msp = {
|
||||||
decode: function(payload) {
|
decode: function(payload) {
|
||||||
var view = payload.data;
|
var view = payload.data;
|
||||||
var d = OSD.data;
|
var d = OSD.data;
|
||||||
|
var i = 2;
|
||||||
d.compiled_in = view.getUint8(0, 1);
|
d.compiled_in = view.getUint8(0, 1);
|
||||||
d.video_system = view.getUint8(1, 1);
|
d.video_system = view.getUint8(1, 1);
|
||||||
d.unit_mode = view.getUint8(2, 1);
|
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
|
||||||
|
d.unit_mode = view.getUint8(2, 1);
|
||||||
|
i = 3;
|
||||||
|
}
|
||||||
d.display_items = [];
|
d.display_items = [];
|
||||||
// start at the offset from the other fields
|
// start at the offset from the other fields
|
||||||
for (var i = 3; i < view.byteLength; i = i + 2) {
|
for (; i < view.byteLength; i = i + 2) {
|
||||||
var v = view.getInt16(i, 1)
|
var v = view.getInt16(i, 1)
|
||||||
var j = d.display_items.length;
|
var j = d.display_items.length;
|
||||||
var c = OSD.constants.DISPLAY_FIELDS[j];
|
var c = OSD.constants.DISPLAY_FIELDS[j];
|
||||||
|
@ -451,7 +460,7 @@ TABS.osd.initialize = function (callback) {
|
||||||
// show Betaflight logo in preview
|
// show Betaflight logo in preview
|
||||||
var $previewLogo = $('.preview-logo').empty();
|
var $previewLogo = $('.preview-logo').empty();
|
||||||
$previewLogo.append(
|
$previewLogo.append(
|
||||||
$('<input type="checkbox" name="preview-logo" class="togglesmall"></input>')
|
$('<input type="checkbox" name="preview-logo" class="togglesmall"/>')
|
||||||
.attr('checked', OSD.data.preview_logo)
|
.attr('checked', OSD.data.preview_logo)
|
||||||
.change(function(e) {
|
.change(function(e) {
|
||||||
OSD.data.preview_logo = $(this).attr('checked') == undefined;
|
OSD.data.preview_logo = $(this).attr('checked') == undefined;
|
||||||
|
@ -499,11 +508,11 @@ TABS.osd.initialize = function (callback) {
|
||||||
|
|
||||||
// display fields on/off and position
|
// display fields on/off and position
|
||||||
var $displayFields = $('.display-fields').empty();
|
var $displayFields = $('.display-fields').empty();
|
||||||
for (let field of OSD.data.display_items) {
|
for (var field in OSD.data.display_items) {
|
||||||
var checked = (-1 != field.position) ? 'checked' : '';
|
var checked = (-1 != field.position) ? 'checked' : '';
|
||||||
var $field = $('<div class="display-field"/>');
|
var $field = $('<div class="display-field"/>');
|
||||||
$field.append(
|
$field.append(
|
||||||
$('<input type="checkbox" name="'+field.name+'" class="togglesmall"></input>')
|
$('<input type="checkbox" name="'+field.name+'" class="togglesmall"/>')
|
||||||
.data('field', field)
|
.data('field', field)
|
||||||
.attr('checked', field.position != -1)
|
.attr('checked', field.position != -1)
|
||||||
.change(function(e) {
|
.change(function(e) {
|
||||||
|
@ -527,7 +536,7 @@ TABS.osd.initialize = function (callback) {
|
||||||
$field.append('<label for="'+field.name+'">'+inflection.titleize(field.name)+'</label>');
|
$field.append('<label for="'+field.name+'">'+inflection.titleize(field.name)+'</label>');
|
||||||
if (field.positionable && field.position != -1) {
|
if (field.positionable && field.position != -1) {
|
||||||
$field.append(
|
$field.append(
|
||||||
$('<input type="number" class="'+field.index+' position"></input>')
|
$('<input type="number" class="'+field.index+' position"/>')
|
||||||
.data('field', field)
|
.data('field', field)
|
||||||
.val(field.position)
|
.val(field.position)
|
||||||
.change($.debounce(250, function(e) {
|
.change($.debounce(250, function(e) {
|
||||||
|
@ -560,7 +569,7 @@ TABS.osd.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// draw all the displayed items and the drag and drop preview images
|
// draw all the displayed items and the drag and drop preview images
|
||||||
for(let field of OSD.data.display_items) {
|
for(var field in OSD.data.display_items) {
|
||||||
if (!field.preview || field.position == -1) { continue; }
|
if (!field.preview || field.position == -1) { continue; }
|
||||||
var j = (field.position >= 0) ? field.position : field.position + OSD.data.display_size.total;
|
var j = (field.position >= 0) ? field.position : field.position + OSD.data.display_size.total;
|
||||||
// create the preview image
|
// create the preview image
|
||||||
|
@ -609,7 +618,7 @@ TABS.osd.initialize = function (callback) {
|
||||||
var field = OSD.data.preview[i][0];
|
var field = OSD.data.preview[i][0];
|
||||||
var charCode = OSD.data.preview[i][1];
|
var charCode = OSD.data.preview[i][1];
|
||||||
}
|
}
|
||||||
var $img = $('<div class="char"><img src='+FONT.draw(charCode)+'></img></div>')
|
var $img = $('<div class="char"><img src='+FONT.draw(charCode)+'/></div>')
|
||||||
.on('dragover', OSD.GUI.preview.onDragOver)
|
.on('dragover', OSD.GUI.preview.onDragOver)
|
||||||
.on('dragleave', OSD.GUI.preview.onDragLeave)
|
.on('dragleave', OSD.GUI.preview.onDragLeave)
|
||||||
.on('drop', OSD.GUI.preview.onDrop)
|
.on('drop', OSD.GUI.preview.onDrop)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue