From d952405886dab44f12c1de53b57912b34320c7c8 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 28 Nov 2018 15:14:45 +0100 Subject: Get calibration to show nice numbers on web page --- gui/api/__init__.py | 1 - gui/dpd/__init__.py | 4 ++-- gui/static/js/odr-predistortion.js | 23 +++++++++++++++++++---- gui/templates/predistortion.html | 2 ++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gui/api/__init__.py b/gui/api/__init__.py index c1d73a0..70a4eff 100755 --- a/gui/api/__init__.py +++ b/gui/api/__init__.py @@ -125,7 +125,6 @@ class API: return send_ok() else: if self.calibration_result is not None: - print("cal result", repr(self.calibration_result)) return send_ok(self.calibration_result) else: return send_error("DPD calibration result unknown") diff --git a/gui/dpd/__init__.py b/gui/dpd/__init__.py index 85abe86..2c7649b 100644 --- a/gui/dpd/__init__.py +++ b/gui/dpd/__init__.py @@ -57,8 +57,8 @@ class DPD: def capture_calibration(self): tx_ts, tx_median, rx_ts, rx_median, coarse_offset, correlation_coefficient = self.capture.calibrate() result = {'status': "ok"} - result['tx_median'] = "{:.2}dB".format(20*np.log10(tx_median)) - result['rx_median'] = "{:.2}dB".format(20*np.log10(rx_median)) + result['tx_median'] = "{:.2f}dB".format(20*np.log10(tx_median)) + result['rx_median'] = "{:.2f}dB".format(20*np.log10(rx_median)) result['tx_ts'] = tx_ts result['rx_ts'] = rx_ts result['coarse_offset'] = int(coarse_offset) diff --git a/gui/static/js/odr-predistortion.js b/gui/static/js/odr-predistortion.js index e13fb88..6c5f4d3 100644 --- a/gui/static/js/odr-predistortion.js +++ b/gui/static/js/odr-predistortion.js @@ -18,16 +18,31 @@ // You should have received a copy of the GNU General Public License // along with ODR-DabMod. If not, see . +function calibraterefresh() { + doApiRequestGET("/api/calibrate", function(data) { + var text = "Captured TX signal and feedback." + + " TX median: " + data['tx_median'] + + " RX median: " + data['rx_median'] + + " with relative timestamp offset " + + (data['tx_ts'] - data['rx_ts']) + + " and measured offset " + data['coarse_offset'] + + ". Correlation: " + data['correlation']; + $('#calibrationresults').text(text); + }); +} + $(function(){ + $('#calibraterefreshbtn').click(calibraterefresh); + $('#calibratebtn').click(function() { doApiRequestPOST("/api/calibrate", {}, function(data) { console.log("calibrate succeeded: " + JSON.stringify(data)); + $('#calibrationresults').text("Processing..."); + setTimeout(function() { - doApiRequestGET("/api/calibrate", function(data) { - $('#calibrationresults').text(data); - }); - }, 2000); + calibraterefresh(); + }, 3000); }); }); diff --git a/gui/templates/predistortion.html b/gui/templates/predistortion.html index 139d982..398b4b7 100644 --- a/gui/templates/predistortion.html +++ b/gui/templates/predistortion.html @@ -36,6 +36,8 @@ along with ODR-DabMod. If not, see . parameters are invalidated! +
Calibration results:N/A
-- cgit v1.2.3