Added OSD preview elements for stick overlays.
parent
5ce8b0948b
commit
5f984ad382
|
@ -3663,6 +3663,12 @@
|
|||
"osdDescElementFlightDist": {
|
||||
"message": "Distance flown during this flight."
|
||||
},
|
||||
"osdDescElementStickOverlayLeft": {
|
||||
"message": "Overlay for the left transmitter stick position."
|
||||
},
|
||||
"osdDescElementStickOverlayRight": {
|
||||
"message": "Overlay for the right transmitter stick position."
|
||||
},
|
||||
"osdDescElementTimer1" : {
|
||||
"message": "Shows the value of timer 1"
|
||||
},
|
||||
|
|
|
@ -38,6 +38,18 @@ SYM.HEADING_S = 0x19;
|
|||
SYM.HEADING_E = 0x1A;
|
||||
SYM.HEADING_W = 0x1B;
|
||||
SYM.TEMP_C = 0x0E;
|
||||
SYM.STICK_OVERLAY_SPRITE_HIGH = 0x08;
|
||||
SYM.STICK_OVERLAY_SPRITE_MID = 0x09;
|
||||
SYM.STICK_OVERLAY_SPRITE_LOW = 0x0A;
|
||||
SYM.STICK_OVERLAY_CENTER = 0x0B;
|
||||
SYM.STICK_OVERLAY_VERTICAL = 0x16;
|
||||
SYM.STICK_OVERLAY_HORIZONTAL = 0x17;
|
||||
|
||||
var STICK_OVERLAY_SPRITE = [
|
||||
SYM.STICK_OVERLAY_SPRITE_HIGH,
|
||||
SYM.STICK_OVERLAY_SPRITE_MID,
|
||||
SYM.STICK_OVERLAY_SPRITE_LOW
|
||||
];
|
||||
|
||||
var FONT = FONT || {};
|
||||
|
||||
|
@ -276,11 +288,53 @@ OSD.generateTemperaturePreview = function (osd_data, temperature) {
|
|||
|
||||
OSD.generateCraftName = function (osd_data) {
|
||||
var preview = 'CRAFT_NAME';
|
||||
if (CONFIG.name != '')
|
||||
if (CONFIG.name != '') {
|
||||
preview = CONFIG.name.toUpperCase();
|
||||
}
|
||||
return preview;
|
||||
}
|
||||
|
||||
OSD.drawStickOverlayPreview = function () {
|
||||
function randomInt(count) {
|
||||
return Math.floor(Math.random() * Math.floor(count));
|
||||
}
|
||||
|
||||
var OVERLAY_WIDTH = 7;
|
||||
var OVERLAY_HEIGHT = 5;
|
||||
|
||||
var stickX = randomInt(OVERLAY_WIDTH);
|
||||
var stickY = randomInt(OVERLAY_HEIGHT);
|
||||
var stickSymbol = randomInt(3);
|
||||
|
||||
// From 'osdDrawStickOverlayAxis' in 'src/main/io/osd.c'
|
||||
var stickOverlay = new Array();
|
||||
for (var x = 0; x < OVERLAY_WIDTH; x++) {
|
||||
for (var y = 0; y < OVERLAY_HEIGHT; y++) {
|
||||
var symbol = undefined;
|
||||
|
||||
if (x === stickX && y === stickY) {
|
||||
symbol = STICK_OVERLAY_SPRITE[stickSymbol];
|
||||
} else if (x === (OVERLAY_WIDTH - 1) / 2 && y === (OVERLAY_HEIGHT - 1) / 2) {
|
||||
symbol = SYM.STICK_OVERLAY_CENTER;
|
||||
} else if (x === (OVERLAY_WIDTH - 1) / 2) {
|
||||
symbol = SYM.STICK_OVERLAY_VERTICAL;
|
||||
} else if (y === (OVERLAY_HEIGHT - 1) / 2) {
|
||||
symbol = SYM.STICK_OVERLAY_HORIZONTAL;
|
||||
}
|
||||
|
||||
if (symbol) {
|
||||
var element = {
|
||||
x: x,
|
||||
y: y,
|
||||
sym: symbol
|
||||
};
|
||||
stickOverlay.push(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stickOverlay;
|
||||
}
|
||||
|
||||
OSD.constants = {
|
||||
VISIBLE: 0x0800,
|
||||
VIDEO_TYPES: [
|
||||
|
@ -409,7 +463,6 @@ OSD.constants = {
|
|||
return semver.gte(CONFIG.apiVersion, "1.39.0") ? true : false;
|
||||
},
|
||||
preview: function () {
|
||||
|
||||
var artificialHorizon = new Array();
|
||||
|
||||
for (var j = 1; j < 8; j++) {
|
||||
|
@ -495,9 +548,7 @@ OSD.constants = {
|
|||
default_position: -77,
|
||||
draw_order: 150,
|
||||
positionable: true,
|
||||
preview: function (osd_data) {
|
||||
return OSD.generateCraftName(osd_data, 1);
|
||||
}
|
||||
preview: OSD.generateCraftName
|
||||
},
|
||||
ALTITUDE: {
|
||||
name: 'ALTITUDE',
|
||||
|
@ -846,6 +897,22 @@ OSD.constants = {
|
|||
return '653' + FONT.symbol(osd_data.unit_mode === 0 ? SYM.FEET : SYM.METRE);
|
||||
}
|
||||
},
|
||||
STICK_OVERLAY_LEFT: {
|
||||
name: 'STICK_OVERLAY_LEFT',
|
||||
desc: 'osdDescElementStickOverlayLeft',
|
||||
default_position: -1,
|
||||
draw_order: 370,
|
||||
positionable: true,
|
||||
preview: OSD.drawStickOverlayPreview
|
||||
},
|
||||
STICK_OVERLAY_RIGHT: {
|
||||
name: 'STICK_OVERLAY_RIGHT',
|
||||
desc: 'osdDescElementStickOverlayRight',
|
||||
default_position: -1,
|
||||
draw_order: 370,
|
||||
positionable: true,
|
||||
preview: OSD.drawStickOverlayPreview
|
||||
},
|
||||
},
|
||||
UNKNOWN_DISPLAY_FIELD: {
|
||||
name: 'UNKNOWN_',
|
||||
|
@ -1119,6 +1186,8 @@ OSD.chooseFields = function () {
|
|||
F.FLIP_ARROW,
|
||||
F.LINK_QUALITY,
|
||||
F.FLIGHT_DIST,
|
||||
F.STICK_OVERLAY_LEFT,
|
||||
F.STICK_OVERLAY_RIGHT,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue