From 0537e23e381dba4e5d8435d035f4baeba506609a Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 27 Feb 2021 23:14:41 +0100 Subject: [PATCH] make a more generic ExponentialInput and use that for the sample_rate input --- ...{FrequencyInput.js => ExponentialInput.js} | 6 +++--- htdocs/settings.js | 2 +- owrx/controllers/assets.py | 2 +- owrx/form/__init__.py | 20 ++++++++++--------- owrx/source/__init__.py | 11 +++++----- 5 files changed, 22 insertions(+), 19 deletions(-) rename htdocs/lib/settings/{FrequencyInput.js => ExponentialInput.js} (87%) diff --git a/htdocs/lib/settings/FrequencyInput.js b/htdocs/lib/settings/ExponentialInput.js similarity index 87% rename from htdocs/lib/settings/FrequencyInput.js rename to htdocs/lib/settings/ExponentialInput.js index dbc978e..824d797 100644 --- a/htdocs/lib/settings/FrequencyInput.js +++ b/htdocs/lib/settings/ExponentialInput.js @@ -1,4 +1,4 @@ -$.fn.frequencyInput = function() { +$.fn.exponentialInput = function() { var suffixes = { "K": 3, "M": 6, @@ -9,7 +9,7 @@ $.fn.frequencyInput = function() { this.each(function(){ var $group = $(this); var currentExponent = 0; - $input = $group.find('input'); + var $input = $group.find('input'); var setExponent = function() { var newExponent = parseInt($exponent.val()); @@ -26,7 +26,7 @@ $.fn.frequencyInput = function() { } }); - $exponent = $group.find('select.frequency-exponent'); + var $exponent = $group.find('select.exponent'); $exponent.on('change', setExponent); // calculate initial exponent diff --git a/htdocs/settings.js b/htdocs/settings.js index f3a2d44..3a071b5 100644 --- a/htdocs/settings.js +++ b/htdocs/settings.js @@ -7,5 +7,5 @@ $(function(){ $('#rf_gain').gainInput(); $('.optional-section').optionalSection(); $('#scheduler').schedulerInput(); - $('.frequency-input').frequencyInput(); + $('.exponential-input').exponentialInput(); }); \ No newline at end of file diff --git a/owrx/controllers/assets.py b/owrx/controllers/assets.py index d42ae23..5973baf 100644 --- a/owrx/controllers/assets.py +++ b/owrx/controllers/assets.py @@ -153,7 +153,7 @@ class CompiledAssetsController(GzipMixin, ModificationAwareController): "lib/settings/GainInput.js", "lib/settings/OptionalSection.js", "lib/settings/SchedulerInput.js", - "lib/settings/FrequencyInput.js", + "lib/settings/ExponentialInput.js", "settings.js", ], } diff --git a/owrx/form/__init__.py b/owrx/form/__init__.py index 0d2c201..3e828fe 100644 --- a/owrx/form/__init__.py +++ b/owrx/form/__init__.py @@ -321,9 +321,10 @@ class ModesInput(DropdownInput): super().__init__(id, label, options) -class FrequencyInput(Input): - def __init__(self, id, label, infotext=None): +class ExponentialInput(Input): + def __init__(self, id, label, unit, infotext=None): super().__init__(id, label, infotext=infotext) + self.unit = unit def defaultConverter(self): return IntConverter() @@ -337,21 +338,22 @@ class FrequencyInput(Input): def render_input(self, value): append = """
- + + + + +
""".format( id=self.id, disabled="disabled" if self.disabled else "", + unit=self.unit, ) return """ -
+
{input} {append}
diff --git a/owrx/source/__init__.py b/owrx/source/__init__.py index f1107ac..5a55f9c 100644 --- a/owrx/source/__init__.py +++ b/owrx/source/__init__.py @@ -11,7 +11,7 @@ from owrx.command import CommandMapper from owrx.socket import getAvailablePort from owrx.property import PropertyStack, PropertyLayer, PropertyFilter from owrx.property.filter import ByLambda -from owrx.form import Input, TextInput, NumberInput, CheckboxInput, ModesInput, FrequencyInput +from owrx.form import Input, TextInput, NumberInput, CheckboxInput, ModesInput, ExponentialInput from owrx.form.converter import OptionalConverter from owrx.form.device import GainInput, SchedulerInput, WaterfallLevelsInput from owrx.controllers.settings import Section @@ -494,17 +494,18 @@ class SdrDeviceDescription(object): "services", "Run background services on this device", ), - FrequencyInput( + ExponentialInput( "lfo_offset", "Oscilator offset", + "Hz", infotext="Use this when the actual receiving frequency differs from the frequency to be tuned on the" + " device.
Formula: Center frequency + oscillator offset = sdr tune frequency", ), WaterfallLevelsInput("waterfall_levels", "Waterfall levels"), SchedulerInput("scheduler", "Scheduler"), - FrequencyInput("center_freq", "Center frequency"), - NumberInput("samp_rate", "Sample rate", append="S/s"), - FrequencyInput("start_freq", "Initial frequency"), + ExponentialInput("center_freq", "Center frequency", "Hz"), + ExponentialInput("samp_rate", "Sample rate", "S/s"), + ExponentialInput("start_freq", "Initial frequency", "Hz"), ModesInput("start_mod", "Initial modulation"), NumberInput("initial_squelch_level", "Initial squelch level", append="dBFS"), ]