send only necessary config changes

This commit is contained in:
Jakob Ketterl 2020-12-30 17:15:48 +01:00
parent 2c3146314b
commit abb0813948
2 changed files with 43 additions and 24 deletions

View File

@ -4,6 +4,7 @@ function DemodulatorPanel(el) {
self.demodulator = null; self.demodulator = null;
self.mode = null; self.mode = null;
self.squelchMargin = 10; self.squelchMargin = 10;
self.initialParams = {};
var displayEl = el.find('.webrx-actual-freq') var displayEl = el.find('.webrx-actual-freq')
this.tuneableFrequencyDisplay = displayEl.tuneableFrequencyDisplay(); this.tuneableFrequencyDisplay = displayEl.tuneableFrequencyDisplay();
@ -180,7 +181,7 @@ DemodulatorPanel.prototype.collectParams = function() {
squelch_level: -150, squelch_level: -150,
mod: 'nfm' mod: 'nfm'
} }
return $.extend(new Object(), defaults, this.initialParams || {}, this.transformHashParams(this.parseHash())); return $.extend(new Object(), defaults, this.initialParams, this.transformHashParams(this.parseHash()));
}; };
DemodulatorPanel.prototype.startDemodulator = function() { DemodulatorPanel.prototype.startDemodulator = function() {
@ -206,7 +207,7 @@ DemodulatorPanel.prototype._apply = function(params) {
}; };
DemodulatorPanel.prototype.setInitialParams = function(params) { DemodulatorPanel.prototype.setInitialParams = function(params) {
this.initialParams = params; $.extend(this.initialParams, params);
}; };
DemodulatorPanel.prototype.onHashChange = function() { DemodulatorPanel.prototype.onHashChange = function() {

View File

@ -700,40 +700,58 @@ function on_ws_recv(evt) {
switch (json.type) { switch (json.type) {
case "config": case "config":
var config = json['value']; var config = json['value'];
if ('waterfall_colors' in config)
waterfall_colors = buildWaterfallColors(config['waterfall_colors']); waterfall_colors = buildWaterfallColors(config['waterfall_colors']);
if ('waterfall_min_level' in config)
waterfall_min_level_default = config['waterfall_min_level']; waterfall_min_level_default = config['waterfall_min_level'];
if ('waterfall_max_level' in config)
waterfall_max_level_default = config['waterfall_max_level']; waterfall_max_level_default = config['waterfall_max_level'];
if ('waterfall_auto_level_margin' in config)
waterfall_auto_level_margin = config['waterfall_auto_level_margin']; waterfall_auto_level_margin = config['waterfall_auto_level_margin'];
waterfallColorsDefault(); waterfallColorsDefault();
var initial_demodulator_params = { var initial_demodulator_params = {};
mod: config['start_mod'], if ('start_mod' in config)
offset_frequency: config['start_offset_freq'], initial_demodulator_params['mod'] = config['start_mod'];
squelch_level: Number.isInteger(config['initial_squelch_level']) ? config['initial_squelch_level'] : -150 if ('start_offset_freq' in config)
}; initial_demodulator_params['offset_frequency'] = config['start_offset_freq'];
if ('initial_squelch_level' in config)
initial_demodulator_params['squelch_level'] = Number.isInteger(config['initial_squelch_level']) ? config['initial_squelch_level'] : -150;
if ('samp_rate' in config)
bandwidth = config['samp_rate']; bandwidth = config['samp_rate'];
if ('center_freq' in config)
center_freq = config['center_freq']; center_freq = config['center_freq'];
if ('fft_size' in config)
fft_size = config['fft_size']; fft_size = config['fft_size'];
if ('audio_compresion' in config) {
var audio_compression = config['audio_compression']; var audio_compression = config['audio_compression'];
audioEngine.setCompression(audio_compression); audioEngine.setCompression(audio_compression);
divlog("Audio stream is " + ((audio_compression === "adpcm") ? "compressed" : "uncompressed") + "."); divlog("Audio stream is " + ((audio_compression === "adpcm") ? "compressed" : "uncompressed") + ".");
}
if ('fft_compression' in config) {
fft_compression = config['fft_compression']; fft_compression = config['fft_compression'];
divlog("FFT stream is " + ((fft_compression === "adpcm") ? "compressed" : "uncompressed") + "."); divlog("FFT stream is " + ((fft_compression === "adpcm") ? "compressed" : "uncompressed") + ".");
}
if ('max_clients' in config)
$('#openwebrx-bar-clients').progressbar().setMaxClients(config['max_clients']); $('#openwebrx-bar-clients').progressbar().setMaxClients(config['max_clients']);
waterfall_init(); waterfall_init();
var demodulatorPanel = $('#openwebrx-panel-receiver').demodulatorPanel(); var demodulatorPanel = $('#openwebrx-panel-receiver').demodulatorPanel();
demodulatorPanel.setCenterFrequency(center_freq); demodulatorPanel.setCenterFrequency(center_freq);
demodulatorPanel.setInitialParams(initial_demodulator_params); demodulatorPanel.setInitialParams(initial_demodulator_params);
if ('squelch_auto_margin' in config)
demodulatorPanel.setSquelchMargin(config['squelch_auto_margin']); demodulatorPanel.setSquelchMargin(config['squelch_auto_margin']);
bookmarks.loadLocalBookmarks(); bookmarks.loadLocalBookmarks();
waterfall_clear(); waterfall_clear();
if ('sdr_id' in config && 'profile_id' in config) {
currentprofile = config['sdr_id'] + '|' + config['profile_id']; currentprofile = config['sdr_id'] + '|' + config['profile_id'];
$('#openwebrx-sdr-profiles-listbox').val(currentprofile); $('#openwebrx-sdr-profiles-listbox').val(currentprofile);
}
if ('frequency_display_precision' in config)
$('#openwebrx-panel-receiver').demodulatorPanel().setFrequencyPrecision(config['frequency_display_precision']); $('#openwebrx-panel-receiver').demodulatorPanel().setFrequencyPrecision(config['frequency_display_precision']);
break; break;