make auto squelch level margin configurable

This commit is contained in:
Jakob Ketterl
2020-11-12 18:00:24 +01:00
parent 0f4b8dc794
commit 504c256b3e
7 changed files with 24 additions and 4 deletions

View File

@ -3,6 +3,7 @@ function DemodulatorPanel(el) {
self.el = el;
self.demodulator = null;
self.mode = null;
self.squelchMargin = 10;
var displayEl = el.find('.webrx-actual-freq')
this.tuneableFrequencyDisplay = displayEl.tuneableFrequencyDisplay();
@ -27,9 +28,9 @@ function DemodulatorPanel(el) {
self.setMode(value);
}
});
el.on('click', '.openwebrx-squelch-default', function() {
el.on('click', '.openwebrx-squelch-auto', function() {
if (!self.squelchAvailable()) return;
el.find('.openwebrx-squelch-slider').val(getLogSmeterValue(smeter_level) + 10);
el.find('.openwebrx-squelch-slider').val(getLogSmeterValue(smeter_level) + self.getSquelchMargin());
self.updateSquelch();
});
el.on('change', '.openwebrx-squelch-slider', function() {
@ -247,7 +248,7 @@ DemodulatorPanel.prototype.updateButtons = function() {
}
var squelch_disabled = !this.squelchAvailable();
this.el.find('.openwebrx-squelch-slider').prop('disabled', squelch_disabled);
this.el.find('.openwebrx-squelch-default')[squelch_disabled ? 'addClass' : 'removeClass']('disabled');
this.el.find('.openwebrx-squelch-auto')[squelch_disabled ? 'addClass' : 'removeClass']('disabled');
}
DemodulatorPanel.prototype.setCenterFrequency = function(center_freq) {
@ -322,6 +323,15 @@ DemodulatorPanel.prototype.updateSquelch = function() {
if (demod) demod.setSquelch(sliderValue);
};
DemodulatorPanel.prototype.setSquelchMargin = function(margin) {
if (!margin || this.squelchMargin == margin) return;
this.squelchMargin = margin;
};
DemodulatorPanel.prototype.getSquelchMargin = function() {
return this.squelchMargin;
};
$.fn.demodulatorPanel = function(){
if (!this.data('panel')) {
this.data('panel', new DemodulatorPanel(this));