update secondary parameters

This commit is contained in:
Jakob Ketterl 2020-04-30 22:31:18 +02:00
parent 33762574c3
commit 1764abe65f
2 changed files with 20 additions and 8 deletions

View File

@ -108,6 +108,7 @@ function Demodulator(offset_frequency, modulation) {
this.squelch_level = -150; this.squelch_level = -150;
this.dmr_filter = 3; this.dmr_filter = 3;
this.state = {}; this.state = {};
this.secondary_demod = false;
var mode = Modes.findByModulation(modulation); var mode = Modes.findByModulation(modulation);
if (mode) { if (mode) {
this.low_cut = mode.bandpass.low_cut; 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, "offset_freq": this.offset_frequency,
"mod": this.modulation, "mod": this.modulation,
"dmr_filter": this.dmr_filter, "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 = {}; var to_send = {};
for (var key in params) { for (var key in params) {
@ -215,3 +218,13 @@ Demodulator.prototype.getBandpass = function() {
high_cut: this.high_cut 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();
};

View File

@ -1810,8 +1810,8 @@ function demodulator_digital_replace(subtype) {
divlog('Digital mode "' + mode.name + '" not supported. Please check requirements', true); divlog('Digital mode "' + mode.name + '" not supported. Please check requirements', true);
return; return;
} }
secondary_demod_start(subtype);
demodulator_analog_replace(mode.underlying[0], true); demodulator_analog_replace(mode.underlying[0], true);
secondary_demod_start(subtype);
if (mode.bandpass) { if (mode.bandpass) {
demodulators[0].setBandpass(mode.bandpass); demodulators[0].setBandpass(mode.bandpass);
} }
@ -1879,12 +1879,14 @@ function secondary_demod_init() {
function secondary_demod_start(subtype) { function secondary_demod_start(subtype) {
secondary_demod_canvases_initialized = false; secondary_demod_canvases_initialized = false;
ws.send(JSON.stringify({"type": "dspcontrol", "params": {"secondary_mod": subtype}})); demodulators[0].set_secondary_demod(subtype);
secondary_demod = subtype; secondary_demod = subtype;
} }
function secondary_demod_stop() { 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; secondary_demod = false;
} }
@ -1969,10 +1971,7 @@ function secondary_demod_update_channel_freq_from_event(evt) {
if (!secondary_demod_waiting_for_set) { if (!secondary_demod_waiting_for_set) {
secondary_demod_waiting_for_set = true; secondary_demod_waiting_for_set = true;
window.setTimeout(function () { window.setTimeout(function () {
ws.send(JSON.stringify({ demodulators[0].set_secondary_offset_freq(Math.floor(secondary_demod_channel_freq));
"type": "dspcontrol",
"params": {"secondary_offset_freq": Math.floor(secondary_demod_channel_freq)}
}));
secondary_demod_waiting_for_set = false; secondary_demod_waiting_for_set = false;
}, },
50 50