Skip to content

Commit

Permalink
Add altitude variant (#4052)
Browse files Browse the repository at this point in the history
* Add altitude variant

* Only add variants if sensor enabled
  • Loading branch information
haslinghuis authored Jun 26, 2024
1 parent 3abe626 commit 9532bda
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
17 changes: 13 additions & 4 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5498,14 +5498,23 @@
"osdDescElementAltitude": {
"message": "Current altitude (flashes when above alarm threshold)"
},
"osdTextElementAltitudeVariant1Decimal": {
"message": "With 1 decimal",
"osdTextElementAltitudeVariant1DecimalAGL": {
"message": "AGL with 1 decimal",
"description": "One of the variants of the altitude element of the OSD"
},
"osdTextElementAltitudeVariantNoDecimal": {
"message": "Without decimals",
"osdTextElementAltitudeVariantNoDecimalAGL": {
"message": "AGL without decimals",
"description": "One of the variants of the altitude element of the OSD"
},
"osdTextElementAltitudeVariant1DecimalASL": {
"message": "ASL with 1 decimal",
"description": "One of the variants of the altitude element of the OSD"
},
"osdTextElementAltitudeVariantNoDecimalASL": {
"message": "ASL without decimals",
"description": "One of the variants of the altitude element of the OSD"
},

"osdTextElementOnTime": {
"message": "On time",
"description": "One of the elements of the OSD"
Expand Down
10 changes: 8 additions & 2 deletions src/js/tabs/osd.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import inflection from "inflection";
import debounce from "lodash.debounce";
import $ from 'jquery';
import FileSystem from "../FileSystem";
import { have_sensor } from "../sensor_helpers";

const FONT = {};
const SYM = {};
Expand Down Expand Up @@ -779,8 +780,8 @@ OSD.loadDisplayFields = function() {
draw_order: 160,
positionable: true,
variants: [
'osdTextElementAltitudeVariant1Decimal',
'osdTextElementAltitudeVariantNoDecimal',
'osdTextElementAltitudeVariant1DecimalAGL',
'osdTextElementAltitudeVariantNoDecimalAGL',
],
preview(osdData) {
return OSD.generateAltitudePreview(osdData);
Expand Down Expand Up @@ -1513,6 +1514,11 @@ OSD.loadDisplayFields = function() {
preview: '1:23.456',
},
};

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47) && have_sensor(FC.CONFIG.activeSensors, 'gps')) {
OSD.ALL_DISPLAY_FIELDS.ALTITUDE.variants.push('osdTextElementAltitudeVariant1DecimalASL');
OSD.ALL_DISPLAY_FIELDS.ALTITUDE.variants.push('osdTextElementAltitudeVariantNoDecimalASL');
}
};

OSD.constants = {
Expand Down

0 comments on commit 9532bda

Please sign in to comment.