diff --git a/index.js b/index.js index af9ab40..6c1e710 100755 --- a/index.js +++ b/index.js @@ -159,11 +159,26 @@ app.post("/stopprojector", (req, res) => { res.json({ status: 'ok' }); }); +function projectorNumberToText(number) { + switch (status1) { + case '01': + return 'On'; + case '02': + return 'Starting/Stopping'; + case '03': + return 'Starting/Stopping'; + case '04': + return 'Off'; + default: + return 'Unknown'; + } +} + app.get("/projectorstatus", async (req, res) => { const res1 = await fetch('http://192.168.1.93/api/v01/control/escvp21?cmd=PWR?'); - const status1 = await res1.text(); + const status1 = projectorNumberToText(await res1.text()); const res2 = await fetch('http://192.168.1.67/api/v01/control/escvp21?cmd=PWR?'); - const status2 = await res2.text(); + const status2 = projectorNumberToText(await res2.text()); res.json({ status1, status2 }); }); diff --git a/public/index.html b/public/index.html index 259e1e4..3aa865e 100755 --- a/public/index.html +++ b/public/index.html @@ -29,48 +29,66 @@ +
+

Background video

Currently selected video:
+
+

Overlay video

Currently selected video:
+
+

Delete videos

+
+

Projector status 1

+
+

Projector status 2

+
+

Relay 1

- - + + + +

Relay 2

- - + + + +

Relay 3

- - + + + +

Relay 4

- - - + + + diff --git a/public/main.js b/public/main.js index a37a025..072e1a4 100755 --- a/public/main.js +++ b/public/main.js @@ -44,6 +44,12 @@ async function main() { status1.textContent = status.status1; status2.textContent = status.status2; + const selectedvideoDiv = document.getElementById('selectedvideo'); + const overlayvideoDiv = document.getElementById('overlayvideo'); + + selectedvideoDiv.innerText = await (await fetch("/selectedvideo")).text(); + overlayvideoDiv.innerText = await (await fetch("/overlayvideo")).text(); + const relay1Div = document.getElementById('relay1'); const relay2Div = document.getElementById('relay2'); const relay3Div = document.getElementById('relay3'); @@ -53,12 +59,6 @@ async function main() { relay2Div.innerText = await (await fetch("https://steady.bpfilip.dk/relay/status/13")).text(); relay3Div.innerText = await (await fetch("https://steady.bpfilip.dk/relay/status/6")).text(); relay4Div.innerText = await (await fetch("https://steady.bpfilip.dk/relay/status/5")).text(); - - const selectedvideoDiv = document.getElementById('selectedvideo'); - const overlayvideoDiv = document.getElementById('overlayvideo'); - - selectedvideoDiv.innerText = await (await fetch("/selectedvideo")).text(); - overlayvideoDiv.innerText = await (await fetch("/overlayvideo")).text(); } main();