allowCCT performance improvement
This commit is contained in:
parent
0465298507
commit
b3324d22f5
@ -2614,7 +2614,7 @@ uint16_t WS2812FX::mode_glitter()
|
||||
|
||||
|
||||
|
||||
//each needs 11 bytes
|
||||
//each needs 12 bytes
|
||||
//Spark type is used for popcorn, 1D fireworks, and drip
|
||||
typedef struct Spark {
|
||||
float pos;
|
||||
|
@ -247,7 +247,7 @@ class WS2812FX {
|
||||
|
||||
// segment parameters
|
||||
public:
|
||||
typedef struct Segment { // 30 (33 in memory?) bytes
|
||||
typedef struct Segment { // 30 (32 in memory) bytes
|
||||
uint16_t start;
|
||||
uint16_t stop; //segment invalid if stop == 0
|
||||
uint16_t offset;
|
||||
|
@ -73,7 +73,7 @@ void colorKtoRGB(uint16_t kelvin, byte* rgb) //white spectrum to rgb, calc
|
||||
g = round(288.1221695283 * pow((temp - 60), -0.0755148492));
|
||||
b = 255;
|
||||
}
|
||||
//g += 15; //mod by Aircoookie, a bit less accurate but visibly less pinkish
|
||||
//g += 12; //mod by Aircoookie, a bit less accurate but visibly less pinkish
|
||||
rgb[0] = (uint8_t) constrain(r, 0, 255);
|
||||
rgb[1] = (uint8_t) constrain(g, 0, 255);
|
||||
rgb[2] = (uint8_t) constrain(b, 0, 255);
|
||||
@ -248,20 +248,25 @@ void colorRGBtoRGBW(byte* rgb) //rgb to rgbw (http://codewelt.com/rgbw). (RGBW_M
|
||||
// adjust RGB values based on color temperature in K (range [2800-10200]) (https://en.wikipedia.org/wiki/Color_balance)
|
||||
void colorBalanceFromKelvin(uint16_t kelvin, byte *rgb)
|
||||
{
|
||||
byte rgbw[4] = {0,0,0,0};
|
||||
colorKtoRGB(kelvin, rgbw); // convert Kelvin to RGB
|
||||
rgb[0] = ((uint16_t) rgbw[0] * rgb[0]) / 255; // correct R
|
||||
rgb[1] = ((uint16_t) rgbw[1] * rgb[1]) / 255; // correct G
|
||||
rgb[2] = ((uint16_t) rgbw[2] * rgb[2]) / 255; // correct B
|
||||
uint32_t col = RGBW32(rgb[0], rgb[1], rgb[2], 0);
|
||||
col = colorBalanceFromKelvin(kelvin, col);
|
||||
rgb[0] = R(col);
|
||||
rgb[1] = G(col);
|
||||
rgb[2] = B(col);
|
||||
}
|
||||
|
||||
byte correctionRGB[4] = {0,0,0,0};
|
||||
uint16_t lastKelvin = 0;
|
||||
|
||||
uint32_t colorBalanceFromKelvin(uint16_t kelvin, uint32_t rgb)
|
||||
{
|
||||
byte rgbw[4] = {0,0,0,0};
|
||||
colorKtoRGB(kelvin, rgbw); // convert Kelvin to RGB
|
||||
rgbw[0] = ((uint16_t) rgbw[0] * R(rgb)) / 255; // correct R
|
||||
rgbw[1] = ((uint16_t) rgbw[1] * G(rgb)) / 255; // correct G
|
||||
rgbw[2] = ((uint16_t) rgbw[2] * B(rgb)) / 255; // correct B
|
||||
//remember so that slow colorKtoRGB() doesn't have to run for every setPixelColor()
|
||||
if (lastKelvin != kelvin) colorKtoRGB(kelvin, correctionRGB); // convert Kelvin to RGB
|
||||
lastKelvin = kelvin;
|
||||
byte rgbw[4];
|
||||
rgbw[0] = ((uint16_t) correctionRGB[0] * R(rgb)) /255; // correct R
|
||||
rgbw[1] = ((uint16_t) correctionRGB[1] * G(rgb)) /255; // correct G
|
||||
rgbw[2] = ((uint16_t) correctionRGB[2] * B(rgb)) /255; // correct B
|
||||
rgbw[3] = W(rgb);
|
||||
return colorFromRgbw(rgbw);
|
||||
}
|
@ -30,7 +30,6 @@ void toggleOnOff()
|
||||
{
|
||||
briLast = bri;
|
||||
bri = 0;
|
||||
//unloadPlaylist(); // no longer necessary
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#ifndef WLED_DISABLE_MQTT
|
||||
#define WLED_ENABLE_MQTT // saves 12kb
|
||||
#endif
|
||||
//#define WLED_ENABLE_ADALIGHT // saves 500b only (uses GPIO3 (RX) for serial)
|
||||
#define WLED_ENABLE_ADALIGHT // saves 500b only (uses GPIO3 (RX) for serial)
|
||||
//#define WLED_ENABLE_DMX // uses 3.5kb (use LEDPIN other than 2)
|
||||
#ifndef WLED_DISABLE_LOXONE
|
||||
#define WLED_ENABLE_LOXONE // uses 1.2kb
|
||||
|
Loading…
Reference in New Issue
Block a user