forked from Aircoookie/WLED
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added liveviewws-page for liveview via websockets
- Loading branch information
1 parent
8545013
commit c4d8ef5
Showing
5 changed files
with
1,503 additions
and
1,422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"> | ||
<meta charset="utf-8"> | ||
<meta name="theme-color" content="#222222"> | ||
<title>WLED Live Preview</title> | ||
<style> | ||
body { | ||
margin: 0; | ||
} | ||
#canv { | ||
background: black; | ||
filter: brightness(175%); | ||
width: 100%; | ||
height: 100%; | ||
position: absolute; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="canv" /> | ||
<script> | ||
console.info("Live-Preview websocket opening"); | ||
var socket = new WebSocket("ws://"+document.location.host+"/ws"); | ||
|
||
socket.onopen = function () { | ||
console.info("Live-Preview websocket is opened"); | ||
socket.send("{'lv':true}"); | ||
} | ||
|
||
socket.onclose = function () { console.info("Live-Preview websocket is closing"); } | ||
|
||
socket.onerror = function (event) { console.error("Live-Preview websocket error:", event); } | ||
|
||
function updatePreview(leds) { | ||
var str = "linear-gradient(90deg,"; | ||
var len = leds.length; | ||
for (i = 0; i < len; i++) { | ||
var leddata = leds[i]; | ||
if (leddata.length > 6) leddata = leddata.substring(2); | ||
str += "#" + leddata; | ||
if (i < len -1) str += "," | ||
} | ||
str += ")"; | ||
document.getElementById("canv").style.background = str; | ||
} | ||
|
||
socket.onmessage = function (event) { | ||
try { | ||
var json = JSON.parse(event.data); | ||
if (json && json.leds) { | ||
requestAnimationFrame(function () {updatePreview(json.leds);}); | ||
} | ||
} | ||
catch (err) { | ||
console.error("Live-Preview websocket error:",err); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.