From fdb8c6b19c20491bc6b7bd21eee6819a58430812 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Tue, 27 Jun 2023 11:00:35 +0200 Subject: [PATCH] Fix OSD stat elements (#3498) --- locales/en/messages.json | 14 ++++++++++++++ src/js/tabs/osd.js | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 3f9db1aa..f4fa2aa4 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -5961,6 +5961,20 @@ "osdDescStatMinRSNR": { "message": "Minimum RSNR value" }, + "osdTextStatBest3ConsecLaps": { + "message": "Best 3 consecutive laps", + "description": "One of the statistics that can be shown at the end of the flight in the OSD" + }, + "osdDescStatBest3ConsecLaps": { + "message": "Best 3 consecutive laps" + }, + "osdTextStatBestLap": { + "message": "Best lap", + "description": "One of the statistics that can be shown at the end of the flight in the OSD" + }, + "osdDescStatBestLap": { + "message": "Best lap" + }, "osdTextStatUnknown": { "message": "Unknown $1", "description": "One of the statistics that can be shown at the end of the flight in the OSD" diff --git a/src/js/tabs/osd.js b/src/js/tabs/osd.js index 04926a3c..6bff175b 100644 --- a/src/js/tabs/osd.js +++ b/src/js/tabs/osd.js @@ -7,7 +7,7 @@ import FC from "../fc"; import MSP from "../msp"; import MSPCodes from "../msp/MSPCodes"; import PortHandler from "../port_handler"; -import CONFIGURATOR, { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_44, API_VERSION_1_45 } from "../data_storage"; +import CONFIGURATOR, { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_44, API_VERSION_1_45, API_VERSION_1_46 } from "../data_storage"; import LogoManager from "../LogoManager"; import { gui_log } from "../gui_log"; import semver from "semver"; @@ -1682,6 +1682,16 @@ OSD.constants = { text: 'osdTextStatMinRSNR', desc: 'osdDescStatMinRSNR', }, + STAT_BEST_3_CONSEC_LAPS : { + name: 'STAT_BEST_3_CONSEC_LAPS', + text: 'osdTextStatBest3ConsecLaps', + desc: 'osdDescStatBest3ConsecLaps', + }, + STAT_BEST_LAP : { + name: 'STAT_BEST_LAP', + text: 'osdTextStatBestLap', + desc: 'osdDescStatBestLap', + }, }, ALL_WARNINGS: { ARMING_DISABLED: { @@ -1979,6 +1989,13 @@ OSD.chooseFields = function() { ]); } + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + OSD.constants.STATISTIC_FIELDS = OSD.constants.STATISTIC_FIELDS.concat([ + F.STAT_BEST_3_CONSEC_LAPS, + F.STAT_BEST_LAP, + ]); + } + // Choose warnings // Nothing much to do here, I'm preempting there being new warnings F = OSD.constants.ALL_WARNINGS;