""".format(
id=self.id,
classes=self.input_classes(),
- value="0.0" if value is None else value,
+ value=display_value,
label=self.label,
options=self.render_options(value),
- stageoption=self.render_stage_option(value),
+ stageoption="" if self.gain_stages is None else self.render_stage_option(value),
)
def render_options(self, value):
@@ -41,9 +47,7 @@ class GainInput(Input):
"""
""".format(
- value=v[0],
- text=v[1],
- selected="selected" if mode == v[0] else ""
+ value=v[0], text=v[1], selected="selected" if mode == v[0] else ""
)
for v in options
)
@@ -55,7 +59,7 @@ class GainInput(Input):
try:
float(value)
return "manual"
- except ValueError:
+ except (ValueError, TypeError):
pass
return "stages"
@@ -75,7 +79,8 @@ class GainInput(Input):
"""
{stage}
-
+
""".format(
id=self.id,
@@ -93,7 +98,7 @@ class GainInput(Input):
if input_id in data:
return data[input_id][0]
else:
- return 0.0
+ return None
select_id = "{id}-select".format(id=self.id)
if select_id in data:
@@ -102,12 +107,14 @@ class GainInput(Input):
value = 0.0
if input_id in data:
try:
- value = float(float(data[input_id][0]))
+ value = float(data[input_id][0])
except ValueError:
pass
return {self.id: value}
- if data[select_id][0] == "stages":
+ if self.gain_stages is not None and data[select_id][0] == "stages":
settings_dict = [{s: getStageValue(s)} for s in self.gain_stages]
+ # filter out empty ones
+ settings_dict = [s for s in settings_dict if next(iter(s.values()))]
return {self.id: SoapySettings.encode(settings_dict)}
return {self.id: None}