From c9c9b1846d44a4ef0c0b827726c839eca3b97684 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 18 Jun 2023 21:40:45 +0200 Subject: [PATCH 1/2] Show GPS home position found in FC --- locales/en/messages.json | 12 +++++++----- src/js/fc.js | 2 ++ src/js/msp/MSPHelper.js | 4 ++++ src/js/tabs/gps.js | 14 +++++++++++--- src/tabs/gps.html | 14 +++++++------- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 1697431ad1..6fee0fd68b 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2710,11 +2710,9 @@ "gpsAltitude": { "message": "Altitude:" }, - "gpsLat": { - "message": "Latitude:" - }, - "gpsLon": { - "message": "Longitude:" + "gpsLatLon": { + "message": "Latitude / Longitude:", + "description": "Show GPS position - Latitude / Longitude" }, "gpsHeading": { "message": "Heading:" @@ -2728,6 +2726,10 @@ "gpsDistToHome": { "message": "Dist to Home:" }, + "gpsHomeLatLon": { + "message": "Home Latitude / Longitude:", + "description": "Show FC stored home position - Latitude / Longitude" + }, "gpsSignalStrHead": { "message": "GPS Signal Strength" }, diff --git a/src/js/fc.js b/src/js/fc.js index 28e05bb61c..16953997ec 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -306,6 +306,8 @@ const FC = { distanceToHome: 0, directionToHome: 0, update: 0, + home_lat: 0, + home_lon: 0, chn: [], svid: [], diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 80286a229d..a9ce6a2b6d 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -302,6 +302,10 @@ MspHelper.prototype.process_data = function(dataHandler) { FC.GPS_DATA.distanceToHome = data.readU16(); FC.GPS_DATA.directionToHome = data.readU16(); FC.GPS_DATA.update = data.readU8(); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + FC.GPS_DATA.home_lat = data.read32(); + FC.GPS_DATA.home_lon = data.read32(); + } break; case MSPCodes.MSP_ATTITUDE: FC.SENSOR_DATA.kinematics[0] = data.read16() / 10.0; // x diff --git a/src/js/tabs/gps.js b/src/js/tabs/gps.js index dcf422009d..804cc4e617 100644 --- a/src/js/tabs/gps.js +++ b/src/js/tabs/gps.js @@ -1,6 +1,6 @@ import { i18n } from "../localization"; import semver from 'semver'; -import { API_VERSION_1_43 } from '../data_storage'; +import { API_VERSION_1_43, API_VERSION_1_46 } from '../data_storage'; import GUI, { TABS } from '../gui'; import FC from '../fc'; import MSP from "../msp"; @@ -189,17 +189,25 @@ gps.initialize = async function (callback) { const usedArray = ['gnssUsedUnused', 'gnssUsedUsed']; const healthyArray = ['gnssHealthyUnknown', 'gnssHealthyHealthy', 'gnssHealthyUnhealthy', 'gnssHealthyUnknown']; let alt = FC.GPS_DATA.alt; + let homeLat = 0; + let homeLon = 0; $('.GPS_info span.colorToggle').text(FC.GPS_DATA.fix ? i18n.getMessage('gpsFixTrue') : i18n.getMessage('gpsFixFalse')); $('.GPS_info span.colorToggle').toggleClass('ready', FC.GPS_DATA.fix != 0); $('.GPS_info td.alt').text(`${alt} m`); - $('.GPS_info td.lat a').prop('href', url).text(`${lat.toFixed(4)} deg`); - $('.GPS_info td.lon a').prop('href', url).text(`${lon.toFixed(4)} deg`); + $('.GPS_info td.latLon a').prop('href', url).text(`${lat.toFixed(4)} deg / ${lon.toFixed(4)} deg`); $('.GPS_info td.heading').text(`${headingDeg.toFixed(4)} deg`); $('.GPS_info td.speed').text(`${FC.GPS_DATA.speed} cm/s`); $('.GPS_info td.sats').text(FC.GPS_DATA.numSat); + $('.GPS_info td.distToHome').text(`${FC.GPS_DATA.distanceToHome} m`); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + homeLat = FC.GPS_DATA.home_lat / 10000000; + homeLon = FC.GPS_DATA.home_lon / 10000000; + } + const urlHome = `https://maps.google.com/?q=${homeLat},${homeLon}`; + $('.GPS_info td.homeLatLon a').prop('href', urlHome).text(`${homeLat.toFixed(4)} deg / ${homeLon.toFixed(4)} deg`); // Update GPS Signal Strengths const eSsTable = $('div.GPS_signal_strength table'); diff --git a/src/tabs/gps.html b/src/tabs/gps.html index d6b1730fc7..c357878585 100644 --- a/src/tabs/gps.html +++ b/src/tabs/gps.html @@ -91,12 +91,8 @@ 0 m - - 0.0000 deg - - - - 0.0000 deg + + 0.0000 deg @@ -110,10 +106,14 @@ 0 - + + + + 0.0000 deg + From 9db30d77a8cd8f1656b5447c6dfe32156d2d898c Mon Sep 17 00:00:00 2001 From: HThuren Date: Mon, 19 Jun 2023 23:09:43 +0200 Subject: [PATCH 2/2] Design change --- locales/en/messages.json | 6 +++--- src/tabs/gps.html | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 6fee0fd68b..9d00cfbb80 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2711,7 +2711,7 @@ "message": "Altitude:" }, "gpsLatLon": { - "message": "Latitude / Longitude:", + "message": "Current Latitude / Longitude:", "description": "Show GPS position - Latitude / Longitude" }, "gpsHeading": { @@ -2721,10 +2721,10 @@ "message": "Speed:" }, "gpsSats": { - "message": "Sats:" + "message": "Number of Satellites:" }, "gpsDistToHome": { - "message": "Dist to Home:" + "message": "Distance Current to Home:" }, "gpsHomeLatLon": { "message": "Home Latitude / Longitude:", diff --git a/src/tabs/gps.html b/src/tabs/gps.html index c357878585..72c370967a 100644 --- a/src/tabs/gps.html +++ b/src/tabs/gps.html @@ -86,34 +86,34 @@ + + + 0 + 0 m - - 0.0000 deg + + 0 cm/s 0.0000 deg - - 0 cm/s + + 0.0000 deg - - 0 + + 0.0000 deg - - - 0.0000 deg -