From d1dfde7652eb4edc727c5582a2b29176529442de Mon Sep 17 00:00:00 2001 From: siinus Date: Thu, 3 Feb 2022 07:41:45 +0200 Subject: [PATCH] Add projector lamp indicators --- nginx/default | 13 ++++++++----- www/index.html | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/nginx/default b/nginx/default index d32b58a..faa90d7 100644 --- a/nginx/default +++ b/nginx/default @@ -91,12 +91,15 @@ server { location /projektor/ { proxy_pass http://127.0.0.1:6999/; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Scheme $scheme; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + location /projector/ { + proxy_pass http://projektor.kontor.lapikud.ee/cgi-bin/; } } diff --git a/www/index.html b/www/index.html index 335c238..c9d425b 100644 --- a/www/index.html +++ b/www/index.html @@ -28,6 +28,10 @@ color: black; } + .center { + text-align: center; + } + .button-grid { display: grid; grid-auto-columns: 1fr; @@ -136,6 +140,7 @@ +

Sisendi juhtimine

@@ -162,6 +167,30 @@ send_mode(event.target.value); }); } + + function query_projector(request_string, closure) { + const xhr = new XMLHttpRequest(); + xhr.open('GET', '/projector/pjctrl.cgi.elf?D=' + request_string, true) + xhr.overrideMimeType('text/plain'); + xhr.onreadystatechange = function () { + if (xhr.readyState === 4) { + let data = JSON.parse(xhr.response.replace(',]', ']')); + if ((data[0] & 0x80) === 0) { + closure(data); + } + } + }; + xhr.send(); + } + + query_projector('%07%03%96%00%00%02%00%01H', function (data) { + const used = ((data[10] << 24) | (data[9] << 16) | (data[8] << 8) | data[7]) / 3600; + document.getElementById('projector_lamp_hours').innerText = + 'Lambi läbisõit ' + Math.round(used) + 'h. '; + }); + query_projector('%07%03%96%00%00%02%00%04H', function (data) { + document.getElementById('projector_lamp_remaining').innerText = 'Alles jäänud ' + data[7] + '%'; + });