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

GPS tab: New design for gps Status / Quality #3566

Merged
merged 10 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
4 changes: 2 additions & 2 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2812,7 +2812,7 @@
"message": "Sat ID"
},
"gpsSignalStatusQly": {
"message": "Status / Quality"
"message": "Status     |  Quality"
HThuren marked this conversation as resolved.
Show resolved Hide resolved
},
"gnssQualityNoSignal": {
"message": "no signal"
Expand All @@ -2836,7 +2836,7 @@
"message": "unused"
},
"gnssUsedUsed": {
"message": "used"
"message": "USED "
},
"gnssHealthyUnknown": {
"message": "unknown"
Expand Down
13 changes: 11 additions & 2 deletions src/css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -1725,13 +1725,22 @@ dialog {
}
}
.colorToggle {
background-color: #e60000;
background-color: #ff0000;
padding: 2px 5px;
border-radius: 3px;
color: #fff;
font-size: 10px;
&.low {
background-color: #808080;
}
&.notReady {
background-color: #ffcc3f;
}
&.locked {
background-color: #ff9500;
}
&.ready {
background-color: #56ac1d;
background-color: #008000;
}
}
.buildInfoBtn {
Expand Down
58 changes: 32 additions & 26 deletions src/js/tabs/gps.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
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";
import MSPCodes from "../msp/MSPCodes";
import $ from 'jquery';
import { have_sensor } from "../sensor_helpers";
import { mspHelper } from '../msp/MSPHelper';
import { updateTabList } from '../utils/updateTabList';
Expand Down Expand Up @@ -132,7 +133,10 @@ gps.initialize = async function (callback) {

}).val(FC.GPS_CONFIG.provider).change();

gpsAutoBaudElement.prop('checked', FC.GPS_CONFIG.auto_baud === 1);
// auto_baud is no longer used in API 1.46
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
gpsAutoBaudElement.prop('checked', FC.GPS_CONFIG.auto_baud === 1);
}

