diff --git a/wled00/FX.cpp b/wled00/FX.cpp index a2f3d27a8..1ce19c7fe 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -693,6 +693,8 @@ uint16_t WS2812FX::mode_android(void) { uint16_t WS2812FX::chase(uint32_t color1, uint32_t color2, uint32_t color3, bool dopalette) { uint16_t counter = now * (SEGMENT.speed >> 3) + 1; uint16_t a = counter * SEGLEN >> 16; + SEGENV.step = a; + if (SEGENV.call == 0) SEGENV.aux1 = a; // Use intensity setting to vary chase up to 1/2 string length uint16_t b = (a + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; uint16_t c = (b + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; @@ -703,6 +705,26 @@ uint16_t WS2812FX::chase(uint32_t color1, uint32_t color2, uint32_t color3, bool setPixelColor(b, color2); setPixelColor(c, color3); + if (a > SEGENV.aux1) { // when speed is too fast, this catches the gaps + for (uint16_t i = SEGENV.aux1; i < a ; i++) { + setPixelColor(i, color1); + uint16_t b1 = (i + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; + uint16_t c1 = (b1 + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; + setPixelColor(b1, color2); + setPixelColor(c1, color3); + } + } else if (a < SEGENV.aux1 && a < 10) { // this is for the start of the strip + for (uint16_t i = 0; i < a ; i++) { + setPixelColor(i, color1); + uint16_t b1 = (i + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; + uint16_t c1 = (b1 + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; + setPixelColor(b1, color2); + setPixelColor(c1, color3); + SEGENV.step = 0; + } + } + SEGENV.aux1 = a++; + return FRAMETIME; } @@ -1188,20 +1210,23 @@ uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2) if (idexR >= SEGLEN) idexR = 0; uint16_t topindex = SEGLEN >> 1; - uint16_t idexB = idexR + topindex; + uint16_t idexB = (idexR > topindex) ? idexR - topindex : idexR + topindex; if (SEGENV.call == 0) SEGENV.aux0 = idexR; - - if (idexR > topindex) idexB -= SEGLEN; if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs - uint8_t gap = (SEGENV.aux0 < idexR)? idexR - SEGENV.aux0:SEGLEN - SEGENV.aux0 + idexR; - for (uint8_t i = 0; i < gap ; i++) { - if ((idexR - i) < 0) idexR = SEGLEN-1 + i; - if ((idexB - i) < 0) idexB = SEGLEN-1 + i; - setPixelColor(idexR-i, color1); - setPixelColor(idexB-i, color2); + if (SEGENV.aux0 == idexR) { + setPixelColor(idexR, color1); + setPixelColor(idexB, color2); + } else { + uint8_t gap = (SEGENV.aux0 < idexR)? idexR - SEGENV.aux0:SEGLEN - SEGENV.aux0 + idexR; + for (uint8_t i = 0; i <= gap ; i++) { + if ((idexR - i) < 0) idexR = SEGLEN-1 + i; + if ((idexB - i) < 0) idexB = SEGLEN-1 + i; + setPixelColor(idexR-i, color1); + setPixelColor(idexB-i, color2); + } + SEGENV.aux0 = idexR; } - SEGENV.aux0 = idexR; return FRAMETIME; }