From 01e96196a4ae09bcc6d183fbbcee84d3e66a8504 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Sun, 1 Dec 2024 21:32:43 +0100 Subject: [PATCH] skyspy: quick quality estimate --- apps/skyspy/skyspy.app.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/skyspy/skyspy.app.js b/apps/skyspy/skyspy.app.js index 687efd59d..14448d345 100644 --- a/apps/skyspy/skyspy.app.js +++ b/apps/skyspy/skyspy.app.js @@ -5,6 +5,7 @@ search for sky -- not enough sattelites wait for signal -- have 5 sattelites with good SNR + .. good snr is like 26, with maybe 24 time goes up twice, maybe 22 for three times, less than that and many times more 2D fix 3D fix @@ -625,17 +626,32 @@ let sky = { .setFontAlign(-1, -1) .drawString(msg, 0, 0); }, - getSatSNR: function(n) { + snrSort: function() { + return this.sats.slice(0, this.snum).sort((a, b) => b.snr - a.snr); + }, + getSatSNR: function(n) { /* Get n-th strongest sat */ if (n <= 0 || n > this.sats.length) { throw new Error("Invalid value for n"); } // Sort the satellites by snr in descending order - let sortedSats = this.sats.slice(0, this.snum).sort((a, b) => b.snr - a.snr); + let sortedSats = this.snrSort(); // Return the SNR of the n-th strongest satellite return sortedSats[n - 1].snr; }, + qualest: function() { + // Sort the satellites by snr in descending order + let sortedSats = this.snrSort(); + if (sortedSats[4].snr) { + return "" + sortedSats[4].snr + "dB"; + } + for (i=4; i>=0; i--) { + if (sortedSats[i].snr) + return "S" + (i+1); + } + return "nil"; + }, messageEnd: function() { this.old_msg = this.msg; this.msg = {}; @@ -643,7 +659,9 @@ let sky = { this.msg.bd = {}; this.msg.gl = {}; this.drawSats(this.sats); - print("SNR/5: ", this.getSatSNR(5), this.getSatSNR(3), this.getSatSNR(1)); + let r = this.qualest(); + print(r); + ui.drawMsg(r); //print(this.sats); if (this.sats_used < 5) this.sky_start = getTime();