allow gamma corrected preview without gamma corrected LEDs

This commit is contained in:
Frank
2023-08-05 00:06:58 +02:00
parent f010adfe24
commit 8e678ffa5e
4 changed files with 18 additions and 7 deletions

View File

@@ -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];
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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