Merge branch 'mapping12soundsim' into segment-api

This commit is contained in:
Blaz Kristan 2022-08-02 21:47:24 +02:00
commit 8f5d2a7f00
9 changed files with 2067 additions and 1840 deletions

View File

@ -393,6 +393,12 @@ const char PAGE_dmxmap[] PROGMEM = R"=====()=====";
method: "gzip",
filter: "html-minify",
},
{
file: "liveviewws2D.htm",
name: "PAGE_liveviewws2D",
method: "gzip",
filter: "html-minify",
},
{
file: "404.htm",
name: "PAGE_404",

View File

@ -233,6 +233,14 @@ button {
border: 0px;
}
#liveview2D {
height: 90%;
display: none;
width: 90%;
border: 0px;
margin: 0 auto;
}
.tab {
background-color: transparent;
color: var(--c-d);

View File

@ -351,6 +351,10 @@
</div>
</div>
<div id="mliveview2D" class="modal">
<div id="kliveview2D" style="width:100%; height:100%">Loading...</div><br>
</div>
<div id="rover" class="modal">
<i class="icons huge">&#xe410;</i><br>
<div id="lv">?</div><br><br>

View File

@ -1551,10 +1551,25 @@ function toggleSync()
function toggleLiveview()
{
//WLEDSR adding liveview2D support
if (isInfo && isM) toggleInfo();
if (isNodes && isM) toggleNodes();
isLv = !isLv;
gId('liveview').style.display = (isLv) ? "block":"none";
var url = (loc?`http://${locip}`:'') + "/liveview";
gId('liveview').src = (isLv) ? url:"about:blank";
var lvID = "liveview";
if (isM) {
lvID = "liveview2D"
if (isLv) {
var cn = '<iframe id="liveview2D" src="about:blank"></iframe>';
d.getElementById('kliveview2D').innerHTML = cn;
}
gId('mliveview2D').style.transform = (isLv) ? "translateY(0px)":"translateY(100%)";
}
gId(lvID).style.display = (isLv) ? "block":"none";
var url = (loc?`http://${locip}`:'') + "/" + lvID;
gId(lvID).src = (isLv) ? url:"about:blank";
gId('buttonSr').className = (isLv) ? "active":"";
if (!isLv && ws && ws.readyState === WebSocket.OPEN) ws.send('{"lv":false}');
size();
@ -1563,6 +1578,7 @@ function toggleLiveview()
function toggleInfo()
{
if (isNodes) toggleNodes();
if (isLv && isM) toggleLiveview();
isInfo = !isInfo;
if (isInfo) requestJson();
gId('info').style.transform = (isInfo) ? "translateY(0px)":"translateY(100%)";
@ -1572,6 +1588,7 @@ function toggleInfo()
function toggleNodes()
{
if (isInfo) toggleInfo();
if (isLv && isM) toggleLiveview();
isNodes = !isNodes;
if (isNodes) loadNodes();
gId('nodes').style.transform = (isNodes) ? "translateY(0px)":"translateY(100%)";

View File

@ -0,0 +1,113 @@
<!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;
}
</style>
</head>
<body>
<canvas id="liveviewCanvas">
LiveView
</canvas>
<script>
var canvas = document.getElementById('liveviewCanvas');
canvas.width = window.innerWidth * 0.98; //remove scroll bars
canvas.height = window.innerHeight * 0.98; //remove scroll bars
var leds = "";
var matrixWidth = 0;
var pixelsPerLed = 0;
// Check for canvas support
if (canvas.getContext) {
// Access the rendering context
var ctx = canvas.getContext('2d');
//In case of pixels
// // ImageData object
// var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
// // One-dimensional array containing the data in the RGBA order
// var data = imageData.data;
// function drawLedPixels(x, y, r, g, b, a) { //old
// // console.log(x, y, r, g, b, a);
// for (right = 0; right < pixelsPerLed; right++) {
// for (down = 0; down < pixelsPerLed; down++) {
// ff = (x * pixelsPerLed + right + (y * pixelsPerLed + down) * matrixWidth * pixelsPerLed) * 4;
// // if (x==15 && y==15)
// // console.log("ff=" + x + " * " + pixelsPerLed + " +" + right + " + (" + y + " * " + pixelsPerLed + " +" + down + ") * " + matrixWidth + ") * 4 = " + ff, data.length); //(5*10+1 + (12*10+1) * 16) * 4 = (51 + 121*16) * 4
// data[ff + 0] = r;
// data[ff + 1] = g;
// data[ff + 2] = b;
// data[ff + 3] = a;
// }
// }
// }
function drawLedCircles(x, y, r, g, b, a) {
ctx.fillStyle = `rgb(${r},${g},${b})`;
ctx.beginPath();
ctx.arc(x*pixelsPerLed+pixelsPerLed*0.5, y*pixelsPerLed+pixelsPerLed*0.5, pixelsPerLed*0.4, 0, 2 * Math.PI);
ctx.fill();
}
function paintLeds() {
// data represents the Uint8ClampedArray containing the data
// in the RGBA order [r0, g0, b0, a0, r1, g1, b1, a1, ..., rn, gn, bn, an]
for (i = 4; i < leds.length; i+=3) {
let ff = (i-4)/3;
drawLedCircles(ff%matrixWidth, Math.floor(ff/matrixWidth), leds[i], leds[i+1], leds[i+2], 255)
}
// ctx.putImageData(imageData, 0, 0); //in case of drawLedPixels
}
}
function updatePreview(ledsp) {
leds = ledsp;
matrixWidth = leds[2];
matrixHeight = leds[3];
pixelsPerLed = Math.min(canvas.width / matrixWidth, canvas.height / matrixHeight);
// console.log(canvas.width, matrixWidth, canvas.height, matrixHeight, pixelsPerLed, leds);
paintLeds();
}
function getLiveJson(e) {
try {
if (toString.call(e.data) === '[object ArrayBuffer]') {
let leds = new Uint8Array(event.data);
if (leds[0] != 76) return; //'L', set in ws.cpp
updatePreview(leds);
}
}
catch (err) {
console.error("Peek WS error:",err);
}
}
var ws;
try {
ws = top.window.ws;
} catch (e) {}
if (ws && ws.readyState === WebSocket.OPEN) {
console.info("Peek uses top WS");
ws.send("{'lv':true}");
} else {
console.info("Peek WS opening");
ws = new WebSocket((window.location.protocol == "https:"?"wss":"ws")+"://"+document.location.host+"/ws");
ws.onopen = function () {
console.info("Peek WS open");
ws.send("{'lv':true}");
}
}
ws.binaryType = "arraybuffer";
ws.addEventListener('message',getLiveJson);
</script>
</body>
</html>

View File

@ -281,6 +281,68 @@ const uint8_t PAGE_liveviewws[] PROGMEM = {
};
// Autogenerated from wled00/data/liveviewws2D.htm, do not edit!!
const uint16_t PAGE_liveviewws2D_length = 896;
const uint8_t PAGE_liveviewws2D[] PROGMEM = {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0x7d, 0x55, 0x6d, 0x6f, 0xdb, 0x36,
0x10, 0xfe, 0xee, 0x5f, 0xa1, 0x72, 0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, 0x89, 0xf4, 0x54, 0x09, 0x12, 0xa5, 0xc1, 0x83, 0x14,
0x99, 0x39, 0x31, 0x0e, 0x11, 0x29, 0x25, 0x99, 0xb5, 0xa5, 0x19, 0xa1, 0x86, 0x7b, 0xba, 0xb9,
0x42, 0xb6, 0x98, 0x81, 0xa0, 0xd4, 0xca, 0x2a, 0x9c, 0x83, 0xef, 0x49, 0x65, 0x0c, 0x19, 0xe1,
0x93, 0xb0, 0x3e, 0x19, 0x85, 0x21, 0xe9, 0x1f, 0xe6, 0xce, 0xc1, 0x39, 0x53, 0xc6, 0xf6, 0x49,
0xe8, 0x7c, 0x58, 0xa0, 0xa4, 0x0b, 0x19, 0x3f, 0xe6, 0x92, 0x3e, 0x09, 0xf7, 0x92, 0xd8, 0x7f,
0x5e, 0xa7, 0x69, 0x0d, 0x4b, 0x21, 0xb9, 0xde, 0x7d, 0xd9, 0x95, 0x38, 0x99, 0xb9, 0xcb, 0xde,
0xb2, 0xcd, 0x39, 0x71, 0x36, 0x9e, 0xa6, 0x53, 0x97, 0xca, 0x5b, 0x61, 0x70, 0x48, 0x03, 0x26,
0xa4, 0x00, 0x63, 0xf8, 0x1a, 0x88, 0x7f, 0x54, 0x3d, 0xac, 0x87, 0xc3, 0xb7, 0x1b, 0x9d, 0x51,
0xd8, 0xcd, 0xdd, 0xb0, 0xfd, 0x97, 0xf9, 0x07, 0xa8, 0x98, 0x44, 0x5c, 0x7b, 0x06, 0x00, 0x00
};
// Autogenerated from wled00/data/404.htm, do not edit!!
const uint16_t PAGE_404_length = 868;
const uint8_t PAGE_404[] PROGMEM = {

File diff suppressed because it is too large Load Diff

View File

@ -103,6 +103,14 @@ void initServer()
request->send(response);
//request->send_P(200, "text/html", PAGE_liveviewws);
});
server.on("/liveview2D", HTTP_GET, [](AsyncWebServerRequest *request){
if (handleIfNoneMatchCacheHeader(request)) return;
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_liveviewws2D, PAGE_liveviewws2D_length);
response->addHeader(FPSTR(s_content_enc),"gzip");
setStaticContentCacheHeaders(response);
request->send(response);
//request->send_P(200, "text/html", PAGE_liveviewws);
});
#else
server.on("/liveview", HTTP_GET, [](AsyncWebServerRequest *request){
if (handleIfNoneMatchCacheHeader(request)) return;

View File

@ -138,7 +138,7 @@ void sendDataWs(AsyncWebSocketClient * client)
releaseJSONBufferLock();
}
#define MAX_LIVE_LEDS_WS 256
#define MAX_LIVE_LEDS_WS 1024
bool sendLiveLedsWs(uint32_t wsClient)
{
@ -153,8 +153,10 @@ bool sendLiveLedsWs(uint32_t wsClient)
uint8_t* buffer = wsBuf->get();
buffer[0] = 'L';
buffer[1] = 1; //version
buffer[2] = strip.matrixWidth;
buffer[3] = strip.matrixHeight;
uint16_t pos = 2;
uint16_t pos = 4;
for (uint16_t i= 0; pos < bufSize -2; i += n)
{
uint32_t c = strip.getPixelColor(i);