expose waterfall auto adjustment settings in web config

This commit is contained in:
Jakob Ketterl 2021-03-31 00:18:06 +02:00
parent 170b720e48
commit 5a7c12dfac
3 changed files with 38 additions and 7 deletions

View File

@ -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"]]

View File

@ -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(

View File

@ -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 """
<div class="row {rowclass}" id="{id}">
@ -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):
<div class="col-9 input-group input-group-sm">
<input type="number" step="any" class="{classes}" name="{id}-{name}" value="{value}" {disabled}>
<div class="input-group-append">
<span class="input-group-text">dBFS</span>
<span class="input-group-text">{unit}</span>
</div>
</div>
</div>
@ -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"}