diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-04-08 11:34:28 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-04-08 11:34:28 +0200 |
commit | dcdb47f24057f42b600856064ab2e45ac252f9dd (patch) | |
tree | d39f8e4f7c768fc6b94a7a7945965eba8e322be4 /ui | |
parent | 8d2f3af3d5b88ac5b7186b23c4231d9cf00f3616 (diff) |
fix light value range + send allState message on socket connect
Diffstat (limited to 'ui')
-rw-r--r-- | ui/index.html | 2 | ||||
-rw-r--r-- | ui/js/api.js | 3 | ||||
-rw-r--r-- | ui/js/socket.js | 4 | ||||
-rw-r--r-- | ui/websocket_output.json | 5 |
4 files changed, 10 insertions, 4 deletions
diff --git a/ui/index.html b/ui/index.html index e93a711..0da8172 100644 --- a/ui/index.html +++ b/ui/index.html @@ -55,7 +55,7 @@ <details open> <summary>Verlichting</summary> <div class="light_controls"> - <input id="lightsInput" type="range" min="0" max="100" step="1" value="0" oninput="api.msg.send.lights(this)"/> + <input id="lightsInput" type="range" min="0" max="100" step="10" value="0" oninput="api.msg.send.lights(this)"/> <div>Felheid: <span id="lightsValue">??</span>%</div> </div> </details> diff --git a/ui/js/api.js b/ui/js/api.js index 3a08c8d..7f11c17 100644 --- a/ui/js/api.js +++ b/ui/js/api.js @@ -50,6 +50,7 @@ const api = { }, msg: { send: { + allState: () => send({ type: 'allState' }), helloWorld: () => send({ type: 'helloWorld' }), barrier: el => { var open = el.value == "true"; // string to boolean @@ -63,7 +64,7 @@ const api = { }, lights: el => { var value = Number(el.value); - send({ type: 'lights', value }); + send({ type: 'lights', value: value / 10 }); api.update.lights(value); }, matrix: el => { diff --git a/ui/js/socket.js b/ui/js/socket.js index 0203b43..d352ab9 100644 --- a/ui/js/socket.js +++ b/ui/js/socket.js @@ -21,3 +21,7 @@ ws.addEventListener("close", () => { console.error("WebSocket closed!"); }); +ws.addEventListener("open", _ev => { + api.msg.send.allState(); +}); + diff --git a/ui/websocket_output.json b/ui/websocket_output.json index 6b6deef..071e37b 100644 --- a/ui/websocket_output.json +++ b/ui/websocket_output.json @@ -8,9 +8,10 @@ { "type": "matrix", "state": "road_closed" } { "type": "matrix", "state": "disabled" } { "type": "lights", "value": 0 } -{ "type": "lights", "value": 12 } -{ "type": "lights", "value": 100 } +{ "type": "lights", "value": 10 } +{ "type": "lights", "value": 2 } { "type": "trafficLights", "state": "off" } { "type": "trafficLights", "state": "red" } { "type": "helloWorld" } { "type": "helloWorld" } +{ "type": "allState" } |