change display precision behavior to reference Hertz

This commit is contained in:
Jakob Ketterl 2021-03-01 01:19:06 +01:00
parent 6bd47cf914
commit d81f0ae96c
7 changed files with 29 additions and 16 deletions

View File

@ -353,9 +353,9 @@ DemodulatorPanel.prototype.setMouseFrequency = function(freq) {
this.mouseFrequencyDisplay.setFrequency(freq); this.mouseFrequencyDisplay.setFrequency(freq);
}; };
DemodulatorPanel.prototype.setFrequencyPrecision = function(precision) { DemodulatorPanel.prototype.setTuningPrecision = function(precision) {
this.tuneableFrequencyDisplay.setFrequencyPrecision(precision); this.tuneableFrequencyDisplay.setTuningPrecision(precision);
this.mouseFrequencyDisplay.setFrequencyPrecision(precision); this.mouseFrequencyDisplay.setTuningPrecision(precision);
}; };
$.fn.demodulatorPanel = function(){ $.fn.demodulatorPanel = function(){

View File

@ -7,7 +7,7 @@ function FrequencyDisplay(element) {
}; };
this.element = $(element); this.element = $(element);
this.digits = []; this.digits = [];
this.precision = 4; this.precision = 2;
this.setupElements(); this.setupElements();
this.setFrequency(0); this.setFrequency(0);
} }
@ -31,9 +31,10 @@ FrequencyDisplay.prototype.setFrequency = function(freq) {
this.frequency = freq; this.frequency = freq;
this.exponent = Math.floor(Math.log10(this.frequency) / 3) * 3; 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( var formatted = (freq / 10 ** this.exponent).toLocaleString(
undefined, undefined,
{maximumFractionDigits: this.precision, minimumFractionDigits: this.precision} {maximumFractionDigits: digits, minimumFractionDigits: digits}
); );
var children = this.digitContainer.children(); var children = this.digitContainer.children();
for (var i = 0; i < formatted.length; i++) { for (var i = 0; i < formatted.length; i++) {
@ -55,8 +56,8 @@ FrequencyDisplay.prototype.setFrequency = function(freq) {
this.unitContainer.text(' ' + this.getPrefix() + 'Hz'); this.unitContainer.text(' ' + this.getPrefix() + 'Hz');
}; };
FrequencyDisplay.prototype.setFrequencyPrecision = function(precision) { FrequencyDisplay.prototype.setTuningPrecision = function(precision) {
if (!precision) return; if (typeof(precision) == 'undefined') return;
this.precision = precision; this.precision = precision;
this.setFrequency(this.frequency); this.setFrequency(this.frequency);
}; };

View File

@ -770,8 +770,8 @@ function on_ws_recv(evt) {
waterfall_clear(); waterfall_clear();
} }
if ('frequency_display_precision' in config) if ('tuning_precision' in config)
$('#openwebrx-panel-receiver').demodulatorPanel().setFrequencyPrecision(config['frequency_display_precision']); $('#openwebrx-panel-receiver').demodulatorPanel().setTuningPrecision(config['tuning_precision']);
break; break;
case "secondary_config": case "secondary_config":

View File

@ -2,7 +2,7 @@ from owrx.property import PropertyLayer
defaultConfig = PropertyLayer( defaultConfig = PropertyLayer(
version=5, version=6,
max_clients=20, max_clients=20,
receiver_name="[Callsign]", receiver_name="[Callsign]",
receiver_location="Budapest, Hungary", receiver_location="Budapest, Hungary",
@ -25,7 +25,7 @@ defaultConfig = PropertyLayer(
waterfall_scheme="GoogleTurboWaterfall", waterfall_scheme="GoogleTurboWaterfall",
waterfall_levels=PropertyLayer(min=-88, max=-20), waterfall_levels=PropertyLayer(min=-88, max=-20),
waterfall_auto_level_margin=PropertyLayer(min=3, max=10, min_range=50), waterfall_auto_level_margin=PropertyLayer(min=3, max=10, min_range=50),
frequency_display_precision=4, tuning_precision=2,
squelch_auto_margin=10, squelch_auto_margin=10,
nmux_memory=50, nmux_memory=50,
google_maps_api_key="", google_maps_api_key="",

View File

@ -89,13 +89,23 @@ class ConfigMigratorVersion4(ConfigMigrator):
config["version"] = 5 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): class Migrator(object):
currentVersion = 5 currentVersion = 6
migrators = { migrators = {
1: ConfigMigratorVersion1(), 1: ConfigMigratorVersion1(),
2: ConfigMigratorVersion2(), 2: ConfigMigratorVersion2(),
3: ConfigMigratorVersion3(), 3: ConfigMigratorVersion3(),
4: ConfigMigratorVersion4(), 4: ConfigMigratorVersion4(),
5: ConfigMigratorVersion5(),
} }
@staticmethod @staticmethod

View File

@ -132,7 +132,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
"audio_compression", "audio_compression",
"fft_compression", "fft_compression",
"max_clients", "max_clients",
"frequency_display_precision", "tuning_precision",
] ]
def __init__(self, conn): def __init__(self, conn):

View File

@ -126,10 +126,12 @@ class GeneralSettingsController(SettingsFormController):
), ),
Section( Section(
"Display settings", "Display settings",
# TODO: custom input for this?
NumberInput( NumberInput(
"frequency_display_precision", "tuning_precision",
"Frequency display precision", "Tuning precision",
infotext="Number of decimal digits to show on the frequency display", 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( Section(