Skip to content

Commit

Permalink
Add gps state and ublox version
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Sep 8, 2024
1 parent a23f3cf commit dc1b5f5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2843,6 +2843,9 @@
"gpsPositionalDop": {
"message": "Positional DOP:"
},
"gpsStatus": {
"message": "Status:"
},
"gpsSignalStrHead": {
"message": "GPS Signal Strength"
},
Expand Down
6 changes: 6 additions & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
FC.GPS_DATA.positionalDop = data.readU16();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
FC.GPS_DATA.status = data.readU8();
}
break;
case MSPCodes.MSP_COMP_GPS:
FC.GPS_DATA.distanceToHome = data.readU16();
Expand Down Expand Up @@ -510,6 +513,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
// Introduced in API version 1.43
FC.GPS_CONFIG.home_point_once = data.readU8();
FC.GPS_CONFIG.ublox_use_galileo = data.readU8();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
FC.GPS_CONFIG.ublox_version = data.readU8();
}
break;
case MSPCodes.MSP_GPS_RESCUE:
FC.GPS_RESCUE.angle = data.readU16();
Expand Down
30 changes: 29 additions & 1 deletion 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_46 } from '../data_storage';
import { API_VERSION_1_46, API_VERSION_1_47 } from '../data_storage';
import GUI, { TABS } from '../gui';
import FC from '../fc';
import MSP from "../msp";
Expand Down Expand Up @@ -114,6 +114,28 @@ gps.initialize = async function (callback) {
'9600',
];

const GPS_STATE = [
"UNKNOWN",
"DETECT_BAUD",
"INITIALIZED",
"CHANGE_BAUD",
"CONFIGURE",
"RECEIVING_DATA",
"PROCESS_DATA",
"LOST_COMMUNICATION",
"COUNT",
];

const UBX_VERSION = [
"UNKNOWN",
"M5",
"M6",
"M7",
"M8",
"M9",
"M10",
];

const gpsSbas = [
i18n.getMessage('gpsSbasAutoDetect'),
i18n.getMessage('gpsSbasEuropeanEGNOS'),
Expand Down Expand Up @@ -169,6 +191,8 @@ gps.initialize = async function (callback) {
gpsAutoBaudGroup.toggle((ubloxSelected || mspSelected) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_46));
gpsAutoConfigGroup.toggle(ubloxSelected || mspSelected);

$('#ublox_version').text(ubloxSelected ? UBX_VERSION[FC.GPS_CONFIG.ublox_version] : '');

}).prop('checked', FC.GPS_CONFIG.auto_config === 1).trigger('change');

gpsUbloxGalileoElement.change(function() {
Expand Down Expand Up @@ -348,6 +372,10 @@ gps.initialize = async function (callback) {
$('.GPS_info td.positionalDop').text(`${positionalDop.toFixed(2)}`);
}

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
$('.GPS_info td.status').text(GPS_STATE[FC.GPS_DATA.status]);
}

updateSignalStrengths();

let gpsFoundPosition = false;
Expand Down
5 changes: 5 additions & 0 deletions src/tabs/gps.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<!-- list generated here -->
</select>
<span i18n="configurationGPSProtocol"></span>
<div id="ublox_version"></div>
</div>
<div class="select line">
<select class="gps_baudrate">
Expand Down Expand Up @@ -122,6 +123,10 @@
<td i18n="gpsPositionalDop"></td>
<td class="positionalDop"></td>
</tr>
<tr>
<td i18n="gpsStatus"></td>
<td class="status"></td>
</tr>
</table>
</div>
</div>
Expand Down

0 comments on commit dc1b5f5

Please sign in to comment.