From 2ad3ab7f0da145bc076b2a4053cb0c3b6ef0563f Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Thu, 6 Jul 2023 22:48:13 +0200 Subject: [PATCH] Correct scaling for peek. --- wled00/json.cpp | 14 +++++++------- wled00/ws.cpp | 17 +++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index a18fcbdb..d48a54a2 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -1089,13 +1089,13 @@ bool serveLiveLeds(AsyncWebServerRequest* request, uint32_t wsClient) for (size_t i= 0; i < used; i += n) { uint32_t c = strip.getPixelColor(i); - uint8_t r = useGlobalLedBuffer ? scale8(R(c), strip.getBrightness()) : R(c); - uint8_t g = useGlobalLedBuffer ? scale8(G(c), strip.getBrightness()) : G(c); - uint8_t b = useGlobalLedBuffer ? scale8(B(c), strip.getBrightness()) : B(c); - uint8_t w = useGlobalLedBuffer ? scale8(W(c), strip.getBrightness()) : W(c); - r = qadd8(w, r); //R, add white channel to RGB channels as a simple RGBW -> RGB map - g = qadd8(w, g); //G - b = qadd8(w, b); //B + uint8_t r = R(c); + uint8_t g = G(c); + uint8_t b = B(c); + uint8_t w = W(c); + r = scale8(qadd8(w, r), strip.getBrightness()); //R, add white channel to RGB channels as a simple RGBW -> RGB map + g = scale8(qadd8(w, g), strip.getBrightness()); //G + b = scale8(qadd8(w, b), strip.getBrightness()); //B olen += sprintf(obuf + olen, "\"%06X\",", RGBW32(r,g,b,0)); } olen -= 1; diff --git a/wled00/ws.cpp b/wled00/ws.cpp index e295fe8e..49780d02 100644 --- a/wled00/ws.cpp +++ b/wled00/ws.cpp @@ -166,14 +166,15 @@ bool sendLiveLedsWs(uint32_t wsClient) size_t n = ((used -1)/MAX_LIVE_LEDS_WS) +1; //only serve every n'th LED if count over MAX_LIVE_LEDS_WS size_t pos = (strip.isMatrix ? 4 : 2); // start of data size_t bufSize = pos + (used/n)*3; - size_t skipLines = 0; AsyncWebSocketMessageBuffer * wsBuf = ws.makeBuffer(bufSize); if (!wsBuf) return false; //out of memory uint8_t* buffer = wsBuf->get(); buffer[0] = 'L'; buffer[1] = 1; //version + #ifndef WLED_DISABLE_2D + size_t skipLines = 0; if (strip.isMatrix) { buffer[1] = 2; //version buffer[2] = Segment::maxWidth; @@ -198,13 +199,13 @@ bool sendLiveLedsWs(uint32_t wsClient) } #endif uint32_t c = strip.getPixelColor(i); - uint8_t r = useGlobalLedBuffer ? scale8(R(c), strip.getBrightness()) : R(c); - uint8_t g = useGlobalLedBuffer ? scale8(G(c), strip.getBrightness()) : G(c); - uint8_t b = useGlobalLedBuffer ? scale8(B(c), strip.getBrightness()) : B(c); - uint8_t w = useGlobalLedBuffer ? scale8(W(c), strip.getBrightness()) : W(c); - buffer[pos++] = qadd8(w, r); //R, add white channel to RGB channels as a simple RGBW -> RGB map - buffer[pos++] = qadd8(w, g); //G - buffer[pos++] = qadd8(w, b); //B + uint8_t r = R(c); + uint8_t g = G(c); + uint8_t b = B(c); + uint8_t w = W(c); + buffer[pos++] = scale8(qadd8(w, r), strip.getBrightness()); //R, add white channel to RGB channels as a simple RGBW -> RGB map + buffer[pos++] = scale8(qadd8(w, g), strip.getBrightness()); //G + buffer[pos++] = scale8(qadd8(w, b), strip.getBrightness()); //B } wsc->binary(wsBuf);