make AGC optional

This commit is contained in:
Jakob Ketterl 2021-02-23 20:02:38 +01:00
parent f9772faa6f
commit 631232fe7c
3 changed files with 18 additions and 9 deletions

View File

@ -4,8 +4,9 @@ from owrx.soapy import SoapySettings
class GainInput(Input):
def __init__(self, id, label, gain_stages=None):
def __init__(self, id, label, has_agc, gain_stages=None):
super().__init__(id, label)
self.has_agc = has_agc
self.gain_stages = gain_stages
def render_input(self, value):
@ -36,10 +37,10 @@ class GainInput(Input):
)
def render_options(self, value):
options = [
("auto", "Enable hardware AGC"),
("manual", "Specify manual gain"),
]
options = []
if self.has_agc:
options.append(("auto", "Enable hardware AGC"))
options.append(("manual", "Specify manual gain")),
if self.gain_stages:
options.append(("stages", "Specify gain stages individually"))
@ -55,7 +56,10 @@ class GainInput(Input):
)
def getMode(self, value):
if value is None or value == "auto":
if value is None:
return "auto" if self.has_agc else "manual"
if value == "auto":
return "auto"
try:
@ -105,7 +109,7 @@ class GainInput(Input):
select_id = "{id}-select".format(id=self.id)
if select_id in data:
if data[select_id][0] == "auto":
if self.has_agc and data[select_id][0] == "auto":
return {self.id: "auto"}
if data[select_id][0] == "manual":
input_id = "{id}-manual".format(id=self.id)

View File

@ -468,6 +468,7 @@ class SdrDeviceDescription(object):
return [
TextInput("name", "Device name"),
CheckboxInput("enabled", "Enable this device", converter=OptionalConverter(defaultFormValue=True)),
GainInput("rf_gain", "Device gain", self.hasAgc()),
NumberInput(
"ppm",
"Frequency correction",
@ -482,7 +483,6 @@ class SdrDeviceDescription(object):
"services",
"Run background services on this device",
),
GainInput("rf_gain", "Device gain"),
NumberInput(
"lfo_offset",
"Oscilator offset",
@ -500,6 +500,10 @@ class SdrDeviceDescription(object):
NumberInput("initial_squelch_level", "Initial squelch level", append="dBFS"),
]
def hasAgc(self):
# default is True since most devices have agc. override in subclasses if agc is not available
return True
def getMandatoryKeys(self):
return ["name", "enabled"]

View File

@ -7,4 +7,5 @@ class SddcSource(ConnectorSource):
class SddcDeviceDescription(ConnectorDeviceDescription):
pass
def hasAgc(self):
return False