Bugfixes.

- gamma on *Color palettes
- gamma moved out of WS2812FX
- palette fade (JSON) fix
This commit is contained in:
Blaz Kristan 2022-07-30 23:58:29 +02:00
parent 96da48ae82
commit d328db543e
12 changed files with 1454 additions and 1451 deletions

View File

@ -249,7 +249,7 @@ class UsermodCronixie : public Usermod {
if (backlight && _digitOut[i] <11)
{
uint32_t col = strip.gamma32(strip.getSegment(0).colors[1]);
uint32_t col = gamma32(strip.getSegment(0).colors[1]);
for (uint16_t j=o; j< o+10; j++) {
if (j != excl) strip.setPixelColor(j, col);
}

View File

@ -1502,7 +1502,7 @@ uint16_t mode_fairytwinkle() {
if (flashers[f].stateOn && flashers[f].stateDur > maxDur) flashers[f].stateDur = maxDur; //react more quickly on intensity change
if (stateTime > riseFallTime) stateTime = riseFallTime; //for flasher brightness calculation, fades in first 255 ms of state
uint8_t fadeprog = 255 - ((stateTime * 255) / riseFallTime);
uint8_t flasherBri = (flashers[f].stateOn) ? 255-strip.gamma8(fadeprog) : strip.gamma8(fadeprog);
uint8_t flasherBri = (flashers[f].stateOn) ? 255-gamma8(fadeprog) : gamma8(fadeprog);
uint16_t lastR = PRNG16;
uint16_t diff = 0;
while (diff < 0x4000) { //make sure colors of two adjacent LEDs differ enough
@ -4284,9 +4284,9 @@ uint16_t mode_tv_simulator(void) {
}
}
// Apply gamma correction, further expand to 16/16/16
nr = (uint8_t)strip.gamma8(tvSimulator->actualColorR) * 257; // New R/G/B
ng = (uint8_t)strip.gamma8(tvSimulator->actualColorG) * 257;
nb = (uint8_t)strip.gamma8(tvSimulator->actualColorB) * 257;
nr = (uint8_t)gamma8(tvSimulator->actualColorR) * 257; // New R/G/B
ng = (uint8_t)gamma8(tvSimulator->actualColorG) * 257;
nb = (uint8_t)gamma8(tvSimulator->actualColorB) * 257;
if (SEGENV.aux0 == 0) { // initialize next iteration
SEGENV.aux0 = 1;
@ -6074,7 +6074,7 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli
return FRAMETIME;
} // mode_ripplepeak()
static const char *_data_FX_MODE_RIPPLEPEAK PROGMEM = "Ripple Peak ♪@Fade rate,Max # of ripples,,Select bin,Volume (minimum)=0;!,!;!;mp12=0,ssim=1"; // Pixel, Beatsin
static const char *_data_FX_MODE_RIPPLEPEAK PROGMEM = "Ripple Peak ♪@Fade rate,Max # of ripples,,Select bin,Volume (minimum)=0;!,!;!;mp12=0,ssim=0"; // Pixel, Beatsin
#ifndef WLED_DISABLE_2D
@ -6128,7 +6128,7 @@ uint16_t mode_2DSwirl(void) {
SEGMENT.setPixels(leds);
return FRAMETIME;
} // mode_2DSwirl()
static const char *_data_FX_MODE_2DSWIRL PROGMEM = "2D Swirl ♪@!,Sensitivity=64,Blur;,Bg Swirl;!;ssim=1"; // Beatsin
static const char *_data_FX_MODE_2DSWIRL PROGMEM = "2D Swirl ♪@!,Sensitivity=64,Blur;,Bg Swirl;!;ssim=0"; // Beatsin
/////////////////////////
@ -6180,7 +6180,7 @@ uint16_t mode_2DWaverly(void) {
SEGMENT.setPixels(leds);
return FRAMETIME;
} // mode_2DWaverly()
static const char *_data_FX_MODE_2DWAVERLY PROGMEM = "2D Waverly ♪@Amplification,Sensitivity=64;;!;ssim=1"; // Beatsin
static const char *_data_FX_MODE_2DWAVERLY PROGMEM = "2D Waverly ♪@Amplification,Sensitivity=64;;!;ssim=0"; // Beatsin
#endif // WLED_DISABLE_2D
@ -6243,7 +6243,7 @@ uint16_t mode_gravcenter(void) { // Gravcenter. By Andrew Tuline.
return FRAMETIME;
} // mode_gravcenter()
static const char *_data_FX_MODE_GRAVCENTER PROGMEM = "Gravcenter ♪@Rate of fall,Sensitivity=128;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_GRAVCENTER PROGMEM = "Gravcenter ♪@Rate of fall,Sensitivity=128;,!;!;mp12=2,ssim=0"; // Circle, Beatsin
///////////////////////
@ -6297,7 +6297,7 @@ uint16_t mode_gravcentric(void) { // Gravcentric. By Andrew
return FRAMETIME;
} // mode_gravcentric()
static const char *_data_FX_MODE_GRAVCENTRIC PROGMEM = "Gravcentric ♪@Rate of fall,Sensitivity=128;!;!;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_GRAVCENTRIC PROGMEM = "Gravcentric ♪@Rate of fall,Sensitivity=128;!;!;mp12=2,ssim=0"; // Circle, Beatsin
///////////////////////
@ -6346,7 +6346,7 @@ uint16_t mode_gravimeter(void) { // Gravmeter. By Andrew Tuline.
return FRAMETIME;
} // mode_gravimeter()
static const char *_data_FX_MODE_GRAVIMETER PROGMEM = "Gravimeter ♪@Rate of fall,Sensitivity=128;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_GRAVIMETER PROGMEM = "Gravimeter ♪@Rate of fall,Sensitivity=128;!,!;!;mp12=2,ssim=0"; // Circle, Beatsin
//////////////////////
@ -6369,7 +6369,7 @@ uint16_t mode_juggles(void) { // Juggles. By Andrew Tuline.
return FRAMETIME;
} // mode_juggles()
static const char *_data_FX_MODE_JUGGLES PROGMEM = "Juggles ♪@!,# of balls;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_JUGGLES PROGMEM = "Juggles ♪@!,# of balls;,!;!;mp12=0,ssim=0"; // Pixels, Beatsin
//////////////////////
@ -6399,7 +6399,7 @@ uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline.
return FRAMETIME;
} // mode_matripix()
static const char *_data_FX_MODE_MATRIPIX PROGMEM = "Matripix ♪@!,Brightness=64;!,!;!;mp12=2,ssim=2,rev=1,mi=1,rY=1,mY=1"; // Circle, WeWillRockYou, reverseX
static const char *_data_FX_MODE_MATRIPIX PROGMEM = "Matripix ♪@!,Brightness=64;!,!;!;mp12=2,ssim=1,rev=1,mi=1,rY=1,mY=1"; // Circle, WeWillRockYou, reverseX
//////////////////////
@ -6437,7 +6437,7 @@ uint16_t mode_midnoise(void) { // Midnoise. By Andrew Tuline.
return FRAMETIME;
} // mode_midnoise()
static const char *_data_FX_MODE_MIDNOISE PROGMEM = "Midnoise ♪@Fade rate,Maximum length=128;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_MIDNOISE PROGMEM = "Midnoise ♪@Fade rate,Maximum length=128;,!;!;mp12=2,ssim=0"; // Circle, Beatsin
//////////////////////
@ -6471,7 +6471,7 @@ uint16_t mode_noisefire(void) { // Noisefire. By Andrew Tuline.
return FRAMETIME;
} // mode_noisefire()
static const char *_data_FX_MODE_NOISEFIRE PROGMEM = "Noisefire ♪@!,!;;;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_NOISEFIRE PROGMEM = "Noisefire ♪@!,!;;;mp12=2,ssim=0"; // Circle, Beatsin
///////////////////////
@ -6509,14 +6509,21 @@ uint16_t mode_noisemeter(void) { // Noisemeter. By Andrew Tuline.
return FRAMETIME;
} // mode_noisemeter()
static const char *_data_FX_MODE_NOISEMETER PROGMEM = "Noisemeter ♪@Fade rate,Width=128;!,!;!;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_NOISEMETER PROGMEM = "Noisemeter ♪@Fade rate,Width=128;!,!;!;mp12=2,ssim=0"; // Circle, Beatsin
//////////////////////
// * PIXELWAVE //
//////////////////////
uint16_t mode_pixelwave(void) { // Pixelwave. By Andrew Tuline.
if (SEGENV.call == 0) SEGMENT.fill(BLACK);
// even with 1D effect we have to take logic for 2D segments for allocation as fill_solid() fills whole segment
const uint16_t cols = SEGMENT.virtualWidth();
const uint16_t rows = SEGMENT.virtualHeight();
const uint16_t dataSize = sizeof(CRGB) * SEGMENT.width() * SEGMENT.height(); // using width*height prevents reallocation if mirroring is enabled
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
CRGB *leds = reinterpret_cast<CRGB*>(SEGENV.data);
if (SEGENV.call == 0) SEGMENT.fill_solid(leds, BLACK);
um_data_t *um_data;
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
@ -6534,15 +6541,15 @@ uint16_t mode_pixelwave(void) { // Pixelwave. By Andrew Tuline.
uint8_t tmpSound = (soundAgc) ? rawSampleAgc : sampleRaw;
int pixBri = tmpSound * SEGMENT.intensity / 64;
SEGMENT.setPixelColor(SEGLEN/2, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(millis(), false, PALETTE_SOLID_WRAP, 0), pixBri));
for (uint16_t i=SEGLEN-1; i>SEGLEN/2; i--) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i-1)); // Move to the right.
for (uint16_t i=0; i<SEGLEN/2; i++) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i+1)); // Move to the left.
leds[SEGLEN/2] = color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(millis(), false, PALETTE_SOLID_WRAP, 0), pixBri);
for (int i=SEGLEN-1; i>SEGLEN/2; i--) leds[i] = leds[i-1]; // Move to the right.
for (int i=0; i<SEGLEN/2; i++) leds[i] = leds[i+1]; // Move to the left.
}
for (int x = 0; x < SEGLEN; x++) SEGMENT.setPixelColor(x, leds[x]);
return FRAMETIME;
} // mode_pixelwave()
static const char *_data_FX_MODE_PIXELWAVE PROGMEM = "Pixelwave ♪@!,Sensitivity=64;!,!;!;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_PIXELWAVE PROGMEM = "Pixelwave ♪@!,Sensitivity=64;!,!;!;mp12=2,ssim=0"; // Circle, Beatsin
//////////////////////
@ -6586,7 +6593,7 @@ uint16_t mode_plasmoid(void) { // Plasmoid. By Andrew Tuline.
return FRAMETIME;
} // mode_plasmoid()
static const char *_data_FX_MODE_PLASMOID PROGMEM = "Plasmoid ♪@Phase=128,# of pixels=128;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_PLASMOID PROGMEM = "Plasmoid ♪@Phase=128,# of pixels=128;,!;!;mp12=0,ssim=0"; // Pixels, Beatsin
///////////////////////
@ -6630,7 +6637,7 @@ uint16_t mode_puddlepeak(void) { // Puddlepeak. By Andrew Tuline.
return FRAMETIME;
} // mode_puddlepeak()
static const char *_data_FX_MODE_PUDDLEPEAK PROGMEM = "Puddlepeak ♪@Fade rate,Puddle size,,Select bin,Volume (minimum)=0;!,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_PUDDLEPEAK PROGMEM = "Puddlepeak ♪@Fade rate,Puddle size,,Select bin,Volume (minimum)=0;!,!;!;mp12=0,ssim=0"; // Pixels, Beatsin
//////////////////////
@ -6665,7 +6672,7 @@ uint16_t mode_puddles(void) { // Puddles. By Andrew Tuline.
return FRAMETIME;
} // mode_puddles()
static const char *_data_FX_MODE_PUDDLES PROGMEM = "Puddles ♪@Fade rate,Puddle size;!,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_PUDDLES PROGMEM = "Puddles ♪@Fade rate,Puddle size;!,!;!;mp12=0,ssim=0"; // Pixels, Beatsin
///////////////////////////////////////////////////////////////////////////////
@ -6695,7 +6702,7 @@ uint16_t mode_pixels(void) { // Pixels. By Andrew Tuline.
return FRAMETIME;
} // mode_pixels()
static const char *_data_FX_MODE_PIXELS PROGMEM = "Pixels ♪@Fade rate,# of pixels;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_PIXELS PROGMEM = "Pixels ♪@Fade rate,# of pixels;,!;!;mp12=0,ssim=0"; // Pixels, Beatsin
///////////////////////////////
@ -6730,7 +6737,7 @@ uint16_t mode_blurz(void) { // Blurz. By Andrew Tuline.
return FRAMETIME;
} // mode_blurz()
static const char *_data_FX_MODE_BLURZ PROGMEM = "Blurz ♫@Fade rate,Blur amount;!,Color mix;!;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_BLURZ PROGMEM = "Blurz ♫@Fade rate,Blur amount;!,Color mix;!;mp12=0,ssim=0"; // Pixels, Beatsin
/////////////////////////
@ -6767,7 +6774,7 @@ uint16_t mode_DJLight(void) { // Written by ??? Adapted by Wil
return FRAMETIME;
} // mode_DJLight()
static const char *_data_FX_MODE_DJLIGHT PROGMEM = "DJ Light ♫@Speed;;;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_DJLIGHT PROGMEM = "DJ Light ♫@Speed;;;mp12=2,ssim=0"; // Circle, Beatsin
////////////////////
@ -6804,7 +6811,7 @@ uint16_t mode_freqmap(void) { // Map FFT_MajorPeak to SEGLEN.
return FRAMETIME;
} // mode_freqmap()
static const char *_data_FX_MODE_FREQMAP PROGMEM = "Freqmap ♫@Fade rate,Starting color;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_FREQMAP PROGMEM = "Freqmap ♫@Fade rate,Starting color;,!;!;mp12=2,ssim=0"; // Circle, Beatsin
///////////////////////
@ -6854,7 +6861,7 @@ uint16_t mode_freqmatrix(void) { // Freqmatrix. By Andreas Plesch
return FRAMETIME;
} // mode_freqmatrix()
static const char *_data_FX_MODE_FREQMATRIX PROGMEM = "Freqmatrix ♫@Time delay,Sound effect,Low bin,High bin,Sensivity;;;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_FREQMATRIX PROGMEM = "Freqmatrix ♫@Time delay,Sound effect,Low bin,High bin,Sensivity;;;mp12=0,ssim=0"; // Pixels, Beatsin
//////////////////////
@ -6891,7 +6898,7 @@ uint16_t mode_freqpixels(void) { // Freqpixel. By Andrew Tuline.
return FRAMETIME;
} // mode_freqpixels()
static const char *_data_FX_MODE_FREQPIXELS PROGMEM = "Freqpixels ♫@Fade rate,Starting colour and # of pixels;;;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_FREQPIXELS PROGMEM = "Freqpixels ♫@Fade rate,Starting colour and # of pixels;;;mp12=0,ssim=0"; // Pixels, Beatsin
//////////////////////
@ -6962,7 +6969,7 @@ uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschun
return FRAMETIME;
} // mode_freqwave()
static const char *_data_FX_MODE_FREQWAVE PROGMEM = "Freqwave ♫@Time delay,Sound effect,Low bin,High bin,Pre-amp;;;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_FREQWAVE PROGMEM = "Freqwave ♫@Time delay,Sound effect,Low bin,High bin,Pre-amp;;;mp12=2,ssim=0"; // Circle, Beatsin
///////////////////////
@ -7015,7 +7022,7 @@ uint16_t mode_gravfreq(void) { // Gravfreq. By Andrew Tuline.
return FRAMETIME;
} // mode_gravfreq()
static const char *_data_FX_MODE_GRAVFREQ PROGMEM = "Gravfreq ♫@Rate of fall,Sensivity=128;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_GRAVFREQ PROGMEM = "Gravfreq ♫@Rate of fall,Sensivity=128;,!;!;mp12=2,ssim=0"; // Circle, Beatsin
//////////////////////
@ -7041,7 +7048,7 @@ uint16_t mode_noisemove(void) { // Noisemove. By: Andrew Tuli
return FRAMETIME;
} // mode_noisemove()
static const char *_data_FX_MODE_NOISEMOVE PROGMEM = "Noisemove ♫@Speed of perlin movement,Fade rate;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_NOISEMOVE PROGMEM = "Noisemove ♫@Speed of perlin movement,Fade rate;,!;!;mp12=0,ssim=0"; // Pixels, Beatsin
//////////////////////
@ -7085,7 +7092,7 @@ uint16_t mode_rocktaves(void) { // Rocktaves. Same note from eac
return FRAMETIME;
} // mode_rocktaves()
static const char *_data_FX_MODE_ROCKTAVES PROGMEM = "Rocktaves ♫@;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_ROCKTAVES PROGMEM = "Rocktaves ♫@;,!;!;mp12=0,ssim=0"; // Pixels, Beatsin
///////////////////////
@ -7138,7 +7145,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
return FRAMETIME;
} // mode_waterfall()
static const char *_data_FX_MODE_WATERFALL PROGMEM = "Waterfall ♫@!,Adjust color,,Select bin, Volume (minimum)=0;!,!;!;mp12=2,ssim=1"; // Circles, Beatsin
static const char *_data_FX_MODE_WATERFALL PROGMEM = "Waterfall ♫@!,Adjust color,,Select bin, Volume (minimum)=0;!,!;!;mp12=2,ssim=0"; // Circles, Beatsin
#ifndef WLED_DISABLE_2D
@ -7195,7 +7202,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
return FRAMETIME;
} // mode_2DGEQ()
static const char *_data_FX_MODE_2DGEQ PROGMEM = "2D GEQ ♫@Fade speed,Ripple decay,# of bands=255,Color bars=64;!,,Peak Color;!=11;ssim=1"; // Beatsin
static const char *_data_FX_MODE_2DGEQ PROGMEM = "2D GEQ ♫@Fade speed,Ripple decay,# of bands=255,Color bars=64;!,,Peak Color;!=11;ssim=0"; // Beatsin
/////////////////////////
@ -7255,7 +7262,7 @@ uint16_t mode_2DFunkyPlank(void) { // Written by ??? Adapted by Wil
SEGMENT.setPixels(leds);
return FRAMETIME;
} // mode_2DFunkyPlank
static const char *_data_FX_MODE_2DFUNKYPLANK PROGMEM = "2D Funky Plank ♫@Scroll speed,,# of bands;;;ssim=1"; // Beatsin
static const char *_data_FX_MODE_2DFUNKYPLANK PROGMEM = "2D Funky Plank ♫@Scroll speed,,# of bands;;;ssim=0"; // Beatsin
#endif // WLED_DISABLE_2D
@ -7365,7 +7372,7 @@ uint16_t mode_2DAkemi(void) {
return FRAMETIME;
} // mode_2DAkemi
static const char *_data_FX_MODE_2DAKEMI PROGMEM = "2D Akemi@Color speed,Dance;Head palette,Arms & Legs,Eyes & Mouth;Face palette;ssim=1"; //beatsin
static const char *_data_FX_MODE_2DAKEMI PROGMEM = "2D Akemi@Color speed,Dance;Head palette,Arms & Legs,Eyes & Mouth;Face palette;ssim=0"; //beatsin
#endif // WLED_DISABLE_2D

