From 6cbbaff24022031e6f5591f92801468e98ec4f2b Mon Sep 17 00:00:00 2001 From: HThuren <99370924+HThuren@users.noreply.github.com> Date: Mon, 13 Mar 2023 20:34:17 +0100 Subject: [PATCH] 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 --- src/css/main.less | 6 +++++- src/images/icons/sensor_sat_on_no_fix.png | Bin 0 -> 2405 bytes ...r_sat_on.png => sensor_sat_on_with_fix.png} | Bin src/js/msp/MSPHelper.js | 4 ++-- src/js/sensor_helpers.js | 17 ++++++++++++++--- src/js/serial_backend.js | 7 ++++++- 6 files changed, 27 insertions(+), 7 deletions(-) create mode 100755 src/images/icons/sensor_sat_on_no_fix.png rename src/images/icons/{sensor_sat_on.png => sensor_sat_on_with_fix.png} (100%) mode change 100644 => 100755 diff --git a/src/css/main.less b/src/css/main.less index bc8ebfb5..e53de65e 100644 --- a/src/css/main.less +++ b/src/css/main.less @@ -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; diff --git a/src/images/icons/sensor_sat_on_no_fix.png b/src/images/icons/sensor_sat_on_no_fix.png new file mode 100755 index 0000000000000000000000000000000000000000..1f718fc8726fd60b7d31bcf60c2e600785cf0706 GIT binary patch literal 2405 zcmV-r37YnaP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2>MAxK~#8N?VEpW z8)q5EpZ9DxzvB?Msnm3fn;dP^4%ndUpe+c&fR0Vw#QsRKwrrzA41qu}*ytn#QbnbX z2_bYcEtLxMav1uFHC=y$eO&e$`^w-*R;?k`@XzVmj>iqEeUY_UtoM$_ZbFnYB zk?td<_dd^Ea(CZ*-uHc;_padL;^N}s;^N}s;^N}s;^GV=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47O%OFQyL-_0C^*Tml_o>Les*Oe zjeeZTz1V+G|NFaI$JX6&5r0Sa-xXS;G#f>CK@_kptEbq&G4YH^W%h+j*upI^67m&p zen7LR8>$D zZ%j&G@;TF=0j3PAaJ;#kn^Y4d;9zg~7Ku@TBEB}z8#cc-puc4vkOx!1-l6r1KdG^+ zAf|A=;oI@|W=(kW;b?7pxvTRLF|A~c8=?kg0wK+uA?bbXmV=$cMohWJ+?fN`o~N;P zcpf7%N?phrg9g8){R%e%Z!n$S%m<#Ue#r}TF}QtrmuQl+l1?n_e}vIvfQ{{q@KK9;9$#4}=X|9I;O?QZs%V-s$gZ+tSi z*XM&S1w`#GH+PB&Df5W1SM_?BY zZu~t~61mG%ncyC*KqhfqjN(X1#Xm)zA$1t6R$jTQ~phX|Rvo7ETBBmEf_!2j(in2wX1x6rE25p-U1)qaS?+teTYk}gI z!>z|doorSOWf#u^MI_Pu8=eU6tyuy$fR1_IjA+Iv^WbP_^$02I~z}e00000NkvXXu0mjfMxUFY literal 0 HcmV?d00001 diff --git a/src/images/icons/sensor_sat_on.png b/src/images/icons/sensor_sat_on_with_fix.png old mode 100644 new mode 100755 similarity index 100% rename from src/images/icons/sensor_sat_on.png rename to src/images/icons/sensor_sat_on_with_fix.png diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 6104c5af..3de999f3 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -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: diff --git a/src/js/sensor_helpers.js b/src/js/sensor_helpers.js index 3da219e3..d204aab2 100644 --- a/src/js/sensor_helpers.js +++ b/src/js/sensor_helpers.js @@ -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"); - $(".gpsicon", eSensorStatus).addClass("active"); + 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")) { diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js index 3a05e942..9b622e28 100644 --- a/src/js/serial_backend.js +++ b/src/js/serial_backend.js @@ -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();