From 54812f0de156d05a911b2a9c1d4c482d64d2ec1f Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 2 May 2020 02:32:49 +0200 Subject: [PATCH] fix band changes --- htdocs/lib/DemodulatorPanel.js | 16 ++++++++++++++-- htdocs/openwebrx.js | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/lib/DemodulatorPanel.js b/htdocs/lib/DemodulatorPanel.js index a3a6ca8..aa8de15 100644 --- a/htdocs/lib/DemodulatorPanel.js +++ b/htdocs/lib/DemodulatorPanel.js @@ -6,7 +6,7 @@ function DemodulatorPanel(el) { var displayEl = el.find('.webrx-actual-freq') this.tuneableFrequencyDisplay = displayEl.tuneableFrequencyDisplay(); displayEl.on('frequencychange', function(event, freq) { - self.getDemodulator().set_offset_frequency(freq - center_freq); + self.getDemodulator().set_offset_frequency(freq - self.center_freq); }); Modes.registerModePanel(this); @@ -101,7 +101,7 @@ DemodulatorPanel.prototype.setMode = function(modulation) { this.demodulator = new Demodulator(current_offset_frequency, modulation); var self = this; this.demodulator.on("frequencychange", function(freq) { - self.tuneableFrequencyDisplay.setFrequency(center_freq + freq); + self.tuneableFrequencyDisplay.setFrequency(self.center_freq + freq); updateHash(); }); } @@ -187,6 +187,18 @@ DemodulatorPanel.prototype.updateButtons = function() { } } +DemodulatorPanel.prototype.setCenterFrequency = function(center_freq) { + if (this.center_freq === center_freq) { + return ; + } + this.center_freq = center_freq; + var demod = this.getDemodulator(); + if (demod) { + this.tuneableFrequencyDisplay.setFrequency(center_freq + demod.get_offset_frequency()); + } + updateHash(); +}; + $.fn.demodulatorPanel = function(){ if (!this.data('panel')) { this.data('panel', new DemodulatorPanel(this)); diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 19d59c8..971cf65 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -745,6 +745,7 @@ function on_ws_recv(evt) { bandwidth = config['samp_rate']; center_freq = config['center_freq']; + $('#openwebrx-panel-receiver').demodulatorPanel().setCenterFrequency(center_freq); fft_size = config['fft_size']; var audio_compression = config['audio_compression']; audioEngine.setCompression(audio_compression);