diff --git a/htdocs/lib/Demodulator.js b/htdocs/lib/Demodulator.js index 66a7196..3938514 100644 --- a/htdocs/lib/Demodulator.js +++ b/htdocs/lib/Demodulator.js @@ -108,6 +108,7 @@ function Demodulator(offset_frequency, modulation) { this.squelch_level = -150; this.dmr_filter = 3; this.state = {}; + this.secondary_demod = false; var mode = Modes.findByModulation(modulation); if (mode) { this.low_cut = mode.bandpass.low_cut; @@ -175,7 +176,9 @@ Demodulator.prototype.set = function () { //this function sends demodulator par "offset_freq": this.offset_frequency, "mod": this.modulation, "dmr_filter": this.dmr_filter, - "squelch_level": this.squelch_level + "squelch_level": this.squelch_level, + "secondary_mod": this.secondary_demod, + "secondary_offset_freq": this.secondary_offset_freq }; var to_send = {}; for (var key in params) { @@ -215,3 +218,13 @@ Demodulator.prototype.getBandpass = function() { high_cut: this.high_cut }; }; + +Demodulator.prototype.set_secondary_demod = function(secondary_demod) { + this.secondary_demod = secondary_demod; + this.set(); +}; + +Demodulator.prototype.set_secondary_offset_freq = function(secondary_offset) { + this.secondary_offset_freq = secondary_offset; + this.set(); +}; diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 1dcdd3f..2c8d13a 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1810,8 +1810,8 @@ function demodulator_digital_replace(subtype) { divlog('Digital mode "' + mode.name + '" not supported. Please check requirements', true); return; } - secondary_demod_start(subtype); demodulator_analog_replace(mode.underlying[0], true); + secondary_demod_start(subtype); if (mode.bandpass) { demodulators[0].setBandpass(mode.bandpass); } @@ -1879,12 +1879,14 @@ function secondary_demod_init() { function secondary_demod_start(subtype) { secondary_demod_canvases_initialized = false; - ws.send(JSON.stringify({"type": "dspcontrol", "params": {"secondary_mod": subtype}})); + demodulators[0].set_secondary_demod(subtype); secondary_demod = subtype; } function secondary_demod_stop() { - ws.send(JSON.stringify({"type": "dspcontrol", "params": {"secondary_mod": false}})); + if (demodulators[0]) { + demodulators[0].set_secondary_demod(false); + } secondary_demod = false; } @@ -1969,10 +1971,7 @@ function secondary_demod_update_channel_freq_from_event(evt) { if (!secondary_demod_waiting_for_set) { secondary_demod_waiting_for_set = true; window.setTimeout(function () { - ws.send(JSON.stringify({ - "type": "dspcontrol", - "params": {"secondary_offset_freq": Math.floor(secondary_demod_channel_freq)} - })); + demodulators[0].set_secondary_offset_freq(Math.floor(secondary_demod_channel_freq)); secondary_demod_waiting_for_set = false; }, 50