diff --git a/config_webrx.py b/config_webrx.py index 427e4dc..77e2278 100644 --- a/config_webrx.py +++ b/config_webrx.py @@ -269,6 +269,10 @@ waterfall_auto_level_margin = {"min": 3, "max": 10, "min_range": 50} # \_waterfall_auto_level_margin["min"]_/ |__ current_min_power_level | \_waterfall_auto_level_margin["max"]_/ # current_max_power_level __| +# This setting allows you to modify the precision of the frequency displays in OpenWebRX. +# Set this to the number of digits you would like to see: +frequency_display_precision = 5 + # This setting tells the auto-squelch the offset to add to the current signal level to use as the new squelch level. # Lowering this setting will give you a more sensitive squelch, but it may also cause unwanted squelch openings when # using the auto squelch. diff --git a/htdocs/lib/DemodulatorPanel.js b/htdocs/lib/DemodulatorPanel.js index 169e427..22a86f3 100644 --- a/htdocs/lib/DemodulatorPanel.js +++ b/htdocs/lib/DemodulatorPanel.js @@ -11,6 +11,8 @@ function DemodulatorPanel(el) { self.getDemodulator().set_offset_frequency(freq - self.center_freq); }); + this.mouseFrequencyDisplay = el.find('.webrx-mouse-freq').frequencyDisplay(); + Modes.registerModePanel(this); el.on('click', '.openwebrx-demodulator-button', function() { var modulation = $(this).data('modulation'); @@ -332,6 +334,15 @@ DemodulatorPanel.prototype.getSquelchMargin = function() { return this.squelchMargin; }; +DemodulatorPanel.prototype.setMouseFrequency = function(freq) { + this.mouseFrequencyDisplay.setFrequency(freq); +}; + +DemodulatorPanel.prototype.setFrequencyPrecision = function(precision) { + this.tuneableFrequencyDisplay.setFrequencyPrecision(precision); + this.mouseFrequencyDisplay.setFrequencyPrecision(precision); +}; + $.fn.demodulatorPanel = function(){ if (!this.data('panel')) { this.data('panel', new DemodulatorPanel(this)); diff --git a/htdocs/lib/FrequencyDisplay.js b/htdocs/lib/FrequencyDisplay.js index d475cf2..ae50fe7 100644 --- a/htdocs/lib/FrequencyDisplay.js +++ b/htdocs/lib/FrequencyDisplay.js @@ -1,6 +1,7 @@ function FrequencyDisplay(element) { this.element = $(element); this.digits = []; + this.precision = 4; this.setupElements(); this.setFrequency(0); } @@ -14,7 +15,10 @@ FrequencyDisplay.prototype.setupElements = function() { FrequencyDisplay.prototype.setFrequency = function(freq) { this.frequency = freq; - var formatted = (freq / 1e6).toLocaleString(undefined, {maximumFractionDigits: 4, minimumFractionDigits: 4}); + var formatted = (freq / 1e6).toLocaleString( + undefined, + {maximumFractionDigits: this.precision, minimumFractionDigits: this.precision} + ); var children = this.digitContainer.children(); for (var i = 0; i < formatted.length; i++) { if (!this.digits[i]) { @@ -34,6 +38,12 @@ FrequencyDisplay.prototype.setFrequency = function(freq) { } }; +FrequencyDisplay.prototype.setFrequencyPrecision = function(precision) { + if (!precision) return; + this.precision = precision; + this.setFrequency(this.frequency); +}; + function TuneableFrequencyDisplay(element) { FrequencyDisplay.call(this, element); this.setupEvents(); diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index dc26330..4ca7b49 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -292,7 +292,7 @@ function scale_canvas_mousemove(evt) { function frequency_container_mousemove(evt) { var frequency = center_freq + scale_offset_freq_from_px(evt.pageX); - $('.webrx-mouse-freq').frequencyDisplay().setFrequency(frequency); + $('#openwebrx-panel-receiver').demodulatorPanel().setMouseFrequency(frequency); } function scale_canvas_end_drag(x) { @@ -570,7 +570,7 @@ function canvas_mousemove(evt) { bookmarks.position(); } } else { - $('.webrx-mouse-freq').frequencyDisplay().setFrequency(canvas_get_frequency(relativeX)); + $('#openwebrx-panel-receiver').demodulatorPanel().setMouseFrequency(canvas_get_frequency(relativeX)); } } @@ -734,6 +734,8 @@ function on_ws_recv(evt) { currentprofile = config['sdr_id'] + '|' + config['profile_id']; $('#openwebrx-sdr-profiles-listbox').val(currentprofile); + $('#openwebrx-panel-receiver').demodulatorPanel().setFrequencyPrecision(config['frequency_display_precision']); + break; case "secondary_config": var s = json['value']; @@ -1241,7 +1243,6 @@ function openwebrx_init() { secondary_demod_init(); digimodes_init(); initPanels(); - $('.webrx-mouse-freq').frequencyDisplay(); $('#openwebrx-panel-receiver').demodulatorPanel(); window.addEventListener("resize", openwebrx_resize); bookmarks = new BookmarkBar(); diff --git a/owrx/connection.py b/owrx/connection.py index 9ff4201..c93290d 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -124,6 +124,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): "initial_squelch_level", "profile_id", "squelch_auto_margin", + "frequency_display_precision", ] def __init__(self, conn):