restart demodulator based on modes

This commit is contained in:
Jakob Ketterl 2020-05-03 12:48:25 +02:00
parent 26ba8ca999
commit e92a91663d

View File

@ -2,6 +2,7 @@ function DemodulatorPanel(el) {
var self = this; var self = this;
self.el = el; self.el = el;
self.demodulator = null; self.demodulator = null;
self.mode = null;
var displayEl = el.find('.webrx-actual-freq') var displayEl = el.find('.webrx-actual-freq')
this.tuneableFrequencyDisplay = displayEl.tuneableFrequencyDisplay(); this.tuneableFrequencyDisplay = displayEl.tuneableFrequencyDisplay();
@ -82,24 +83,25 @@ DemodulatorPanel.prototype.setMode = function(modulation) {
if (!mode) { if (!mode) {
return; return;
} }
if (this.mode === mode) {
return;
}
if (!mode.isAvailable()) { if (!mode.isAvailable()) {
divlog('Modulation "' + mode.name + '" not supported. Please check requirements', true); divlog('Modulation "' + mode.name + '" not supported. Please check requirements', true);
return; return;
} }
this.mode = mode;
if (mode.type === 'digimode') { if (mode.type === 'digimode') {
modulation = mode.underlying[0]; modulation = mode.underlying[0];
} }
var current_offset_frequency = 0; var current_offset_frequency = 0;
var current_modulation = false;
if (this.demodulator) { if (this.demodulator) {
current_modulation = this.demodulator.get_modulation();
current_offset_frequency = this.demodulator.get_offset_frequency(); current_offset_frequency = this.demodulator.get_offset_frequency();
} }
var replace_modulator = current_modulation !== modulation;
if (replace_modulator) {
this.stopDemodulator(); this.stopDemodulator();
this.demodulator = new Demodulator(current_offset_frequency, modulation); this.demodulator = new Demodulator(current_offset_frequency, modulation);
var self = this; var self = this;
@ -107,7 +109,6 @@ DemodulatorPanel.prototype.setMode = function(modulation) {
self.tuneableFrequencyDisplay.setFrequency(self.center_freq + freq); self.tuneableFrequencyDisplay.setFrequency(self.center_freq + freq);
self.updateHash(); self.updateHash();
}); });
}
if (mode.type === 'digimode') { if (mode.type === 'digimode') {
this.demodulator.set_secondary_demod(mode.modulation); this.demodulator.set_secondary_demod(mode.modulation);
if (mode.bandpass) { if (mode.bandpass) {
@ -117,9 +118,7 @@ DemodulatorPanel.prototype.setMode = function(modulation) {
this.demodulator.set_secondary_demod(false); this.demodulator.set_secondary_demod(false);
} }
if (replace_modulator) {
this.demodulator.start(); this.demodulator.start();
}
this.updateButtons(); this.updateButtons();
this.updatePanels(); this.updatePanels();
@ -127,8 +126,7 @@ DemodulatorPanel.prototype.setMode = function(modulation) {
}; };
DemodulatorPanel.prototype.disableDigiMode = function() { DemodulatorPanel.prototype.disableDigiMode = function() {
var modulation = this.el.find('.openwebrx-button.highlighted[data-modulation]').data('modulation'); this.setMode(this.getDemodulator().get_modulation());
this.setMode(modulation);
}; };
DemodulatorPanel.prototype.updatePanels = function() { DemodulatorPanel.prototype.updatePanels = function() {