gpsAutoConfigElement.on('change', function () {
const checked = $(this).is(":checked");
Expand All @@ -146,7 +150,7 @@ gps.initialize = async function (callback) {
const enableSbasVisible = checked && ubloxSelected;
gpsUbloxSbasGroup.toggle(enableSbasVisible);

gpsAutoBaudGroup.toggle(ubloxSelected || mspSelected);
gpsAutoBaudGroup.toggle((ubloxSelected || mspSelected) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_46));
gpsAutoConfigGroup.toggle(ubloxSelected || mspSelected);

}).prop('checked', FC.GPS_CONFIG.auto_config === 1).trigger('change');
Expand Down Expand Up @@ -181,22 +185,22 @@ gps.initialize = async function (callback) {
const lat = FC.GPS_DATA.lat / 10000000;
const lon = FC.GPS_DATA.lon / 10000000;
const url = `https://maps.google.com/?q=${lat},${lon}`;
const heading = hasMag ? Math.atan2(FC.SENSOR_DATA.magnetometer[1], FC.SENSOR_DATA.magnetometer[0]) : undefined;
const headingDeg = heading === undefined ? 0 : heading * 180 / Math.PI;
const magHeading = hasMag ? Math.atan2(FC.SENSOR_DATA.magnetometer[1], FC.SENSOR_DATA.magnetometer[0]) : undefined;
const magHeadingDeg = magHeading === undefined ? 0 : magHeading * 180 / Math.PI;
const gpsHeading = FC.GPS_DATA.ground_course / 100;
const gnssArray = ['GPS', 'SBAS', 'Galileo', 'BeiDou', 'IMES', 'QZSS', 'Glonass'];
const qualityArray = ['gnssQualityNoSignal', 'gnssQualitySearching', 'gnssQualityAcquired', 'gnssQualityUnusable', 'gnssQualityLocked',
'gnssQualityFullyLocked', 'gnssQualityFullyLocked', 'gnssQualityFullyLocked'];
const usedArray = ['gnssUsedUnused', 'gnssUsedUsed'];
const healthyArray = ['gnssHealthyUnknown', 'gnssHealthyHealthy', 'gnssHealthyUnhealthy', 'gnssHealthyUnknown'];
let alt = FC.GPS_DATA.alt;

$('.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.latLon a').prop('href', url).text(`${lat.toFixed(4)} deg / ${lon.toFixed(4)} deg`);
$('.GPS_info td.heading').text(`${headingDeg.toFixed(4)} ${gspUnitText}`);
$('.GPS_info td.latLon a').prop('href', url).text(`${lat.toFixed(6)} / ${lon.toFixed(6)} ${gspUnitText}`);
$('.GPS_info td.heading').text(`${magHeadingDeg.toFixed(4)} / ${gpsHeading.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`);
Expand All @@ -221,7 +225,7 @@ gps.initialize = async function (callback) {
<tr>
<td>-</td>
<td>${FC.GPS_DATA.svid[i]}</td>
<td><progress value="${FC.GPS_DATA.cno[i]}" max="99"></progress></td>
<td><meter value="${FC.GPS_DATA.cno[i]}" max="55"></meter></td>
<td>${FC.GPS_DATA.quality[i]}</td>
</tr>
`);
Expand All @@ -232,7 +236,7 @@ gps.initialize = async function (callback) {
<tr>
<td>-</td>
<td>-</td>
<td><progress value="0" max="99"></progress></td>
<td><meter value="0" max="55"></meter></td>
<td> </td>
</tr>
`);
Expand All @@ -253,36 +257,38 @@ gps.initialize = async function (callback) {

if (FC.GPS_DATA.chn[i] >= 7) {
rowContent += '<td>-</td>';
rowContent += `<td><progress value="${0}" max="99"></progress></td>`;
rowContent += `<td><meter value="${0}" max="55"></meter></td>`;
rowContent += `<td> </td>`;
} else {
rowContent += `<td>${FC.GPS_DATA.svid[i]}</td>`;
rowContent += `<td><progress value="${FC.GPS_DATA.cno[i]}" max="99"></progress></td>`;
rowContent += `<td><meter value="${FC.GPS_DATA.cno[i]}" max="55"></meter></td>`;

let quality = i18n.getMessage(qualityArray[FC.GPS_DATA.quality[i] & 0x7]);
let used = i18n.getMessage(usedArray[(FC.GPS_DATA.quality[i] & 0x8) >> 3]);
let healthy = i18n.getMessage(healthyArray[(FC.GPS_DATA.quality[i] & 0x30) >> 4]);
let usedColor = '';

// Add color to the text
if (quality.startsWith('fully locked')) {
// 2nd column: no signal = red, unusable = red, searching = red, locked = yellow and fully locked = green
if (quality.startsWith(i18n.getMessage('gnssQualityFullyLocked'))) {
usedColor = 'locked';
quality = `<span class="colorToggle ready">${quality}</span>`;
} else {
quality = `<span class="colorToggle">${quality}</span>`;
}

if (used.startsWith('used')) {
used = `<span class="colorToggle ready">${used}</span>`;
} else {
used = `<span class="colorToggle">${used}</span>`;
if (quality.startsWith(i18n.getMessage('gnssQualityLocked'))) {
HThuren marked this conversation as resolved.
Show resolved Hide resolved
usedColor = 'notReady';
quality = `<span class="colorToggle locked">${quality}</span>`;
} else {
quality = `<span class="colorToggle">${quality}</span>`;
}
}

if (healthy.startsWith('healthy')) {
healthy = `<span class="colorToggle ready">${healthy}</span>`;
// 1st column: unused = red, used = green
if (used.startsWith(i18n.getMessage('gnssUsedUsed'))) {
used = `<span class="colorToggle ready">&nbsp${used}&nbsp</span>`;
} else {
healthy = `<span class="colorToggle">${healthy}</span>`;
used = `<span class="colorToggle ${usedColor}">${used}</span>`;
}

rowContent += `<td>${quality} | ${used} | ${healthy}</td>`;
rowContent += `<td>${used} | ${quality}</td>`;
}
eSsTable.append(`<tr>${rowContent}</tr>`);
}
Expand All @@ -292,7 +298,7 @@ gps.initialize = async function (callback) {
action: 'center',
lat: lat,
lon: lon,
heading: heading,
heading: magHeading,
};

frame = document.getElementById('map');
Expand Down
2 changes: 1 addition & 1 deletion src/js/tabs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ setup.initialize = function (callback) {
const lon = FC.GPS_DATA.lon / 10000000;
const url = `https://maps.google.com/?q=${lat},${lon}`;
const gpsUnitText = i18n.getMessage('gpsPositionUnit');
$('.GPS_info td.latLon a').prop('href', url).text(`${lat.toFixed(4)} ${gpsUnitText} / ${lon.toFixed(4)} ${gpsUnitText}`);
$('.GPS_info td.latLon a').prop('href', url).text(`${lat.toFixed(4)} / ${lon.toFixed(4)} ${gpsUnitText}`);
}

function get_fast_data() {
Expand Down