fix band changes

This commit is contained in:
Jakob Ketterl 2020-05-02 02:32:49 +02:00
parent 28c1425a8f
commit 54812f0de1
2 changed files with 15 additions and 2 deletions

View File

@ -6,7 +6,7 @@ function DemodulatorPanel(el) {
var displayEl = el.find('.webrx-actual-freq') var displayEl = el.find('.webrx-actual-freq')
this.tuneableFrequencyDisplay = displayEl.tuneableFrequencyDisplay(); this.tuneableFrequencyDisplay = displayEl.tuneableFrequencyDisplay();
displayEl.on('frequencychange', function(event, freq) { 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); Modes.registerModePanel(this);
@ -101,7 +101,7 @@ DemodulatorPanel.prototype.setMode = function(modulation) {
this.demodulator = new Demodulator(current_offset_frequency, modulation); this.demodulator = new Demodulator(current_offset_frequency, modulation);
var self = this; var self = this;
this.demodulator.on("frequencychange", function(freq) { this.demodulator.on("frequencychange", function(freq) {
self.tuneableFrequencyDisplay.setFrequency(center_freq + freq); self.tuneableFrequencyDisplay.setFrequency(self.center_freq + freq);
updateHash(); 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(){ $.fn.demodulatorPanel = function(){
if (!this.data('panel')) { if (!this.data('panel')) {
this.data('panel', new DemodulatorPanel(this)); this.data('panel', new DemodulatorPanel(this));

View File

@ -745,6 +745,7 @@ function on_ws_recv(evt) {
bandwidth = config['samp_rate']; bandwidth = config['samp_rate'];
center_freq = config['center_freq']; center_freq = config['center_freq'];
$('#openwebrx-panel-receiver').demodulatorPanel().setCenterFrequency(center_freq);
fft_size = config['fft_size']; fft_size = config['fft_size'];
var audio_compression = config['audio_compression']; var audio_compression = config['audio_compression'];
audioEngine.setCompression(audio_compression); audioEngine.setCompression(audio_compression);