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 icon now reflect fix state #3377

Merged
merged 4 commits into from Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/css/main.less
Expand Up @@ -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;
Expand Down
Binary file added src/images/icons/sensor_sat_on_no_fix.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
4 changes: 2 additions & 2 deletions src/js/msp/MSPHelper.js
Expand Up @@ -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();
Expand All @@ -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:
Expand Down
17 changes: 14 additions & 3 deletions src/js/sensor_helpers.js
Expand Up @@ -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, gps_fix_state) {
HThuren marked this conversation as resolved.
Show resolved Hide resolved
// 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) {
HThuren marked this conversation as resolved.
Show resolved Hide resolved
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");

Expand Down Expand Up @@ -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")) {
Expand Down
10 changes: 8 additions & 2 deletions src/js/serial_backend.js
Expand Up @@ -213,7 +213,7 @@ function finishClose(finishedCallback) {
$('div.connect_controls div.connect_state').text(i18n.getMessage('connect'));

// reset active sensor indicators
sensor_status(0);
sensor_status(0, 0);

if (wasConnected) {
// detach listeners and remove element data
Expand Down Expand Up @@ -348,7 +348,7 @@ function onOpenVirtual() {
processBoardInfo();

update_dataflash_global();
sensor_status(FC.CONFIG.activeSensors);
sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);
HThuren marked this conversation as resolved.
Show resolved Hide resolved
updateTabList(FC.FEATURE_CONFIG.features);
}

Expand Down Expand Up @@ -667,10 +667,14 @@ async function getStatus() {

async function update_live_status() {
const statuswrapper = $('#quad-status_wrapper');
// const sensorState = $('#sensor-status');
HThuren marked this conversation as resolved.
Show resolved Hide resolved

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);
Expand Down Expand Up @@ -711,6 +715,8 @@ async function update_live_status() {
}
}

sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);

$(".linkicon").toggleClass('active', active);

statuswrapper.show();
Expand Down