From 30cfb7ffe7cc15708e7b8af633501a49369b5baa Mon Sep 17 00:00:00 2001 From: Fisch Date: Mon, 7 Dec 2020 20:51:15 +0100 Subject: [PATCH] implement proper white channel calculation --- src/main.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8090cf4..a91bb5a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,7 +36,7 @@ const uint16_t Num_Leds = 264; // strip length const uint8_t - Brightness = 100; // maximum brightness + Brightness = 127; // maximum brightness // --- FastLED Setings #if defined(SK6812RGBW) @@ -273,10 +273,30 @@ void dataMode(){ uint8_t r=leds[i].r; uint8_t g=leds[i].g; uint8_t b=leds[i].b; + + /* Simple 255,255,255 = White approach uint8_t w=min(r,min(g,b)); //get white content and use for white r-=w; //subtract white content g-=w; b-=w; + */ + + // Calibration 20201207. These RGB values match the Neutral White color with calibW brightness. + uint8_t calibR=255; + uint8_t calibG=175; + uint8_t calibB=90; + uint8_t calibW=135; + + //one of calibR,calibG or calibB should be 255. + int minval=min(r-calibR,min(g-calibG,b-calibB)); //0 if rgb contains full white. <0 if not full white. -1*(max(calibR,calibG,calibB)) if no white content + float whitecontent=1.0 + (minval/255.0); //scale to: 0=no white, 1=full white content + //subtract white contents from rgb + r-=calibR*whitecontent; + g-=calibG*whitecontent; + b-=calibB*whitecontent; + + uint8_t w=calibW*whitecontent; + send_leds[i] = CRGBW(r, g, b, w); //transfer to rgbw struct }