diff --git a/htdocs/lib/DemodulatorPanel.js b/htdocs/lib/DemodulatorPanel.js index b5b4bb9..c6e127e 100644 --- a/htdocs/lib/DemodulatorPanel.js +++ b/htdocs/lib/DemodulatorPanel.js @@ -140,7 +140,8 @@ DemodulatorPanel.prototype.getDemodulator = function() { }; DemodulatorPanel.prototype.startDemodulator = function() { - var params = $.extend(this.initialParams || {}, this.transformHashParams(validateHash())); + if (!Modes.initComplete()) return; + var params = $.extend({}, this.initialParams || {}, this.transformHashParams(validateHash())); this._apply(params); }; @@ -197,14 +198,11 @@ DemodulatorPanel.prototype.updateButtons = function() { DemodulatorPanel.prototype.setCenterFrequency = function(center_freq) { if (this.center_freq === center_freq) { - return ; + return; } + this.stopDemodulator(); this.center_freq = center_freq; - var demod = this.getDemodulator(); - if (demod) { - this.tuneableFrequencyDisplay.setFrequency(center_freq + demod.get_offset_frequency()); - } - updateHash(); + this.startDemodulator(); }; $.fn.demodulatorPanel = function(){ diff --git a/htdocs/lib/Modes.js b/htdocs/lib/Modes.js index 6c6fa80..c12ff23 100644 --- a/htdocs/lib/Modes.js +++ b/htdocs/lib/Modes.js @@ -20,13 +20,13 @@ var Modes = { registerModePanel: function(el) { this.panels.push(el); }, + initComplete: function() { + return this.modes.length && Object.keys(this.features).length; + }, updatePanels: function() { - var init_complete = this.modes.length && Object.keys(this.features).length; this.panels.forEach(function(p) { p.render(); - if (init_complete) { - p.startDemodulator(); - } + p.startDemodulator(); }); } }; diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 8c72612..e5a7489 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -745,7 +745,6 @@ 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); @@ -758,7 +757,9 @@ function on_ws_recv(evt) { updateSquelch(); waterfall_init(); - $('#openwebrx-panel-receiver').demodulatorPanel().setInitialParams(initial_demodulator_params); + var demodulatorPanel = $('#openwebrx-panel-receiver').demodulatorPanel(); + demodulatorPanel.setInitialParams(initial_demodulator_params); + demodulatorPanel.setCenterFrequency(center_freq); bookmarks.loadLocalBookmarks(); waterfall_clear();