implement gain dialog with AGC option
This commit is contained in:
parent
86278ff44d
commit
d0d946e09f
22
htdocs/lib/settings/GainInput.js
Normal file
22
htdocs/lib/settings/GainInput.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
$.fn.gainInput = function() {
|
||||||
|
this.each(function() {
|
||||||
|
var $container = $(this);
|
||||||
|
|
||||||
|
var update = function(value){
|
||||||
|
$container.find('.option').hide();
|
||||||
|
$container.find('.option.' + value).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
var $select = $container.find('select');
|
||||||
|
$select.on('change', function(e) {
|
||||||
|
var value = $(e.target).val()
|
||||||
|
update(value);
|
||||||
|
if (value == 'auto') {
|
||||||
|
$input.val('auto');
|
||||||
|
} else {
|
||||||
|
$input
|
||||||
|
}
|
||||||
|
});
|
||||||
|
update($select.val());
|
||||||
|
});
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
$(function(){
|
$(function(){
|
||||||
$('.map-input').mapInput();
|
$('.map-input').mapInput();
|
||||||
$('.sdrdevice').sdrdevice();
|
|
||||||
$('.imageupload').imageUpload();
|
$('.imageupload').imageUpload();
|
||||||
$('.bookmarks').bookmarktable();
|
$('.bookmarks').bookmarktable();
|
||||||
$('.wsjt-decoding-depths').wsjtDecodingDepthsInput();
|
$('.wsjt-decoding-depths').wsjtDecodingDepthsInput();
|
||||||
$('#waterfall_scheme').waterfallDropdown();
|
$('#waterfall_scheme').waterfallDropdown();
|
||||||
|
$('#rf_gain').gainInput();
|
||||||
});
|
});
|
@ -150,6 +150,7 @@ class CompiledAssetsController(GzipMixin, ModificationAwareController):
|
|||||||
"lib/settings/BookmarkTable.js",
|
"lib/settings/BookmarkTable.js",
|
||||||
"lib/settings/WsjtDecodingDepthsInput.js",
|
"lib/settings/WsjtDecodingDepthsInput.js",
|
||||||
"lib/settings/WaterfallDropdown.js",
|
"lib/settings/WaterfallDropdown.js",
|
||||||
|
"lib/settings/GainInput.js",
|
||||||
"settings.js",
|
"settings.js",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
33
owrx/form/device.py
Normal file
33
owrx/form/device.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from owrx.form import Input
|
||||||
|
|
||||||
|
|
||||||
|
class GainInput(Input):
|
||||||
|
def render_input(self, value):
|
||||||
|
auto_mode = value is None or value == "auto"
|
||||||
|
|
||||||
|
return """
|
||||||
|
<div id="{id}">
|
||||||
|
<select class="{classes}" id="{id}-select" name="{id}-select">
|
||||||
|
<option value="auto" {auto_selected}>Enable hardware AGC</option>
|
||||||
|
<option value="manual" {manual_selected}>Specify manual gain</option>
|
||||||
|
</select>
|
||||||
|
<div class="option manual" style="display: none;">
|
||||||
|
<input type="number" id="{id}-manual" name="{id}-manual" value="{value}" class="{classes}" placeholder="Manual device gain" value="{value}" step="any">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
""".format(
|
||||||
|
id=self.id,
|
||||||
|
classes=self.input_classes(),
|
||||||
|
value=value,
|
||||||
|
label=self.label,
|
||||||
|
auto_selected="selected" if auto_mode else "",
|
||||||
|
manual_selected="" if auto_mode else "selected",
|
||||||
|
)
|
||||||
|
|
||||||
|
def parse(self, data):
|
||||||
|
select_id = "{id}-select".format(id=self.id)
|
||||||
|
if select_id in data:
|
||||||
|
input_id = "{id}-manual".format(id=self.id)
|
||||||
|
if data[select_id][0] == "manual" and input_id in data:
|
||||||
|
return {self.id: float(data[input_id][0])}
|
||||||
|
return {self.id: None}
|
@ -10,8 +10,9 @@ from abc import ABC, abstractmethod
|
|||||||
from owrx.command import CommandMapper
|
from owrx.command import CommandMapper
|
||||||
from owrx.socket import getAvailablePort
|
from owrx.socket import getAvailablePort
|
||||||
from owrx.property import PropertyStack, PropertyLayer
|
from owrx.property import PropertyStack, PropertyLayer
|
||||||
from owrx.form import Input, TextInput, NumberInput, CheckboxInput, FloatInput
|
from owrx.form import Input, TextInput, NumberInput, CheckboxInput
|
||||||
from owrx.form.converter import IntConverter, OptionalConverter, FloatConverter
|
from owrx.form.converter import IntConverter, OptionalConverter
|
||||||
|
from owrx.form.device import GainInput
|
||||||
from owrx.controllers.settings import Section
|
from owrx.controllers.settings import Section
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
@ -394,7 +395,7 @@ class SdrDeviceDescription(object):
|
|||||||
"Run background services on this device",
|
"Run background services on this device",
|
||||||
converter=OptionalConverter(defaultFormValue=True),
|
converter=OptionalConverter(defaultFormValue=True),
|
||||||
),
|
),
|
||||||
FloatInput("rf_gain", "Device gain", converter=OptionalConverter(FloatConverter())),
|
GainInput("rf_gain", "Device gain"),
|
||||||
]
|
]
|
||||||
|
|
||||||
def mergeInputs(self, *args):
|
def mergeInputs(self, *args):
|
||||||
|
Loading…
Reference in New Issue
Block a user