Added ability to jump center_frequency by right-clicking arrow buttons.

This commit is contained in:
Marat Fayzullin 2023-05-20 15:43:56 -04:00
parent 5488c29807
commit c77d3c24a4
4 changed files with 22 additions and 2 deletions

View File

@ -45,10 +45,10 @@
<div class="openwebrx-waterfall-container">
<div id="openwebrx-frequency-container">
<div id="openwebrx-bookmarks-container" style="z-index:2;">
<div class="openwebrx-button openwebrx-round-button openwebrx-tune-button" style="position:absolute;top:30%;left:0;z-index:3;" title="Tune down" onclick="tuneBySteps(-1);">
<div class="openwebrx-button openwebrx-round-button openwebrx-tune-button" style="position:absolute;top:30%;left:0;z-index:3;" title="Tune down" onclick="tuneBySteps(-1);" oncontextmenu="jumpBySteps(-1);return false;">
<svg viewBox="0 0 80 80"><use xlink:href="static/gfx/svg-defs.svg#left"></use></svg>
</div>
<div class="openwebrx-button openwebrx-round-button openwebrx-tune-button" style="position:absolute;top:30%;right:0;z-index:3;" title="Tune up" onclick="tuneBySteps(1);">
<div class="openwebrx-button openwebrx-round-button openwebrx-tune-button" style="position:absolute;top:30%;right:0;z-index:3;" title="Tune up" onclick="tuneBySteps(1);" oncontextmenu="jumpBySteps(1);return false;">
<svg viewBox="0 0 80 80"><use xlink:href="static/gfx/svg-defs.svg#right"></use></svg>
</div>
</div>

View File

@ -151,6 +151,17 @@ function tuneBySteps(steps) {
}
}
function jumpBySteps(steps) {
steps = Math.round(steps);
if (steps != 0) {
var f = center_freq + steps * bandwidth / 4;
ws.send(JSON.stringify({
"type": "setfrequency",
"params": { "frequency": f }
}));
}
}
var waterfall_min_level;
var waterfall_max_level;
var waterfall_min_level_default;

View File

@ -295,6 +295,10 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
profile = message["params"]["profile"].split("|")
self.setSdr(profile[0])
self.sdr.activateProfile(profile[1])
elif message["type"] == "setfrequency":
if "params" in message and "frequency" in message["params"]:
frequency = message["params"]["frequency"]
self.sdr.setCenterFreq(frequency)
elif message["type"] == "connectionproperties":
if "params" in message:
self.connectionProperties = message["params"]

View File

@ -231,6 +231,11 @@ class SdrSource(ABC):
except KeyError:
logger.warning("invalid profile %s for sdr %s. ignoring", profile_id, self.getId())
def setCenterFreq(self, frequency):
if "center_freq" in self.sdrProps:
self.sdrProps["center_freq"] = frequency
self.wireEvents()
def getId(self):
return self.id