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
|
//Spark type is used for popcorn, 1D fireworks, and drip
|
||||||
typedef struct Spark {
|
typedef struct Spark {
|
||||||
float pos;
|
float pos;
|
||||||
|
@ -247,7 +247,7 @@ class WS2812FX {
|
|||||||
|
|
||||||
// segment parameters
|
// segment parameters
|
||||||
public:
|
public:
|
||||||
typedef struct Segment { // 30 (33 in memory?) bytes
|
typedef struct Segment { // 30 (32 in memory) bytes
|
||||||
uint16_t start;
|
uint16_t start;
|
||||||
uint16_t stop; //segment invalid if stop == 0
|
uint16_t stop; //segment invalid if stop == 0
|
||||||
uint16_t offset;
|
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));
|
g = round(288.1221695283 * pow((temp - 60), -0.0755148492));
|
||||||
b = 255;
|
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[0] = (uint8_t) constrain(r, 0, 255);
|
||||||
rgb[1] = (uint8_t) constrain(g, 0, 255);
|
rgb[1] = (uint8_t) constrain(g, 0, 255);
|
||||||
rgb[2] = (uint8_t) constrain(b, 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)
|
// 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)
|
void colorBalanceFromKelvin(uint16_t kelvin, byte *rgb)
|
||||||
{
|
{
|
||||||
byte rgbw[4] = {0,0,0,0};
|
uint32_t col = RGBW32(rgb[0], rgb[1], rgb[2], 0);
|
||||||
colorKtoRGB(kelvin, rgbw); // convert Kelvin to RGB
|
col = colorBalanceFromKelvin(kelvin, col);
|
||||||
rgb[0] = ((uint16_t) rgbw[0] * rgb[0]) / 255; // correct R
|
rgb[0] = R(col);
|
||||||
rgb[1] = ((uint16_t) rgbw[1] * rgb[1]) / 255; // correct G
|
rgb[1] = G(col);
|
||||||
rgb[2] = ((uint16_t) rgbw[2] * rgb[2]) / 255; // correct B
|
rgb[2] = B(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte correctionRGB[4] = {0,0,0,0};
|
||||||
|
uint16_t lastKelvin = 0;
|
||||||
|
|
||||||
uint32_t colorBalanceFromKelvin(uint16_t kelvin, uint32_t rgb)
|
uint32_t colorBalanceFromKelvin(uint16_t kelvin, uint32_t rgb)
|
||||||
{
|
{
|
||||||
byte rgbw[4] = {0,0,0,0};
|
//remember so that slow colorKtoRGB() doesn't have to run for every setPixelColor()
|
||||||
colorKtoRGB(kelvin, rgbw); // convert Kelvin to RGB
|
if (lastKelvin != kelvin) colorKtoRGB(kelvin, correctionRGB); // convert Kelvin to RGB
|
||||||
rgbw[0] = ((uint16_t) rgbw[0] * R(rgb)) / 255; // correct R
|
lastKelvin = kelvin;
|
||||||
rgbw[1] = ((uint16_t) rgbw[1] * G(rgb)) / 255; // correct G
|
byte rgbw[4];
|
||||||
rgbw[2] = ((uint16_t) rgbw[2] * B(rgb)) / 255; // correct B
|
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);
|
rgbw[3] = W(rgb);
|
||||||
return colorFromRgbw(rgbw);
|
return colorFromRgbw(rgbw);
|
||||||
}
|
}
|
@ -30,7 +30,6 @@ void toggleOnOff()
|
|||||||
{
|
{
|
||||||
briLast = bri;
|
briLast = bri;
|
||||||
bri = 0;
|
bri = 0;
|
||||||
//unloadPlaylist(); // no longer necessary
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#ifndef WLED_DISABLE_MQTT
|
#ifndef WLED_DISABLE_MQTT
|
||||||
#define WLED_ENABLE_MQTT // saves 12kb
|
#define WLED_ENABLE_MQTT // saves 12kb
|
||||||
#endif
|
#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)
|
//#define WLED_ENABLE_DMX // uses 3.5kb (use LEDPIN other than 2)
|
||||||
#ifndef WLED_DISABLE_LOXONE
|
#ifndef WLED_DISABLE_LOXONE
|
||||||
#define WLED_ENABLE_LOXONE // uses 1.2kb
|
#define WLED_ENABLE_LOXONE // uses 1.2kb
|
||||||
|
Loading…
Reference in New Issue
Block a user