From 631232fe7c98bf3d8c587441d3c00a4858daa514 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Tue, 23 Feb 2021 20:02:38 +0100 Subject: [PATCH] make AGC optional --- owrx/form/device.py | 18 +++++++++++------- owrx/source/__init__.py | 6 +++++- owrx/source/sddc.py | 3 ++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/owrx/form/device.py b/owrx/form/device.py index dfc1bc3a..0eb36511 100644 --- a/owrx/form/device.py +++ b/owrx/form/device.py @@ -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) diff --git a/owrx/source/__init__.py b/owrx/source/__init__.py index 0311453e..04a7a33e 100644 --- a/owrx/source/__init__.py +++ b/owrx/source/__init__.py @@ -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"] diff --git a/owrx/source/sddc.py b/owrx/source/sddc.py index e729116d..b9d89165 100644 --- a/owrx/source/sddc.py +++ b/owrx/source/sddc.py @@ -7,4 +7,5 @@ class SddcSource(ConnectorSource): class SddcDeviceDescription(ConnectorDeviceDescription): - pass + def hasAgc(self): + return False