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.mode = null;
self.squelchMargin = 10;
self.initialParams = {};
var displayEl = el.find('.webrx-actual-freq')
this.tuneableFrequencyDisplay = displayEl.tuneableFrequencyDisplay();
@ -180,7 +181,7 @@ DemodulatorPanel.prototype.collectParams = function() {
squelch_level: -150,
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() {
@ -206,7 +207,7 @@ DemodulatorPanel.prototype._apply = function(params) {
};
DemodulatorPanel.prototype.setInitialParams = function(params) {
this.initialParams = params;
$.extend(this.initialParams, params);
};
DemodulatorPanel.prototype.onHashChange = function() {

View File

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