diff --git a/htdocs/lib/DemodulatorPanel.js b/htdocs/lib/DemodulatorPanel.js index 33751b0..3b815c2 100644 --- a/htdocs/lib/DemodulatorPanel.js +++ b/htdocs/lib/DemodulatorPanel.js @@ -353,9 +353,9 @@ DemodulatorPanel.prototype.setMouseFrequency = function(freq) { this.mouseFrequencyDisplay.setFrequency(freq); }; -DemodulatorPanel.prototype.setFrequencyPrecision = function(precision) { - this.tuneableFrequencyDisplay.setFrequencyPrecision(precision); - this.mouseFrequencyDisplay.setFrequencyPrecision(precision); +DemodulatorPanel.prototype.setTuningPrecision = function(precision) { + this.tuneableFrequencyDisplay.setTuningPrecision(precision); + this.mouseFrequencyDisplay.setTuningPrecision(precision); }; $.fn.demodulatorPanel = function(){ diff --git a/htdocs/lib/FrequencyDisplay.js b/htdocs/lib/FrequencyDisplay.js index 777b975..3d20f8c 100644 --- a/htdocs/lib/FrequencyDisplay.js +++ b/htdocs/lib/FrequencyDisplay.js @@ -7,7 +7,7 @@ function FrequencyDisplay(element) { }; this.element = $(element); this.digits = []; - this.precision = 4; + this.precision = 2; this.setupElements(); this.setFrequency(0); } @@ -31,9 +31,10 @@ FrequencyDisplay.prototype.setFrequency = function(freq) { this.frequency = freq; this.exponent = Math.floor(Math.log10(this.frequency) / 3) * 3; + var digits = Math.max(0, this.exponent - this.precision); var formatted = (freq / 10 ** this.exponent).toLocaleString( undefined, - {maximumFractionDigits: this.precision, minimumFractionDigits: this.precision} + {maximumFractionDigits: digits, minimumFractionDigits: digits} ); var children = this.digitContainer.children(); for (var i = 0; i < formatted.length; i++) { @@ -55,8 +56,8 @@ FrequencyDisplay.prototype.setFrequency = function(freq) { this.unitContainer.text(' ' + this.getPrefix() + 'Hz'); }; -FrequencyDisplay.prototype.setFrequencyPrecision = function(precision) { - if (!precision) return; +FrequencyDisplay.prototype.setTuningPrecision = function(precision) { + if (typeof(precision) == 'undefined') return; this.precision = precision; this.setFrequency(this.frequency); }; diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index d31c13d..b6343fd 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -770,8 +770,8 @@ function on_ws_recv(evt) { waterfall_clear(); } - if ('frequency_display_precision' in config) - $('#openwebrx-panel-receiver').demodulatorPanel().setFrequencyPrecision(config['frequency_display_precision']); + if ('tuning_precision' in config) + $('#openwebrx-panel-receiver').demodulatorPanel().setTuningPrecision(config['tuning_precision']); break; case "secondary_config": diff --git a/owrx/config/defaults.py b/owrx/config/defaults.py index afb74d8..db0441d 100644 --- a/owrx/config/defaults.py +++ b/owrx/config/defaults.py @@ -2,7 +2,7 @@ from owrx.property import PropertyLayer defaultConfig = PropertyLayer( - version=5, + version=6, max_clients=20, receiver_name="[Callsign]", receiver_location="Budapest, Hungary", @@ -25,7 +25,7 @@ defaultConfig = PropertyLayer( waterfall_scheme="GoogleTurboWaterfall", waterfall_levels=PropertyLayer(min=-88, max=-20), waterfall_auto_level_margin=PropertyLayer(min=3, max=10, min_range=50), - frequency_display_precision=4, + tuning_precision=2, squelch_auto_margin=10, nmux_memory=50, google_maps_api_key="", diff --git a/owrx/config/migration.py b/owrx/config/migration.py index a241e01..3ddccbd 100644 --- a/owrx/config/migration.py +++ b/owrx/config/migration.py @@ -89,13 +89,23 @@ class ConfigMigratorVersion4(ConfigMigrator): config["version"] = 5 +class ConfigMigratorVersion5(ConfigMigrator): + def migrate(self, config): + if "frequency_display_precision" in config: + # old config was always in relation to the display in MHz (1e6 Hz, hence the 6) + config["tuning_precision"] = 6 - config["frequency_display_precision"] + del config["frequency_display_precision"] + config["version"] = 6 + + class Migrator(object): - currentVersion = 5 + currentVersion = 6 migrators = { 1: ConfigMigratorVersion1(), 2: ConfigMigratorVersion2(), 3: ConfigMigratorVersion3(), 4: ConfigMigratorVersion4(), + 5: ConfigMigratorVersion5(), } @staticmethod diff --git a/owrx/connection.py b/owrx/connection.py index bc6f589..2acfbd9 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -132,7 +132,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): "audio_compression", "fft_compression", "max_clients", - "frequency_display_precision", + "tuning_precision", ] def __init__(self, conn): diff --git a/owrx/controllers/settings/general.py b/owrx/controllers/settings/general.py index 84cd36f..b12ab4e 100644 --- a/owrx/controllers/settings/general.py +++ b/owrx/controllers/settings/general.py @@ -126,10 +126,12 @@ class GeneralSettingsController(SettingsFormController): ), Section( "Display settings", + # TODO: custom input for this? NumberInput( - "frequency_display_precision", - "Frequency display precision", - infotext="Number of decimal digits to show on the frequency display", + "tuning_precision", + "Tuning precision", + infotext="Specifies the precision of the frequency tuning display as an exponent of 10, in Hertz. " + + "Setting this to 1 means 10Hz precision, 2 means 100Hz precision, etc.", ), ), Section(