diff --git a/csdr.py b/csdr.py index 710e641..2bcbac9 100644 --- a/csdr.py +++ b/csdr.py @@ -25,6 +25,7 @@ import subprocess import os import signal import threading +import math from functools import partial from owrx.kiss import KissClient, DirewolfConfig @@ -85,7 +86,7 @@ class dsp(object): self.csdr_dynamic_bufsize = False self.csdr_print_bufsizes = False self.csdr_through = False - self.squelch_level = 0 + self.squelch_level = -150 self.fft_averages = 50 self.iqtee = False self.iqtee2 = False @@ -521,13 +522,16 @@ class dsp(object): def get_bpf(self): return [self.low_cut, self.high_cut] + def convertToLinear(self, db): + return float(math.pow(10, db / 10)) + def set_squelch_level(self, squelch_level): self.squelch_level = squelch_level # no squelch required on digital voice modes - actual_squelch = 0 if self.isDigitalVoice() or self.isPacket() else self.squelch_level + actual_squelch = -150 if self.isDigitalVoice() or self.isPacket() else self.squelch_level if self.running: self.modification_lock.acquire() - self.squelch_pipe_file.write("%g\n" % (float(actual_squelch))) + self.squelch_pipe_file.write("%g\n" % (self.convertToLinear(actual_squelch))) self.squelch_pipe_file.flush() self.modification_lock.release() diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index a6b193d..08dd94d 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -141,9 +141,8 @@ function setSquelchToAuto() { } function updateSquelch() { - var sliderValue = parseInt(e("openwebrx-panel-squelch").value); - var outputValue = (sliderValue === parseInt(e("openwebrx-panel-squelch").min)) ? 0 : getLinearSmeterValue(sliderValue); - ws.send(JSON.stringify({"type": "dspcontrol", "params": {"squelch_level": outputValue}})); + var sliderValue = parseInt($("#openwebrx-panel-squelch").val()); + ws.send(JSON.stringify({"type": "dspcontrol", "params": {"squelch_level": sliderValue}})); } var waterfall_min_level; @@ -1058,6 +1057,9 @@ function on_ws_recv(evt) { mathbox_waterfall_colors = config['mathbox_waterfall_colors']; mathbox_waterfall_frequency_resolution = config['mathbox_waterfall_frequency_resolution']; mathbox_waterfall_history_length = config['mathbox_waterfall_history_length']; + var sql = Number.isInteger(config['initial_squelch_level']) ? config['initial_squelch_level'] : -150; + $("#openwebrx-panel-squelch").val(sql); + updateSquelch(); waterfall_init(); initialize_demodulator(); diff --git a/owrx/connection.py b/owrx/connection.py index af0a3ec..a8e33e9 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -69,6 +69,7 @@ class OpenWebRxReceiverClient(Client): "mathbox_waterfall_colors", "mathbox_waterfall_history_length", "mathbox_waterfall_frequency_resolution", + "initial_squelch_level", ] def __init__(self, conn):