1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Merge pull request #1091 from McGiverGim/fix_osd_preview_old_firm

Fix OSD non positionable elements
This commit is contained in:
Michael Keller 2018-07-03 22:46:11 +12:00 committed by GitHub
commit ac3a64300a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -381,7 +381,13 @@ OSD.constants = {
CROSSHAIRS: {
name: 'CROSSHAIRS',
desc: 'osdDescElementCrosshairs',
default_position: 193,
default_position: function() {
var position = 193;
if (OSD.constants.VIDEO_TYPES[OSD.data.video_system] != 'NTSC') {
position += FONT.constants.SIZES.LINE;
}
return position;
},
draw_order: 40,
positionable: function() {
return semver.gte(CONFIG.apiVersion, "1.39.0") ? true : false;
@ -391,7 +397,13 @@ OSD.constants = {
ARTIFICIAL_HORIZON: {
name: 'ARTIFICIAL_HORIZON',
desc: 'osdDescElementArtificialHorizon',
default_position: 194,
default_position: function() {
var position = 74;
if (OSD.constants.VIDEO_TYPES[OSD.data.video_system] != 'NTSC') {
position += FONT.constants.SIZES.LINE;
}
return position;
},
draw_order: 10,
positionable: function() {
return semver.gte(CONFIG.apiVersion, "1.39.0") ? true : false;
@ -422,7 +434,13 @@ OSD.constants = {
HORIZON_SIDEBARS: {
name: 'HORIZON_SIDEBARS',
desc: 'osdDescElementHorizonSidebars',
default_position: 194,
default_position: function() {
var position = 194;
if (OSD.constants.VIDEO_TYPES[OSD.data.video_system] != 'NTSC') {
position += FONT.constants.SIZES.LINE;
}
return position;
},
draw_order: 50,
positionable: function() {
return semver.gte(CONFIG.apiVersion, "1.39.0") ? true : false;
@ -1145,14 +1163,20 @@ OSD.msp = {
unpack: {
position: function(bits, c) {
var display_item = {};
var positionable = typeof(c.positionable) === 'function'? c.positionable() : c.positionable;
var default_position = typeof(c.default_position) === 'function'? c.default_position() : c.default_position;
display_item.positionable = positionable;
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
// size * y + x
display_item.position = FONT.constants.SIZES.LINE * ((bits >> 5) & 0x001F) + (bits & 0x001F);
display_item.position = positionable ? FONT.constants.SIZES.LINE * ((bits >> 5) & 0x001F) + (bits & 0x001F) : default_position;
display_item.isVisible = (bits & OSD.constants.VISIBLE) != 0;
} else {
display_item.position = (bits === -1) ? c.default_position : bits;
display_item.position = (bits === -1) ? default_position : bits;
display_item.isVisible = bits !== -1;
}
return display_item;
},
timer: function(bits, c) {
@ -1290,7 +1314,6 @@ OSD.msp = {
desc: c.desc,
index: j,
draw_order: c.draw_order,
positionable: c.positionable,
preview: suffix ? c.preview + suffix : c.preview
}, this.helpers.unpack.position(v, c)));
}
@ -1349,9 +1372,6 @@ OSD.msp = {
if (typeof(item.preview) === 'function') {
item.preview = item.preview(d);
}
if (typeof(item.positionable) === 'function') {
item.positionable = item.positionable(d);
}
}
OSD.updateDisplaySize();