From 8e678ffa5e40b12b6a07992eb92bb171fd253c74 Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 5 Aug 2023 00:06:58 +0200 Subject: [PATCH] allow gamma corrected preview without gamma corrected LEDs --- wled00/colors.cpp | 5 +++-- wled00/json.cpp | 16 +++++++++++++--- wled00/wled.h | 2 +- wled00/ws.cpp | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/wled00/colors.cpp b/wled00/colors.cpp index eca8cf74..aed4e56c 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -358,8 +358,9 @@ static void calcInvGammaTable(float gamma) } } uint8_t unGamma8(uint8_t value) { - if (!gammaCorrectCol || (value == 0) || (value == 255)) return value; - if ((gammaCorrectVal <= 1.0f) || (gammaCorrectVal > 3.0f)) return value; + //if (!gammaCorrectCol || (value == 0) || (value == 255)) return value; + if ((value == 0) || (value == 255)) return value; + if ((gammaCorrectVal < 0.999f) || (gammaCorrectVal > 3.0f)) return value; if (gammaTinv[255] == 0) calcInvGammaTable(gammaCorrectVal); return gammaTinv[value]; } diff --git a/wled00/json.cpp b/wled00/json.cpp index 3106aa96..6737a00f 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -1440,9 +1440,19 @@ 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 = qadd8(W(c), R(c)); //add white channel to RGB channels as a simple RGBW -> RGB map - uint8_t g = qadd8(W(c), G(c)); - uint8_t b = qadd8(W(c), B(c)); + // WLEDMM begin: live leds with color gamma correction + uint8_t w = W(c); // not sure why, but it looks better if always using "white" without corrections + uint8_t r,g,b; + if (gammaCorrectPreview) { + r = qadd8(w, unGamma8(R(c))); //R, add white channel to RGB channels as a simple RGBW -> RGB map + g = qadd8(w, unGamma8(G(c))); //G + b = qadd8(w, unGamma8(B(c))); //B + } else { + // WLEDMM end + r = qadd8(w, R(c)); //add white channel to RGB channels as a simple RGBW -> RGB map + g = qadd8(w, G(c)); + b = qadd8(w, B(c)); + } olen += sprintf(obuf + olen, "\"%06X\",", RGBW32(r,g,b,0)); } olen -= 1; diff --git a/wled00/wled.h b/wled00/wled.h index b0ca1c0c..d3d218fe 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2308040 +#define VERSION 2308041 //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 9cb34a95..38aee2c9 100644 --- a/wled00/ws.cpp +++ b/wled00/ws.cpp @@ -240,7 +240,7 @@ static bool sendLiveLedsWs(uint32_t wsClient) // WLEDMM added "static" //WLEDMM: no skipLines uint32_t c = restoreColorLossy(strip.getPixelColor(i), stripBrightness); // WLEDMM full bright preview - does _not_ recover ABL reductions // WLEDMM begin: preview with color gamma correction - if (gammaCorrectPreview && gammaCorrectCol) { + if (gammaCorrectPreview) { uint8_t w = W(c); // not sure why, but it looks better if using "white" without corrections buffer[pos++] = qadd8(w, unGamma8(R(c))); //R, add white channel to RGB channels as a simple RGBW -> RGB map buffer[pos++] = qadd8(w, unGamma8(G(c))); //G