Skip to content

Commit ee9ac94

Browse files
committed
Segment layering & effect blending improvements
- Photoshop-style segment/layer blending - return of strip ABL - remove global LED buffer in favour of segment-local buffer - new effect blending modes/transitions - custom palettes moved out of WS2812FX class - increased limits (matrix size, LED RAM) - added "rainbow"-mode colorwheel - replaced palettes with gamma unmodified ones - move gamma adjustment to last step before sending to LEDs - Segment & WS2812FX class reorganisation (mutable members, reordered members, protected members)
1 parent 3538684 commit ee9ac94

32 files changed

+2723
-2931
lines changed

usermods/Analog_Clock/Analog_Clock.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ class AnalogClockUsermod : public Usermod {
102102
void secondsEffectSineFade(int16_t secondLed, Toki::Time const& time) {
103103
uint32_t ms = time.ms % 1000;
104104
uint8_t b0 = (cos8_t(ms * 64 / 1000) - 128) * 2;
105-
setPixelColor(secondLed, gamma32(scale32(secondColor, b0)));
105+
setPixelColor(secondLed, scale32(secondColor, b0));
106106
uint8_t b1 = (sin8_t(ms * 64 / 1000) - 128) * 2;
107-
setPixelColor(inc(secondLed, 1, secondsSegment), gamma32(scale32(secondColor, b1)));
107+
setPixelColor(inc(secondLed, 1, secondsSegment), scale32(secondColor, b1));
108108
}
109109

110110
static inline uint32_t qadd32(uint32_t c1, uint32_t c2) {
@@ -191,7 +191,7 @@ class AnalogClockUsermod : public Usermod {
191191
// for (uint16_t i = 1; i < secondsTrail + 1; ++i) {
192192
// uint16_t trailLed = dec(secondLed, i, secondsSegment);
193193
// uint8_t trailBright = 255 / (secondsTrail + 1) * (secondsTrail - i + 1);
194-
// setPixelColor(trailLed, gamma32(scale32(secondColor, trailBright)));
194+
// setPixelColor(trailLed, scale32(secondColor, trailBright));
195195
// }
196196
}
197197

usermods/Cronixie/Cronixie.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class UsermodCronixie : public Usermod {
247247

248248
if (backlight && _digitOut[i] <11)
249249
{
250-
uint32_t col = gamma32(strip.getSegment(0).colors[1]);
250+
uint32_t col = strip.getSegment(0).colors[1];
251251
for (uint16_t j=o; j< o+10; j++) {
252252
if (j != excl) strip.setPixelColor(j, col);
253253
}

wled00/FX.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5053,7 +5053,11 @@ uint16_t mode_2Dfirenoise(void) { // firenoise2d. By Andrew Tuline
50535053
unsigned yscale = SEGMENT.speed*8;
50545054
unsigned indexx = 0;
50555055

5056-
CRGBPalette16 pal = SEGMENT.check1 ? SEGPALETTE : SEGMENT.loadPalette(pal, 35);
5056+
//CRGBPalette16 pal = SEGMENT.check1 ? SEGPALETTE : SEGMENT.loadPalette(pal, 35);
5057+
CRGBPalette16 pal = SEGMENT.check1 ? SEGPALETTE : CRGBPalette16(CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black,
5058+
CRGB::Red, CRGB::Red, CRGB::Red, CRGB::DarkOrange,
5059+
CRGB::DarkOrange,CRGB::DarkOrange, CRGB::Orange, CRGB::Orange,
5060+
CRGB::Yellow, CRGB::Orange, CRGB::Yellow, CRGB::Yellow);
50575061
for (int j=0; j < cols; j++) {
50585062
for (int i=0; i < rows; i++) {
50595063
indexx = perlin8(j*yscale*rows/255, i*xscale+strip.now/4); // We're moving along our Perlin map.
@@ -6088,7 +6092,8 @@ uint16_t mode_2Dscrollingtext(void) {
60886092
case 5: letterWidth = 5; letterHeight = 12; break;
60896093
}
60906094
// letters are rotated
6091-
if (((SEGMENT.custom3+1)>>3) % 2) {
6095+
const int8_t rotate = map(SEGMENT.custom3, 0, 31, -2, 2);
6096+
if (rotate == 1 || rotate == -1) {
60926097
rotLH = letterWidth;
60936098
rotLW = letterHeight;
60946099
} else {
@@ -6126,6 +6131,7 @@ uint16_t mode_2Dscrollingtext(void) {
61266131
else if (!strncmp_P(text,PSTR("#DD"),3)) sprintf (text, zero? ("%02d") : ("%d"), day(localTime));
61276132
else if (!strncmp_P(text,PSTR("#DAY"),4)) sprintf (text, ("%s") , dayShortStr(day(localTime)));
61286133
else if (!strncmp_P(text,PSTR("#DDDD"),5)) sprintf (text, ("%s") , dayStr(day(localTime)));
6134+
else if (!strncmp_P(text,PSTR("#DAYL"),5)) sprintf (text, ("%s") , dayStr(day(localTime)));
61296135
else if (!strncmp_P(text,PSTR("#MO"),3)) sprintf (text, zero? ("%02d") : ("%d"), month(localTime));
61306136
else if (!strncmp_P(text,PSTR("#MON"),4)) sprintf (text, ("%s") , monthShortStr(month(localTime)));
61316137
else if (!strncmp_P(text,PSTR("#MMMM"),5)) sprintf (text, ("%s") , monthStr(month(localTime)));
@@ -6159,27 +6165,28 @@ uint16_t mode_2Dscrollingtext(void) {
61596165
SEGENV.step = strip.now + map(SEGMENT.speed, 0, 255, 250, 50); // shift letters every ~250ms to ~50ms
61606166
}
61616167

6162-
if (!SEGMENT.check2) SEGMENT.fade_out(255 - (SEGMENT.custom1>>4)); // trail
6163-
bool usePaletteGradient = false;
6168+
SEGMENT.fade_out(255 - (SEGMENT.custom1>>4)); // trail
61646169
uint32_t col1 = SEGMENT.color_from_palette(SEGENV.aux1, false, PALETTE_SOLID_WRAP, 0);
61656170
uint32_t col2 = BLACK;
6171+
// if gradient is selected and palette is default (0) drawCharacter() uses gradient from SEGCOLOR(0) to SEGCOLOR(2)
6172+
// otherwise col2 == BLACK means use currently selected palette for gradient
6173+
// if gradient is not selected set both colors the same
61666174
if (SEGMENT.check1) { // use gradient
6167-
if(SEGMENT.palette == 0) { // use colors for gradient
6168-
col1 = SEGCOLOR(0);
6169-
col2 = SEGCOLOR(2);
6175+
if (SEGMENT.palette == 0) { // use colors for gradient
6176+
col1 = SEGCOLOR(0);
6177+
col2 = SEGCOLOR(2);
61706178
}
6171-
else usePaletteGradient = true;
6172-
}
6179+
} else col2 = col1; // force characters to use single color (from palette)
61736180

61746181
for (int i = 0; i < numberOfLetters; i++) {
61756182
int xoffset = int(cols) - int(SEGENV.aux0) + rotLW*i;
61766183
if (xoffset + rotLW < 0) continue; // don't draw characters off-screen
6177-
SEGMENT.drawCharacter(text[i], xoffset, yoffset, letterWidth, letterHeight, col1, col2, map(SEGMENT.custom3, 0, 31, -2, 2), usePaletteGradient);
6184+
SEGMENT.drawCharacter(text[i], xoffset, yoffset, letterWidth, letterHeight, col1, col2, rotate);
61786185
}
61796186

61806187
return FRAMETIME;
61816188
}
6182-
static const char _data_FX_MODE_2DSCROLLTEXT[] PROGMEM = "Scrolling Text@!,Y Offset,Trail,Font size,Rotate,Gradient,Overlay,Reverse;!,!,Gradient;!;2;ix=128,c1=0,rev=0,mi=0,rY=0,mY=0";
6189+
static const char _data_FX_MODE_2DSCROLLTEXT[] PROGMEM = "Scrolling Text@!,Y Offset,Trail,Font size,Rotate,Gradient,,Reverse;!,!,Gradient;!;2;ix=128,c1=0,rev=0,mi=0,rY=0,mY=0";
61836190

61846191

61856192
////////////////////////////

0 commit comments

Comments
 (0)