View File

@ -682,7 +682,6 @@ class WS2812FX { // 96 bytes
setBrightness(uint8_t b, bool direct = false),
setRange(uint16_t i, uint16_t i2, uint32_t col),
setTransitionMode(bool t),
calcGammaTable(float),
purgeSegments(void),
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 1, uint8_t spacing = 0, uint16_t offset = UINT16_MAX, uint16_t startY=0, uint16_t stopY=1),
setMainSegmentId(uint8_t n),
@ -728,9 +727,7 @@ class WS2812FX { // 96 bytes
getActiveSegmentsNum(void),
getFirstSelectedSegId(void),
getLastActiveSegmentId(void),
setPixelSegment(uint8_t n),
gamma8(uint8_t),
gamma8_cal(uint8_t, float);
setPixelSegment(uint8_t n);
inline uint8_t getBrightness(void) { return _brightness; }
inline uint8_t getMaxSegments(void) { return MAX_NUM_SEGMENTS; } // returns maximum number of supported segments (fixed value)
@ -756,7 +753,6 @@ class WS2812FX { // 96 bytes
now,
timebase,
currentColor(uint32_t colorNew, uint8_t tNr),
gamma32(uint32_t),
getPixelColor(uint16_t);
inline uint32_t getLastShow(void) { return _lastShow; }

View File

@ -189,6 +189,8 @@ void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
}
}
}
#else
setPixelColor(x, col);
#endif
}
@ -454,14 +456,12 @@ void Segment::move(uint8_t dir, uint8_t delta, CRGB *leds) {
}
void Segment::fill_solid(CRGB* leds, CRGB color) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth();
const uint16_t cols = is2D() ? virtualWidth() : virtualLength();
const uint16_t rows = virtualHeight();
for(uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) {
if (leds) leds[XY(x,y)] = color;
else setPixelColorXY(x, y, color);
}
#endif
}
// by stepko, taken from https://editor.soulmatelights.com/gallery/573-blobs

