From 5a7c12dfac59310b51bc637b562d07404f5f6059 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Wed, 31 Mar 2021 00:18:06 +0200 Subject: [PATCH] expose waterfall auto adjustment settings in web config --- config_webrx.py | 6 +++--- owrx/controllers/settings/general.py | 17 +++++++++++++++-- owrx/form/device.py | 22 ++++++++++++++++++++-- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/config_webrx.py b/config_webrx.py index 6262210..37e87a7 100644 --- a/config_webrx.py +++ b/config_webrx.py @@ -258,10 +258,10 @@ Note: if you experience audio underruns while CPU usage is 100%, you can: #waterfall_colors = [0x0000FF, 0x00FF00, 0xFF0000] ### Waterfall calibration -#waterfall_auto_levels = {"min": -88, "max": -20} # in dB +#waterfall_levels = {"min": -88, "max": -20} # in dB -waterfall_auto_levels = {"min": 3, "max": 10} -waterfall_auto_min_range = 50 +#waterfall_auto_levels = {"min": 3, "max": 10} +#waterfall_auto_min_range = 50 # Note: When the auto waterfall level button is clicked, the following happens: # [waterfall_levels.min] = [current_min_power_level] - [waterfall_auto_levels["min"]] diff --git a/owrx/controllers/settings/general.py b/owrx/controllers/settings/general.py index cae76c0..c1a2b36 100644 --- a/owrx/controllers/settings/general.py +++ b/owrx/controllers/settings/general.py @@ -12,7 +12,7 @@ from owrx.form import ( from owrx.form.converter import WaterfallColorsConverter, IntConverter from owrx.form.receiverid import ReceiverKeysConverter from owrx.form.gfx import AvatarInput, TopPhotoInput -from owrx.form.device import WaterfallLevelsInput +from owrx.form.device import WaterfallLevelsInput, WaterfallAutoLevelsInput from owrx.waterfall import WaterfallOptions import shutil import os @@ -104,6 +104,19 @@ class GeneralSettingsController(SettingsFormController): + "diagram.", ), WaterfallLevelsInput("waterfall_levels", "Waterfall levels"), + WaterfallAutoLevelsInput( + "waterfall_auto_levels", + "Automatic adjustment margins", + infotext="Specifies the upper and lower dynamic headroom that should be added when automatically " + + "adjusting waterfall colors", + ), + NumberInput( + "waterfall_auto_min_range", + "Automatic adjustment minimum range", + append="dB", + infotext="Minimum dynamic range the waterfall should cover after automatically adjusting " + + "waterfall colors", + ), ), Section( "Compression", @@ -130,7 +143,7 @@ class GeneralSettingsController(SettingsFormController): "tuning_precision", "Tuning precision", options=[Option(str(i), "{} Hz".format(10 ** i)) for i in range(0, 6)], - converter=IntConverter() + converter=IntConverter(), ), ), Section( diff --git a/owrx/form/device.py b/owrx/form/device.py index f7a01ac..68d3d45 100644 --- a/owrx/form/device.py +++ b/owrx/form/device.py @@ -351,6 +351,9 @@ class SchedulerInput(Input): class WaterfallLevelsInput(Input): + def __init__(self, id, label, infotext=None): + super().__init__(id, label, infotext=infotext) + def render_input_group(self, value, errors): return """
@@ -364,6 +367,12 @@ class WaterfallLevelsInput(Input): errors=self.render_errors(errors), ) + def getUnit(self): + return "dBFS" + + def getFields(self): + return {"min": "Minimum", "max": "Maximum"} + def render_input(self, value, errors): return "".join( """ @@ -372,7 +381,7 @@ class WaterfallLevelsInput(Input):
- dBFS + {unit}
@@ -383,8 +392,9 @@ class WaterfallLevelsInput(Input): value=value[name] if value and name in value else "0", classes=self.input_classes(errors), disabled="disabled" if self.disabled else "", + unit=self.getUnit(), ) - for name, label in [("min", "Minimum"), ("max", "Maximum")] + for name, label in self.getFields().items() ) def parse(self, data): @@ -398,3 +408,11 @@ class WaterfallLevelsInput(Input): return {self.id: {k: v for name in ["min", "max"] for k, v in getValue(name).items()}} except KeyError: return {} + + +class WaterfallAutoLevelsInput(WaterfallLevelsInput): + def getUnit(self): + return "dB" + + def getFields(self): + return {"min": "Lower", "max": "Upper"}