Skip to content

Commit d45157d

Browse files
committed
add actions to set the frequency absolute or relative
1 parent 78bc99b commit d45157d

5 files changed

Lines changed: 489 additions & 130 deletions

File tree

manifest.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,30 @@
223223
"PropertyInspectorPath": "pi/setsplitvfo.html",
224224
"Controllers": ["Keypad"],
225225
"States": [{ "Title": "Split" }]
226+
},
227+
{
228+
"Name": "Set Frequency",
229+
"UUID": "com.thecodingflow.hamlibplugin.setfrequency",
230+
"Tooltip": "Set the frequency for a certain VFO",
231+
"Icon": "icons/radio_light",
232+
"DisableAutomaticStates": false,
233+
"VisibleInActionsList": true,
234+
"SupportedInMultiActions": true,
235+
"PropertyInspectorPath": "pi/setfrequency.html",
236+
"Controllers": ["Keypad"],
237+
"States": [{ "Title": "Freq" }]
238+
},
239+
{
240+
"Name": "Set Frequency (rel)",
241+
"UUID": "com.thecodingflow.hamlibplugin.setfrequencyrelative",
242+
"Tooltip": "Set the frequency relative to another VFO",
243+
"Icon": "icons/radio_light",
244+
"DisableAutomaticStates": false,
245+
"VisibleInActionsList": true,
246+
"SupportedInMultiActions": true,
247+
"PropertyInspectorPath": "pi/setfrequencyrelative.html",
248+
"Controllers": ["Keypad"],
249+
"States": [{ "Title": "Freq Rel" }]
226250
}
227251
],
228252
"OS": [{ "Platform": "linux" }],

pi/setfrequency.html

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<script>
5+
let update = () => {};
6+
let vfoSetting = "";
7+
let frequencySetting = "";
8+
9+
function connectOpenActionSocket(
10+
inPort,
11+
inPropertyInspectorUUID,
12+
inRegisterEvent,
13+
inInfo,
14+
inActionInfo,
15+
) {
16+
const websocket = new WebSocket("ws://localhost:" + inPort);
17+
inActionInfo = JSON.parse(inActionInfo);
18+
websocket.onopen = () => {
19+
websocket.send(
20+
JSON.stringify({
21+
event: inRegisterEvent,
22+
uuid: inPropertyInspectorUUID,
23+
}),
24+
);
25+
};
26+
27+
vfoSetting = inActionInfo.payload.settings.vfo ?? "";
28+
frequencySetting =
29+
inActionInfo.payload.settings.frequency ?? "";
30+
31+
websocket.onmessage = (event) => {
32+
const data = JSON.parse(event.data);
33+
if (data.event == "didReceiveSettings") {
34+
vfoSetting = data.payload.settings.vfo ?? "";
35+
frequencySetting =
36+
data.payload.settings.frequency ?? "";
37+
}
38+
if (data.event == "sendToPropertyInspector") {
39+
// TODO: receive available vfos from the plugin
40+
}
41+
};
42+
43+
const vfoElement = document.getElementById("vfo");
44+
vfoElement.value = inActionInfo.payload.settings.vfo ?? "";
45+
46+
const frequencyElement = document.getElementById("frequency");
47+
frequencyElement.value =
48+
inActionInfo.payload.settings.frequency ?? "";
49+
50+
update = () => {
51+
websocket.send(
52+
JSON.stringify({
53+
event: "setSettings",
54+
context: inActionInfo.context,
55+
payload: {
56+
vfo: vfoElement.value || "",
57+
frequency: frequencyElement.value || "",
58+
},
59+
}),
60+
);
61+
};
62+
}
63+
64+
const connectElgatoStreamDeckSocket = connectOpenActionSocket;
65+
</script>
66+
67+
<style>
68+
* {
69+
font-family: system-ui, sans-serif;
70+
font-size: 16px;
71+
color: oklch(92.2% 0 0);
72+
}
73+
body {
74+
margin: 16px;
75+
background-color: oklch(26.9% 0 0);
76+
}
77+
label {
78+
margin-right: 4px;
79+
}
80+
input {
81+
margin: 4px;
82+
padding: 4px;
83+
background-color: oklch(37.1% 0 0);
84+
border: 1px solid oklch(43.9% 0 0);
85+
border-radius: 8px;
86+
}
87+
</style>
88+
</head>
89+
90+
<body>
91+
<div>
92+
<label for="vfo">VFO:</label>
93+
<!-- should be a combo box with all VFOs -->
94+
<input id="vfo" oninput="update()" type="text" />
95+
<br />
96+
<label for="frequency">Frequency (Hz):</label>
97+
<input id="frequency" oninput="update()" type="text" />
98+
</div>
99+
</body>
100+
</html>

