From c22c92e3af1a50bda381b7324a6eef12a2a86f8e Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 10 Jul 2023 18:29:16 +0200 Subject: [PATCH] preview at full brightness * reverts global brightness in preview * can NOT revert brightness reductions from auto brightness limiter. --- wled00/wled.h | 2 +- wled00/ws.cpp | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/wled00/wled.h b/wled00/wled.h index 87039f65..cbf799d5 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2307080 +#define VERSION 2307100 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG diff --git a/wled00/ws.cpp b/wled00/ws.cpp index 5a655c82..ee242af5 100644 --- a/wled00/ws.cpp +++ b/wled00/ws.cpp @@ -167,6 +167,17 @@ void sendDataWs(AsyncWebSocketClient * client) releaseJSONBufferLock(); } +// WLEDMM function to recover full-brigh pixel (based on code from upstream alt-buffer, which is based on code from NeoPixelBrightnessBus) +static uint32_t restoreColorLossy(uint32_t c, uint_fast8_t _restaurationBri) { + if (_restaurationBri == 255) return c; + uint8_t* chan = (uint8_t*) &c; + for (uint_fast8_t i=0; i<4; i++) { + uint_fast16_t val = chan[i]; + chan[i] = ((val << 8) + _restaurationBri) / (_restaurationBri + 1); //adding _bri slighly improves recovery / stops degradation on re-scale + } + return c; +} + static bool sendLiveLedsWs(uint32_t wsClient) // WLEDMM added "static" { AsyncWebSocketClient * wsc = ws.client(wsClient); @@ -219,13 +230,15 @@ static bool sendLiveLedsWs(uint32_t wsClient) // WLEDMM added "static" } #endif + uint8_t stripBrightness = strip.getBrightness(); for (size_t i = 0; pos < bufSize -2; i += n) { //WLEDMM: no skipLines - uint32_t c = strip.getPixelColor(i); - buffer[pos++] = qadd8(W(c), R(c)); //R, add white channel to RGB channels as a simple RGBW -> RGB map - buffer[pos++] = qadd8(W(c), G(c)); //G - buffer[pos++] = qadd8(W(c), B(c)); //B + uint32_t c = restoreColorLossy(strip.getPixelColor(i), stripBrightness); // WLEDMM full bright preview - does _not_ recover ABL reductions + uint8_t w = W(c); // WLEDMM small optimization + buffer[pos++] = qadd8(w, R(c)); //R, add white channel to RGB channels as a simple RGBW -> RGB map + buffer[pos++] = qadd8(w, G(c)); //G + buffer[pos++] = qadd8(w, B(c)); //B } wsc->binary(wsBuf);