GPS icon now reflect fix state (#3377)

* GPS icon now reflect fix state

* Code moved to sensor_helpers.js

* Code moved to sensor_helpers.js

* Minor changes
master
HThuren 2023-03-13 20:34:17 +01:00 committed by GitHub
parent 6ef0046a1d
commit 6cbbaff240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 7 deletions

View File

@ -482,7 +482,11 @@ input[type="number"] {
}
.gpsicon.active {
color: #818181;
background-image: url(../images/icons/sensor_sat_on.png);
background-image: url(../images/icons/sensor_sat_on_no_fix.png);
}
.gpsicon.active_fix {
color: #818181;
background-image: url(../images/icons/sensor_sat_on_with_fix.png);
}
.baroicon.active {
color: #818181;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -191,7 +191,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
FC.CONFIG.mode = data.readU32();
FC.CONFIG.profile = data.readU8();
sensor_status(FC.CONFIG.activeSensors);
sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);
break;
case MSPCodes.MSP_STATUS_EX:
FC.CONFIG.cycleTime = data.readU16();
@ -213,7 +213,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
FC.CONFIG.armingDisableCount = data.readU8(); // Flag count
FC.CONFIG.armingDisableFlags = data.readU32();
sensor_status(FC.CONFIG.activeSensors);
sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);
break;
case MSPCodes.MSP_RAW_IMU:

View File

@ -19,19 +19,23 @@ export function have_sensor(sensors_detected, sensor_code) {
return false;
}
export function sensor_status(sensors_detected) {
export function sensor_status(sensors_detected = 0, gps_fix_state = 0) {
// initialize variable (if it wasn't)
if (!sensor_status.previous_sensors_detected) {
sensor_status.previous_sensors_detected = -1; // Otherwise first iteration will not be run if sensors_detected == 0
}
if (!sensor_status.previous_gps_fix_state) {
sensor_status.previous_gps_fix_state = -1;
}
// update UI (if necessary)
if (sensor_status.previous_sensors_detected == sensors_detected) {
if (sensor_status.previous_sensors_detected == sensors_detected && sensor_status.previous_gps_fix_state == gps_fix_state) {
return;
}
// set current value
sensor_status.previous_sensors_detected = sensors_detected;
sensor_status.previous_gps_fix_state = gps_fix_state;
const eSensorStatus = $("div#sensor-status");
@ -72,10 +76,17 @@ export function sensor_status(sensors_detected) {
if (have_sensor(sensors_detected, "gps")) {
$(".gps", eSensorStatus).addClass("on");
if (gps_fix_state) {
$(".gpsicon", eSensorStatus).removeClass("active");
$(".gpsicon", eSensorStatus).addClass("active_fix");
} else {
$(".gpsicon", eSensorStatus).removeClass("active_fix");
$(".gpsicon", eSensorStatus).addClass("active");
}
} else {
$(".gps", eSensorStatus).removeClass("on");
$(".gpsicon", eSensorStatus).removeClass("active");
$(".gpsicon", eSensorStatus).removeClass("active_fix");
}
if (have_sensor(sensors_detected, "sonar")) {

View File

@ -217,7 +217,7 @@ function finishClose(finishedCallback) {
$('div.connect_controls div.connect_state').text(i18n.getMessage('connect'));
// reset active sensor indicators
sensor_status(0);
sensor_status();
if (wasConnected) {
// detach listeners and remove element data
@ -683,6 +683,9 @@ async function update_live_status() {
if (GUI.active_tab !== 'cli' && GUI.active_tab !== 'presets') {
await MSP.promise(MSPCodes.MSP_BOXNAMES);
await getStatus();
if (have_sensor(FC.CONFIG.activeSensors, 'gps')) {
await MSP.promise(MSPCodes.MSP_RAW_GPS);
}
await MSP.promise(MSPCodes.MSP_ANALOG);
const active = ((Date.now() - FC.ANALOG.last_received_timestamp) < 300);
@ -723,6 +726,8 @@ async function update_live_status() {
}
}
sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);
$(".linkicon").toggleClass('active', active);
statuswrapper.show();