View File

@ -266,22 +266,22 @@ CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
_lastPaletteChange = millis();
} break;}
case 2: {//primary color only
CRGB prim = CRGB(colors[0]);
CRGB prim = CRGB(strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0]);
targetPalette = CRGBPalette16(prim); break;}
case 3: {//primary + secondary
CRGB prim = CRGB(colors[0]);
CRGB sec = CRGB(colors[1]);
CRGB prim = CRGB(strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0]);
CRGB sec = CRGB(strip.gammaCorrectCol ? gamma32(colors[1]) : colors[1]);
targetPalette = CRGBPalette16(prim,prim,sec,sec); break;}
case 4: {//primary + secondary + tertiary
CRGB prim = CRGB(colors[0]);
CRGB sec = CRGB(colors[1]);
CRGB ter = CRGB(colors[2]);
CRGB prim = CRGB(strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0]);
CRGB sec = CRGB(strip.gammaCorrectCol ? gamma32(colors[1]) : colors[1]);
CRGB ter = CRGB(strip.gammaCorrectCol ? gamma32(colors[2]) : colors[2]);
targetPalette = CRGBPalette16(ter,sec,prim); break;}
case 5: {//primary + secondary (+tert if not off), more distinct
CRGB prim = CRGB(colors[0]);
CRGB sec = CRGB(colors[1]);
CRGB prim = CRGB(strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0]);
CRGB sec = CRGB(strip.gammaCorrectCol ? gamma32(colors[1]) : colors[1]);
if (colors[2]) {
CRGB ter = CRGB(colors[2]);
CRGB ter = CRGB(strip.gammaCorrectCol ? gamma32(colors[2]) : colors[2]);
targetPalette = CRGBPalette16(prim,prim,prim,prim,prim,sec,sec,sec,sec,sec,ter,ter,ter,ter,ter,prim);
} else {
targetPalette = CRGBPalette16(prim,prim,prim,prim,prim,prim,prim,prim,sec,sec,sec,sec,sec,sec,sec,sec);
@ -751,8 +751,8 @@ uint8_t Segment::get_random_wheel_index(uint8_t pos) {
uint32_t IRAM_ATTR Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri)
{
// default palette or no RGB support on segment
if (palette == 0 || !(_capabilities & 0x01)) {
uint32_t color = colors[constrain(mcol,0,NUM_COLORS-1)]; // SEGCOLOR(mcol);
if ((palette == 0 && mcol < NUM_COLORS) || !(_capabilities & 0x01)) {
uint32_t color = (transitional && _t) ? _t->_colorT[mcol] : colors[mcol];
if (pbri == 255) return color;
return RGBW32(scale8_video(R(color),pbri), scale8_video(G(color),pbri), scale8_video(B(color),pbri), scale8_video(W(color),pbri));
}
@ -863,9 +863,7 @@ void WS2812FX::service() {
seg.currentPalette(_currentPalette, seg.palette);
if (!cctFromRgb || correctWB) busses.setSegmentCCT(seg.currentBri(seg.cct, true), correctWB);
for (uint8_t c = 0; c < NUM_COLORS; c++) {
_colors_t[c] = gamma32(_colors_t[c]);
}
for (uint8_t c = 0; c < NUM_COLORS; c++) _colors_t[c] = gamma32(_colors_t[c]);
seg.handleTransition();
@ -1570,54 +1568,6 @@ void WS2812FX::deserializeMap(uint8_t n) {
releaseJSONBufferLock();
}
//gamma 2.8 lookup table used for color correction
static byte gammaT[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
uint8_t WS2812FX::gamma8_cal(uint8_t b, float gamma) {
return (int)(powf((float)b / 255.0f, gamma) * 255.0f + 0.5f);
}
void WS2812FX::calcGammaTable(float gamma)
{
for (uint16_t i = 0; i < 256; i++) {
gammaT[i] = gamma8_cal(i, gamma);
}
}
uint8_t WS2812FX::gamma8(uint8_t b)
{
return gammaT[b];
}
uint32_t WS2812FX::gamma32(uint32_t color)
{
if (!gammaCorrectCol) return color;
uint8_t w = W(color);
uint8_t r = R(color);
uint8_t g = G(color);
uint8_t b = B(color);
w = gammaT[w];
r = gammaT[r];
g = gammaT[g];
b = gammaT[b];
return RGBW32(r, g, b, w);
}
WS2812FX* WS2812FX::instance = nullptr;

View File

@ -319,3 +319,52 @@ uint16_t approximateKelvinFromRGB(uint32_t rgb) {
return (k > 10091) ? 10091 : k;
}
}
//gamma 2.8 lookup table used for color correction
static byte gammaT[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
uint8_t gamma8_cal(uint8_t b, float gamma)
{
return (int)(powf((float)b / 255.0f, gamma) * 255.0f + 0.5f);
}
void calcGammaTable(float gamma)
{
for (uint16_t i = 0; i < 256; i++) {
gammaT[i] = gamma8_cal(i, gamma);
}
}
uint8_t gamma8(uint8_t b)
{
return gammaT[b];
}
uint32_t gamma32(uint32_t color)
{
uint8_t w = W(color);
uint8_t r = R(color);
uint8_t g = G(color);
uint8_t b = B(color);
w = gammaT[w];
r = gammaT[r];
g = gammaT[g];
b = gammaT[b];
return RGBW32(r, g, b, w);
}

View File

@ -1220,6 +1220,7 @@ TD .checkmark, TD .radiomark {
.lbl-s {
display: inline-block;
/* margin: 10px 4px 0 0; */
margin-top: 6px;
font-size: 13px;
width: 48%;
text-align: center;

View File

@ -60,22 +60,21 @@ bool getJsonValue(const JsonVariant& element, DestType& destination, const Defau
//colors.cpp
uint32_t color_blend(uint32_t,uint32_t,uint16_t,bool b16=false);
uint32_t color_add(uint32_t,uint32_t);
inline uint32_t colorFromRgbw(byte* rgbw) { return uint32_t((byte(rgbw[3]) << 24) | (byte(rgbw[0]) << 16) | (byte(rgbw[1]) << 8) | (byte(rgbw[2]))); }
void colorHStoRGB(uint16_t hue, byte sat, byte* rgb); //hue, sat to rgb
void colorKtoRGB(uint16_t kelvin, byte* rgb);
void colorCTtoRGB(uint16_t mired, byte* rgb); //white spectrum to rgb
void colorXYtoRGB(float x, float y, byte* rgb); // only defined if huesync disabled TODO
void colorRGBtoXY(byte* rgb, float* xy); // only defined if huesync disabled TODO
void colorFromDecOrHexString(byte* rgb, char* in);
bool colorFromHexString(byte* rgb, const char* in);
uint32_t colorBalanceFromKelvin(uint16_t kelvin, uint32_t rgb);
uint16_t approximateKelvinFromRGB(uint32_t rgb);
void setRandomColor(byte* rgb);
uint8_t gamma8_cal(uint8_t b, float gamma);
void calcGammaTable(float gamma);
uint8_t gamma8(uint8_t b);
uint32_t gamma32(uint32_t);
//dmx.cpp
void initDMX();

File diff suppressed because it is too large Load Diff

View File

@ -205,7 +205,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
extractModeSlider(fx, 255, buf, 4, &tmp);
if (tmp < strip.getPaletteCount() + strip.customPalettes.size()) {
if (tmp != seg.palette) {
if (strip.paletteBlend && !seg.transitional) seg.startTransition(strip.getTransition());
if (strip.paletteFade && !seg.transitional) seg.startTransition(strip.getTransition());
seg.palette = tmp;
}
}
@ -224,7 +224,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
sOpt = extractModeDefaults(fx, "pal");
if (sOpt >= 0 && sOpt < strip.getPaletteCount() + strip.customPalettes.size()) {
if (sOpt != seg.palette) {
if (strip.paletteBlend && !seg.transitional) seg.startTransition(strip.getTransition());
if (strip.paletteFade && !seg.transitional) seg.startTransition(strip.getTransition());
seg.palette = sOpt;
}
}
@ -238,7 +238,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
uint8_t pal = seg.palette;
if (getVal(elem["pal"], &pal, 1, strip.getPaletteCount())) {
if (pal != seg.palette) {
if (strip.paletteBlend && !seg.transitional) seg.startTransition(strip.getTransition());
if (strip.paletteFade && !seg.transitional) seg.startTransition(strip.getTransition());
seg.palette = pal;
}
}
@ -290,7 +290,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
if (set < 2) stop = start + 1;
for (int i = start; i < stop; i++) {
if (strip.gammaCorrectCol) {
seg.setPixelColor(i, strip.gamma8(rgbw[0]), strip.gamma8(rgbw[1]), strip.gamma8(rgbw[2]), strip.gamma8(rgbw[3]));
seg.setPixelColor(i, gamma8(rgbw[0]), gamma8(rgbw[1]), gamma8(rgbw[2]), gamma8(rgbw[3]));
} else {
seg.setPixelColor(i, rgbw[0], rgbw[1], rgbw[2], rgbw[3]);
}

View File

@ -567,7 +567,7 @@ void setRealtimePixel(uint16_t i, byte r, byte g, byte b, byte w)
{
if (!arlsDisableGammaCorrection && strip.gammaCorrectCol)
{
strip.setPixelColor(pix, strip.gamma8(r), strip.gamma8(g), strip.gamma8(b), strip.gamma8(w));
strip.setPixelColor(pix, gamma8(r), gamma8(g), gamma8(b), gamma8(w));
} else {
strip.setPixelColor(pix, r, g, b, w);
}

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2207302
#define VERSION 2207303
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG