From bb1b561c476837e39998f29f0eb197c5887b954c Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 26 Apr 2020 16:58:31 +0200 Subject: [PATCH] fully-automatic mode panel generation --- htdocs/index.html | 43 +------------------------------------------ htdocs/lib/Modes.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ htdocs/openwebrx.js | 2 +- owrx/connection.py | 1 + owrx/modes.py | 28 ++++++++++++++++++++-------- 5 files changed, 68 insertions(+), 51 deletions(-) diff --git a/htdocs/index.html b/htdocs/index.html index 9027ef1..f6d08ac 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -166,48 +166,7 @@ -
-
FM
-
AM
-
LSB
-
USB
-
CW
-
-
- - - - -
-
-
DIG
- -
+
diff --git a/htdocs/lib/Modes.js b/htdocs/lib/Modes.js index ea7e8b7..dda89f2 100644 --- a/htdocs/lib/Modes.js +++ b/htdocs/lib/Modes.js @@ -3,19 +3,64 @@ var Modes = { features: {}, setModes:function(json){ this.modes = json.map(function(m){ return new Mode(m); }); + this.updateModePanel(); }, setFeatures:function(features){ this.features = features; + this.updateModePanel(); }, findByModulation:function(modulation){ matches = this.modes.filter(function(m) { return m.modulation === modulation; }); if (matches.length) return matches[0] + }, + updateModePanel:function() { + var available = this.modes.filter(function(m){ return m.isAvailable(); }); + var normalModes = available.filter(function(m){ return !m.digimode; }); + var digiModes = available.filter(function(m){ return m.digimode; }); + + var index = 0; + var arrayLength = normalModes.length; + var chunks = []; + + + for (index = 0; index < arrayLength; index += 5) { + chunks.push(normalModes.slice(index, index + 5)); + } + + var html = [] + + html.push.apply(html, chunks.map(function(chunk){ + return $( + '
' + + chunk.map(function(m){ + return '
' + + m.name + '
'; + }).join('') + + '
'); + })); + + html.push($( + '
' + + '
DIG
' + + '' + + '
' + )); + + $("#openwebrx-panel-receiver").find(".openwebrx-modes").html(html); } } var Mode = function(json){ this.modulation = json.modulation; this.name = json.name; + this.digimode = json.digimode; this.requirements = json.requirements; }; diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 41c91a4..9798d19 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1123,6 +1123,7 @@ function on_ws_recv(evt) { break; case "features": var features = json['value']; + Modes.setFeatures(features); for (var feature in features) { if (features.hasOwnProperty(feature)) { $('[data-feature="' + feature + '"]')[features[feature] ? "show" : "hide"](); @@ -1179,7 +1180,6 @@ function on_ws_recv(evt) { break; case 'modes': Modes.setModes(json['value']); - console.info(Modes); break; default: console.warn('received message of unknown type: ' + json['type']); diff --git a/owrx/connection.py b/owrx/connection.py index 4367e55..3d54ee8 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -353,6 +353,7 @@ class OpenWebRxReceiverClient(Client): self.send({"type": "modes", "value": [{ "modulation": m.modulation, "name": m.name, + "digimode": m.digimode, "requirements": m.requirements } for m in modes]}) diff --git a/owrx/modes.py b/owrx/modes.py index b0721fc..d2d890a 100644 --- a/owrx/modes.py +++ b/owrx/modes.py @@ -3,9 +3,10 @@ from functools import reduce class Mode(object): - def __init__(self, modulation, name, requirements=None, service=False): + def __init__(self, modulation, name, requirements=None, service=False, digimode=False): self.modulation = modulation self.name = name + self.digimode = digimode self.requirements = requirements if requirements is not None else [] self.service = service @@ -21,13 +22,24 @@ class Mode(object): class Modes(object): mappings = [ - Mode("ft8", "FT8", ["wsjt-x"], True), - Mode("ft4", "FT4", ["wsjt-x"], True), - Mode("jt65", "JT65", ["wsjt-x"], True), - Mode("jt9", "JT9", ["wsjt-x"], True), - Mode("wspr", "WSPR", ["wsjt-x"], True), - Mode("packet", "Packet", ["packet"], True), - Mode("js8", "JS8Call", ["js8call"], True), + Mode("nfm", "FM"), + Mode("am", "AM"), + Mode("lsb", "LSB"), + Mode("usb", "USB"), + Mode("cw", "CW"), + Mode("dmr", "DMR", requirements=["digital_voice_digiham"]), + Mode("dstar", "DStar", requirements=["digital_voice_dsd"]), + Mode("nxdn", "NXDN", requirements=["digital_voice_dsd"]), + Mode("ysf", "YSF", requirements=["digital_voice_digiham"]), + Mode("bpsk31", "BPSK31", digimode=True), + Mode("bpsk63", "BPSK63", digimode=True), + Mode("ft8", "FT8", requirements=["wsjt-x"], service=True, digimode=True), + Mode("ft4", "FT4", requirements=["wsjt-x"], service=True, digimode=True), + Mode("jt65", "JT65", requirements=["wsjt-x"], service=True, digimode=True), + Mode("jt9", "JT9", requirements=["wsjt-x"], service=True, digimode=True), + Mode("wspr", "WSPR", requirements=["wsjt-x"], service=True, digimode=True), + Mode("packet", "Packet", ["packet"], service=True, digimode=True), + Mode("js8", "JS8Call", requirements=["js8call"], service=True, digimode=True), ] @staticmethod