From 27d7f5f1908d741445e27402c780a04468d8f999 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Fri, 6 Jan 2023 18:11:52 +0100 Subject: [PATCH] Fixes. Prevent flickering if segment off. --- wled00/FX.cpp | 19 ++++++++++--------- wled00/FX_2Dfcn.cpp | 21 +++++++++++---------- wled00/FX_fcn.cpp | 3 ++- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 1b19838e..8678929d 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -5878,20 +5878,21 @@ uint16_t mode_2Dscrollingtext(void) { else SEGENV.aux0 = (cols + (numberOfLetters * letterWidth))/2; ++SEGENV.aux1 &= 0xFF; // color shift SEGENV.step = millis() + map(SEGMENT.speed, 0, 255, 10*FRAMETIME_FIXED, 2*FRAMETIME_FIXED); - - // we need it 3 times - SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color - SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color - SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color - for (int i = 0; i < numberOfLetters; i++) { - if (int(cols) - int(SEGENV.aux0) + letterWidth*(i+1) < 0) continue; // don't draw characters off-screen - SEGMENT.drawCharacter(text[i], int(cols) - int(SEGENV.aux0) + letterWidth*i, yoffset, letterWidth, letterHeight, SEGMENT.color_from_palette(SEGENV.aux1, false, PALETTE_SOLID_WRAP, 0)); + if (!SEGMENT.check2) { + // we need it 3 times + SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color + SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color + SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color } +} + for (int i = 0; i < numberOfLetters; i++) { + if (int(cols) - int(SEGENV.aux0) + letterWidth*(i+1) < 0) continue; // don't draw characters off-screen + SEGMENT.drawCharacter(text[i], int(cols) - int(SEGENV.aux0) + letterWidth*i, yoffset, letterWidth, letterHeight, SEGMENT.color_from_palette(SEGENV.aux1, false, PALETTE_SOLID_WRAP, 0)); } return FRAMETIME; } -static const char _data_FX_MODE_2DSCROLLTEXT[] PROGMEM = "Scrolling Text@!,Y Offset,Trail,Font size;!,!;!;2;ix=128,c1=0,rev=0,mi=0,rY=0,mY=0"; +static const char _data_FX_MODE_2DSCROLLTEXT[] PROGMEM = "Scrolling Text@!,Y Offset,Trail,Font size,,,Overlay;!,!;!;2;ix=128,c1=0,rev=0,mi=0,rY=0,mY=0"; //////////////////////////// diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index fa095599..1a1bb247 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -164,6 +164,7 @@ void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col) if (leds) leds[XY(x,y)] = col; uint8_t _bri_t = currentBri(on ? opacity : 0); + if (!_bri_t) return; if (_bri_t < 255) { byte r = scale8(R(col), _bri_t); byte g = scale8(G(col), _bri_t); @@ -433,14 +434,14 @@ void Segment::draw_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB col) { int d = 3 - (2*radius); int y = radius, x = 0; while (y >= x) { - addPixelColorXY(cx+x, cy+y, col); - addPixelColorXY(cx-x, cy+y, col); - addPixelColorXY(cx+x, cy-y, col); - addPixelColorXY(cx-x, cy-y, col); - addPixelColorXY(cx+y, cy+x, col); - addPixelColorXY(cx-y, cy+x, col); - addPixelColorXY(cx+y, cy-x, col); - addPixelColorXY(cx-y, cy-x, col); + setPixelColorXY(cx+x, cy+y, col); + setPixelColorXY(cx-x, cy+y, col); + setPixelColorXY(cx+x, cy-y, col); + setPixelColorXY(cx-x, cy-y, col); + setPixelColorXY(cx+y, cy+x, col); + setPixelColorXY(cx-y, cy+x, col); + setPixelColorXY(cx+y, cy-x, col); + setPixelColorXY(cx-y, cy-x, col); x++; if (d > 0) { y--; @@ -460,7 +461,7 @@ void Segment::fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB col) { if (x * x + y * y <= radius * radius && int16_t(cx)+x>=0 && int16_t(cy)+y>=0 && int16_t(cx)+xdy ? dx : -dy)/2, e2; for (;;) { - addPixelColorXY(x0,y0,c); + setPixelColorXY(x0,y0,c); if (x0==x1 && y0==y1) break; e2 = err; if (e2 >-dx) { err -= dy; x0 += sx; } diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 289a658a..8c7ee250 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -610,6 +610,7 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col) uint16_t len = length(); uint8_t _bri_t = currentBri(on ? opacity : 0); + if (!_bri_t) return; if (_bri_t < 255) { byte r = scale8(R(col), _bri_t); byte g = scale8(G(col), _bri_t); @@ -1070,7 +1071,7 @@ void WS2812FX::service() { //if (seg.transitional && seg._modeP) (*_mode[seg._modeP])(progress()); delay = (*_mode[seg.currentMode(seg.mode)])(); if (seg.mode != FX_MODE_HALLOWEEN_EYES) seg.call++; - if (seg.transitional && delay > FRAMETIME) delay = FRAMETIME; // foce faster updates during transition + if (seg.transitional && delay > FRAMETIME) delay = FRAMETIME; // force faster updates during transition seg.handleTransition(); }