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

Fix gps color #4241

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions src/js/tabs/gps.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,31 +265,18 @@ gps.initialize = async function (callback) {
rowContent += `<td>${FC.GPS_DATA.svid[i]}</td>`;
rowContent += `<td><meter value="${FC.GPS_DATA.cno[i]}" max="55"></meter></td>`;

let quality = i18n.getMessage(qualityArray[FC.GPS_DATA.quality[i] & 0x7]);
let used = i18n.getMessage(usedArray[(FC.GPS_DATA.quality[i] & 0x8) >> 3]);
let usedColor = '';
const quality = i18n.getMessage(qualityArray[FC.GPS_DATA.quality[i] & 0x7]);
const used = i18n.getMessage(usedArray[(FC.GPS_DATA.quality[i] & 0x8) >> 3]);

// Add color to the text
// 2nd column: no signal = red, unusable = red, searching = red, locked = yellow and fully locked = green
if (quality.startsWith(i18n.getMessage('gnssQualityFullyLocked'))) {
usedColor = 'locked';
quality = `<span class="colorToggle ready">${quality}</span>`;
} else if (quality.startsWith(i18n.getMessage('gnssQualityLocked'))) {
usedColor = 'notReady';
quality = `<span class="colorToggle locked">${quality}</span>`;
} else {
quality = `<span class="colorToggle">${quality}</span>`;
}

// 1st column: unused = red, used = green
if (used.startsWith(i18n.getMessage('gnssUsedUsed'))) {
used = `<span class="colorToggle ready">${used}</span>`;
} else {
used = `<span class="colorToggle ${usedColor}">${used}</span>`;
}

rowContent += `<td style="text-align: left; width: 17%;">${used}</td>
<td style="text-align: left; width: 33%;">${quality}</td>`;
const qualityColor = quality.startsWith(i18n.getMessage('gnssQualityFullyLocked')) ? 'ready' : quality.startsWith(i18n.getMessage('gnssQualityLocked')) ? 'locked' : 'low';
const qualityHtml = `<span class="colorToggle ${qualityColor}">${quality}</span>`;

const usedColor = used.startsWith(i18n.getMessage('gnssUsedUsed')) ? 'ready' : 'low';
const usedHtml = `<span class="colorToggle ${usedColor}">${used}</span>`;

rowContent += `<td style="text-align: left; width: 17%;">${usedHtml}</td>
<td style="text-align: left; width: 33%;">${qualityHtml}</td>`;
}
eSsTable.append(`<tr>${rowContent}</tr>`);
}
Expand Down