Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show GPS home position found in FC #3486

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2714,11 +2714,9 @@
"gpsAltitude": {
"message": "Altitude:"
},
"gpsLat": {
"message": "Latitude:"
},
"gpsLon": {
"message": "Longitude:"
"gpsLatLon": {
"message": "Current Latitude / Longitude:",
"description": "Show GPS position - Latitude / Longitude"
},
"gpsHeading": {
"message": "Heading:"
Expand All @@ -2727,10 +2725,14 @@
"message": "Speed:"
},
"gpsSats": {
"message": "Sats:"
"message": "Number of Satellites:"
},
"gpsDistToHome": {
"message": "Dist to Home:"
"message": "Distance Current to Home:"
},
"gpsHomeLatLon": {
"message": "Home Latitude / Longitude:",
"description": "Show FC stored home position - Latitude / Longitude"
},
"gpsSignalStrHead": {
"message": "GPS Signal Strength"
Expand Down
2 changes: 2 additions & 0 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ const FC = {
distanceToHome: 0,
directionToHome: 0,
update: 0,
home_lat: 0,
home_lon: 0,

chn: [],
svid: [],
Expand Down
4 changes: 4 additions & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions src/js/tabs/gps.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -189,18 +189,26 @@ 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);

const gspUnitText = i18n.getMessage('gpsPositionUnit');
$('.GPS_info td.alt').text(`${alt} m`);
$('.GPS_info td.lat a').prop('href', url).text(`${lat.toFixed(4)} ${gspUnitText}`);
$('.GPS_info td.lon a').prop('href', url).text(`${lon.toFixed(4)} ${gspUnitText}`);
$('.GPS_info td.latLon a').prop('href', url).text(`${lat.toFixed(4)} ${gspUnitText} / ${lon.toFixed(4)} ${gspUnitText}`);
$('.GPS_info td.heading').text(`${headingDeg.toFixed(4)} ${gspUnitText}`);
$('.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');
Expand Down
22 changes: 11 additions & 11 deletions src/tabs/gps.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,30 @@
<td><span class="colorToggle" i18n="gpsFixFalse"></span></td>
</tr>
<tr>
<td i18n="gpsAltitude"></td>
<td class="alt">0 m</td>
<td i18n="gpsSats"></td>
<td class="sats">0</td>
</tr>
<tr>
<td i18n="gpsLat"></td>
<td class="lat"><a href="#" target="_blank">0.0000 deg</a></td>
<td i18n="gpsAltitude"></td>
<td class="alt">0 m</td>
</tr>
<tr>
<td i18n="gpsLon"></td>
<td class="lon"><a href="#" target="_blank">0.0000 deg</a></td>
<td i18n="gpsSpeed"></td>
<td class="speed">0 cm/s</td>
</tr>
<tr>
<td i18n="gpsHeading"></td>
<td class="heading"><a href="#" target="_blank">0.0000 deg</a></td>
</tr>
<tr>
<td i18n="gpsSpeed"></td>
<td class="speed">0 cm/s</td>
<td i18n="gpsLatLon"></td>
<td class="latLon"><a href="#" target="_blank">0.0000 deg</a></td>
</tr>
<tr>
<td i18n="gpsSats"></td>
<td class="sats">0</td>
<td i18n="gpsHomeLatLon"></td>
<td class="homeLatLon"><a href="#" target="_blank">0.0000 deg</a></td>
</tr>
<tr class="noboarder">
<tr>
<td i18n="gpsDistToHome"></td>
<td class="distToHome"></td>
</tr>
Expand Down