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 changesmaster
parent
6ef0046a1d
commit
6cbbaff240
|
@ -482,7 +482,11 @@ input[type="number"] {
|
||||||
}
|
}
|
||||||
.gpsicon.active {
|
.gpsicon.active {
|
||||||
color: #818181;
|
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 {
|
.baroicon.active {
|
||||||
color: #818181;
|
color: #818181;
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
0
src/images/icons/sensor_sat_on.png → src/images/icons/sensor_sat_on_with_fix.png
Normal file → Executable file
0
src/images/icons/sensor_sat_on.png → src/images/icons/sensor_sat_on_with_fix.png
Normal file → Executable file
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
@ -191,7 +191,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
||||||
FC.CONFIG.mode = data.readU32();
|
FC.CONFIG.mode = data.readU32();
|
||||||
FC.CONFIG.profile = data.readU8();
|
FC.CONFIG.profile = data.readU8();
|
||||||
|
|
||||||
sensor_status(FC.CONFIG.activeSensors);
|
sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);
|
||||||
break;
|
break;
|
||||||
case MSPCodes.MSP_STATUS_EX:
|
case MSPCodes.MSP_STATUS_EX:
|
||||||
FC.CONFIG.cycleTime = data.readU16();
|
FC.CONFIG.cycleTime = data.readU16();
|
||||||
|
@ -213,7 +213,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
||||||
FC.CONFIG.armingDisableCount = data.readU8(); // Flag count
|
FC.CONFIG.armingDisableCount = data.readU8(); // Flag count
|
||||||
FC.CONFIG.armingDisableFlags = data.readU32();
|
FC.CONFIG.armingDisableFlags = data.readU32();
|
||||||
|
|
||||||
sensor_status(FC.CONFIG.activeSensors);
|
sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSPCodes.MSP_RAW_IMU:
|
case MSPCodes.MSP_RAW_IMU:
|
||||||
|
|
|
@ -19,19 +19,23 @@ export function have_sensor(sensors_detected, sensor_code) {
|
||||||
return false;
|
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)
|
// initialize variable (if it wasn't)
|
||||||
if (!sensor_status.previous_sensors_detected) {
|
if (!sensor_status.previous_sensors_detected) {
|
||||||
sensor_status.previous_sensors_detected = -1; // Otherwise first iteration will not be run if sensors_detected == 0
|
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)
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set current value
|
// set current value
|
||||||
sensor_status.previous_sensors_detected = sensors_detected;
|
sensor_status.previous_sensors_detected = sensors_detected;
|
||||||
|
sensor_status.previous_gps_fix_state = gps_fix_state;
|
||||||
|
|
||||||
const eSensorStatus = $("div#sensor-status");
|
const eSensorStatus = $("div#sensor-status");
|
||||||
|
|
||||||
|
@ -72,10 +76,17 @@ export function sensor_status(sensors_detected) {
|
||||||
|
|
||||||
if (have_sensor(sensors_detected, "gps")) {
|
if (have_sensor(sensors_detected, "gps")) {
|
||||||
$(".gps", eSensorStatus).addClass("on");
|
$(".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");
|
$(".gpsicon", eSensorStatus).addClass("active");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$(".gps", eSensorStatus).removeClass("on");
|
$(".gps", eSensorStatus).removeClass("on");
|
||||||
$(".gpsicon", eSensorStatus).removeClass("active");
|
$(".gpsicon", eSensorStatus).removeClass("active");
|
||||||
|
$(".gpsicon", eSensorStatus).removeClass("active_fix");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_sensor(sensors_detected, "sonar")) {
|
if (have_sensor(sensors_detected, "sonar")) {
|
||||||
|
|
|
@ -217,7 +217,7 @@ function finishClose(finishedCallback) {
|
||||||
$('div.connect_controls div.connect_state').text(i18n.getMessage('connect'));
|
$('div.connect_controls div.connect_state').text(i18n.getMessage('connect'));
|
||||||
|
|
||||||
// reset active sensor indicators
|
// reset active sensor indicators
|
||||||
sensor_status(0);
|
sensor_status();
|
||||||
|
|
||||||
if (wasConnected) {
|
if (wasConnected) {
|
||||||
// detach listeners and remove element data
|
// detach listeners and remove element data
|
||||||
|
@ -683,6 +683,9 @@ async function update_live_status() {
|
||||||
if (GUI.active_tab !== 'cli' && GUI.active_tab !== 'presets') {
|
if (GUI.active_tab !== 'cli' && GUI.active_tab !== 'presets') {
|
||||||
await MSP.promise(MSPCodes.MSP_BOXNAMES);
|
await MSP.promise(MSPCodes.MSP_BOXNAMES);
|
||||||
await getStatus();
|
await getStatus();
|
||||||
|
if (have_sensor(FC.CONFIG.activeSensors, 'gps')) {
|
||||||
|
await MSP.promise(MSPCodes.MSP_RAW_GPS);
|
||||||
|
}
|
||||||
await MSP.promise(MSPCodes.MSP_ANALOG);
|
await MSP.promise(MSPCodes.MSP_ANALOG);
|
||||||
|
|
||||||
const active = ((Date.now() - FC.ANALOG.last_received_timestamp) < 300);
|
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);
|
$(".linkicon").toggleClass('active', active);
|
||||||
|
|
||||||
statuswrapper.show();
|
statuswrapper.show();
|
||||||
|
|
Loading…
Reference in New Issue