pi/setfrequencyrelative.html

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<script>
5+
let update = () => {};
6+
let vfoSetting = "";
7+
let offsetSetting = "";
8+
let refvfoSetting = "";
9+
10+
function connectOpenActionSocket(
11+
inPort,
12+
inPropertyInspectorUUID,
13+
inRegisterEvent,
14+
inInfo,
15+
inActionInfo,
16+
) {
17+
const websocket = new WebSocket("ws://localhost:" + inPort);
18+
inActionInfo = JSON.parse(inActionInfo);
19+
websocket.onopen = () => {
20+
websocket.send(
21+
JSON.stringify({
22+
event: inRegisterEvent,
23+
uuid: inPropertyInspectorUUID,
24+
}),
25+
);
26+
};
27+
28+
vfoSetting = inActionInfo.payload.settings.vfo ?? "";
29+
offsetSetting = inActionInfo.payload.settings.offset ?? "";
30+
refvfoSetting = inActionInfo.payload.settings.refvfo ?? "";
31+
32+
websocket.onmessage = (event) => {
33+
const data = JSON.parse(event.data);
34+
if (data.event == "didReceiveSettings") {
35+
vfoSetting = data.payload.settings.vfo ?? "";
36+
offsetSetting = data.payload.settings.offset ?? "";
37+
refvfoSetting = data.payload.settings.refvfo ?? "";
38+
}
39+
if (data.event == "sendToPropertyInspector") {
40+
// TODO: receive available vfos from the plugin
41+
}
42+
};
43+
44+
const vfoElement = document.getElementById("vfo");
45+
vfoElement.value = inActionInfo.payload.settings.vfo ?? "";
46+
47+
const offsetElement = document.getElementById("offset");
48+
offsetElement.value =
49+
inActionInfo.payload.settings.offset ?? "";
50+
51+
const refvfoElement = document.getElementById("refvfo");
52+
refvfoElement.value =
53+
inActionInfo.payload.settings.refvfo ?? "";
54+
55+
update = () => {
56+
websocket.send(
57+
JSON.stringify({
58+
event: "setSettings",
59+
context: inActionInfo.context,
60+
payload: {
61+
vfo: vfoElement.value || "",
62+
offset: offsetElement.value || "",
63+
refvfo: refvfoElement.value || "",
64+
},
65+
}),
66+
);
67+
};
68+
}
69+
70+
const connectElgatoStreamDeckSocket = connectOpenActionSocket;
71+
</script>
72+
73+
<style>
74+
* {
75+
font-family: system-ui, sans-serif;
76+
font-size: 16px;
77+
color: oklch(92.2% 0 0);
78+
}
79+
body {
80+
margin: 16px;
81+
background-color: oklch(26.9% 0 0);
82+
}
83+
label {
84+
margin-right: 4px;
85+
}
86+
input {
87+
margin: 4px;
88+
padding: 4px;
89+
background-color: oklch(37.1% 0 0);
90+
border: 1px solid oklch(43.9% 0 0);
91+
border-radius: 8px;
92+
}
93+
</style>
94+
</head>
95+
96+
<body>
97+
<div>
98+
<label for="vfo">VFO:</label>
99+
<!-- should be a combo box with all VFOs -->
100+
<input id="vfo" oninput="update()" type="text" />
101+
<br />
102+
<label for="offset">Offset (Hz):</label>
103+
<input id="offset" oninput="update()" type="text" />
104+
<br />
105+
<label for="refvfo">Reference VFO:</label>
106+
<!-- should be a combo box with all VFOs -->
107+
<input id="refvfo" oninput="update()" type="text" />
108+
</div>
109+
</body>
110+
</html>

0 commit comments

Comments
 (0)