make AGC optional
This commit is contained in:
parent
f9772faa6f
commit
631232fe7c
@ -4,8 +4,9 @@ from owrx.soapy import SoapySettings
|
|||||||
|
|
||||||
|
|
||||||
class GainInput(Input):
|
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)
|
super().__init__(id, label)
|
||||||
|
self.has_agc = has_agc
|
||||||
self.gain_stages = gain_stages
|
self.gain_stages = gain_stages
|
||||||
|
|
||||||
def render_input(self, value):
|
def render_input(self, value):
|
||||||
@ -36,10 +37,10 @@ class GainInput(Input):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def render_options(self, value):
|
def render_options(self, value):
|
||||||
options = [
|
options = []
|
||||||
("auto", "Enable hardware AGC"),
|
if self.has_agc:
|
||||||
("manual", "Specify manual gain"),
|
options.append(("auto", "Enable hardware AGC"))
|
||||||
]
|
options.append(("manual", "Specify manual gain")),
|
||||||
if self.gain_stages:
|
if self.gain_stages:
|
||||||
options.append(("stages", "Specify gain stages individually"))
|
options.append(("stages", "Specify gain stages individually"))
|
||||||
|
|
||||||
@ -55,7 +56,10 @@ class GainInput(Input):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def getMode(self, value):
|
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"
|
return "auto"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -105,7 +109,7 @@ class GainInput(Input):
|
|||||||
|
|
||||||
select_id = "{id}-select".format(id=self.id)
|
select_id = "{id}-select".format(id=self.id)
|
||||||
if select_id in data:
|
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"}
|
return {self.id: "auto"}
|
||||||
if data[select_id][0] == "manual":
|
if data[select_id][0] == "manual":
|
||||||
input_id = "{id}-manual".format(id=self.id)
|
input_id = "{id}-manual".format(id=self.id)
|
||||||
|
@ -468,6 +468,7 @@ class SdrDeviceDescription(object):
|
|||||||
return [
|
return [
|
||||||
TextInput("name", "Device name"),
|
TextInput("name", "Device name"),
|
||||||
CheckboxInput("enabled", "Enable this device", converter=OptionalConverter(defaultFormValue=True)),
|
CheckboxInput("enabled", "Enable this device", converter=OptionalConverter(defaultFormValue=True)),
|
||||||
|
GainInput("rf_gain", "Device gain", self.hasAgc()),
|
||||||
NumberInput(
|
NumberInput(
|
||||||
"ppm",
|
"ppm",
|
||||||
"Frequency correction",
|
"Frequency correction",
|
||||||
@ -482,7 +483,6 @@ class SdrDeviceDescription(object):
|
|||||||
"services",
|
"services",
|
||||||
"Run background services on this device",
|
"Run background services on this device",
|
||||||
),
|
),
|
||||||
GainInput("rf_gain", "Device gain"),
|
|
||||||
NumberInput(
|
NumberInput(
|
||||||
"lfo_offset",
|
"lfo_offset",
|
||||||
"Oscilator offset",
|
"Oscilator offset",
|
||||||
@ -500,6 +500,10 @@ class SdrDeviceDescription(object):
|
|||||||
NumberInput("initial_squelch_level", "Initial squelch level", append="dBFS"),
|
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):
|
def getMandatoryKeys(self):
|
||||||
return ["name", "enabled"]
|
return ["name", "enabled"]
|
||||||
|
|
||||||
|
@ -7,4 +7,5 @@ class SddcSource(ConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class SddcDeviceDescription(ConnectorDeviceDescription):
|
class SddcDeviceDescription(ConnectorDeviceDescription):
|
||||||
pass
|
def hasAgc(self):
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user