diff --git a/wled00/WS2812FX.cpp b/wled00/WS2812FX.cpp index b4d1f92cb..cc1a73d37 100644 --- a/wled00/WS2812FX.cpp +++ b/wled00/WS2812FX.cpp @@ -413,10 +413,11 @@ uint16_t WS2812FX::mode_theater_chase_rainbow(void) { */ uint16_t WS2812FX::running_base(bool saw) { uint8_t x_scale = SEGMENT.intensity >> 2; + uint32_t counter = (now * SEGMENT.speed) >> 9; for(uint16_t i=0; i < SEGLEN; i++) { uint8_t s = 0; - uint8_t a = i*x_scale - (SEGENV.step >> 4); + uint8_t a = i*x_scale - counter; if (saw) { if (a < 16) { @@ -428,8 +429,7 @@ uint16_t WS2812FX::running_base(bool saw) { s = sin8(a); setPixelColor(SEGMENT.start + i, color_blend(color_from_palette(SEGMENT.start + i, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), s)); } - SEGENV.step += SEGMENT.speed; - return 20; + return FRAMETIME; } @@ -854,11 +854,16 @@ uint16_t WS2812FX::mode_chase_flash_random(void) { * Alternating pixels running function. */ uint16_t WS2812FX::running(uint32_t color1, uint32_t color2) { + uint8_t pxw = 1 + (SEGMENT.intensity >> 5); + uint32_t cycleTime = 35 + (255 - SEGMENT.speed); + uint32_t it = now / cycleTime; + if (SEGMENT.speed == 0) it = 0; + for(uint16_t i=0; i < SEGLEN; i++) { - if((i + SEGENV.step) % 4 < 2) { + if((i + SEGENV.aux0) % (pxw*2) < pxw) { if (color1 == SEGCOLOR(0)) { - setPixelColor(SEGMENT.stop -i, color_from_palette(SEGMENT.stop -i -1, true, PALETTE_SOLID_WRAP, 0)); + setPixelColor(SEGMENT.stop -i -1, color_from_palette(SEGMENT.stop -i -1, true, PALETTE_SOLID_WRAP, 0)); } else { setPixelColor(SEGMENT.stop -i -1, color1); @@ -868,8 +873,12 @@ uint16_t WS2812FX::running(uint32_t color1, uint32_t color2) { } } - if (SEGMENT.speed != 0) SEGENV.step = (SEGENV.step + 1) & 0x3; - return 35 + ((350 * (uint32_t)(255 - SEGMENT.speed)) / 255); + if (it != SEGENV.step ) + { + SEGENV.aux0 = (SEGENV.aux0 +1) % (pxw*2); + SEGENV.step = it; + } + return FRAMETIME; } /* diff --git a/wled00/WS2812FX_fcn.cpp b/wled00/WS2812FX_fcn.cpp index d7ff43c1a..e36c9a10a 100644 --- a/wled00/WS2812FX_fcn.cpp +++ b/wled00/WS2812FX_fcn.cpp @@ -546,15 +546,15 @@ uint32_t WS2812FX::color_blend(uint32_t color1, uint32_t color2, uint8_t blend) if(blend == 0) return color1; if(blend == 255) return color2; - int w1 = (color1 >> 24) & 0xff; - int r1 = (color1 >> 16) & 0xff; - int g1 = (color1 >> 8) & 0xff; - int b1 = color1 & 0xff; + uint32_t w1 = (color1 >> 24) & 0xff; + uint32_t r1 = (color1 >> 16) & 0xff; + uint32_t g1 = (color1 >> 8) & 0xff; + uint32_t b1 = color1 & 0xff; - int w2 = (color2 >> 24) & 0xff; - int r2 = (color2 >> 16) & 0xff; - int g2 = (color2 >> 8) & 0xff; - int b2 = color2 & 0xff; + uint32_t w2 = (color2 >> 24) & 0xff; + uint32_t r2 = (color2 >> 16) & 0xff; + uint32_t g2 = (color2 >> 8) & 0xff; + uint32_t b2 = color2 & 0xff; uint32_t w3 = ((w2 * blend) + (w1 * (255 - blend))) >> 8; uint32_t r3 = ((r2 * blend) + (r1 * (255 - blend))) >> 8; diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 09408995a..558be3ed2 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -98,7 +98,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1910072 +#define VERSION 1910073 char versionString[] = "0.8.5";