Improved running effects

This commit is contained in:
cschwinne 2019-10-07 23:22:56 +02:00
parent ae1bc96006
commit d8859b9f0a
3 changed files with 25 additions and 16 deletions

View File

@ -413,10 +413,11 @@ uint16_t WS2812FX::mode_theater_chase_rainbow(void) {
*/ */
uint16_t WS2812FX::running_base(bool saw) { uint16_t WS2812FX::running_base(bool saw) {
uint8_t x_scale = SEGMENT.intensity >> 2; uint8_t x_scale = SEGMENT.intensity >> 2;
uint32_t counter = (now * SEGMENT.speed) >> 9;
for(uint16_t i=0; i < SEGLEN; i++) { for(uint16_t i=0; i < SEGLEN; i++) {
uint8_t s = 0; uint8_t s = 0;
uint8_t a = i*x_scale - (SEGENV.step >> 4); uint8_t a = i*x_scale - counter;
if (saw) { if (saw) {
if (a < 16) if (a < 16)
{ {
@ -428,8 +429,7 @@ uint16_t WS2812FX::running_base(bool saw) {
s = sin8(a); s = sin8(a);
setPixelColor(SEGMENT.start + i, color_blend(color_from_palette(SEGMENT.start + i, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), s)); 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 FRAMETIME;
return 20;
} }
@ -854,11 +854,16 @@ uint16_t WS2812FX::mode_chase_flash_random(void) {
* Alternating pixels running function. * Alternating pixels running function.
*/ */
uint16_t WS2812FX::running(uint32_t color1, uint32_t color2) { 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++) { 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)) 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 } else
{ {
setPixelColor(SEGMENT.stop -i -1, color1); 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; if (it != SEGENV.step )
return 35 + ((350 * (uint32_t)(255 - SEGMENT.speed)) / 255); {
SEGENV.aux0 = (SEGENV.aux0 +1) % (pxw*2);
SEGENV.step = it;
}
return FRAMETIME;
} }
/* /*

View File

@ -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 == 0) return color1;
if(blend == 255) return color2; if(blend == 255) return color2;
int w1 = (color1 >> 24) & 0xff; uint32_t w1 = (color1 >> 24) & 0xff;
int r1 = (color1 >> 16) & 0xff; uint32_t r1 = (color1 >> 16) & 0xff;
int g1 = (color1 >> 8) & 0xff; uint32_t g1 = (color1 >> 8) & 0xff;
int b1 = color1 & 0xff; uint32_t b1 = color1 & 0xff;
int w2 = (color2 >> 24) & 0xff; uint32_t w2 = (color2 >> 24) & 0xff;
int r2 = (color2 >> 16) & 0xff; uint32_t r2 = (color2 >> 16) & 0xff;
int g2 = (color2 >> 8) & 0xff; uint32_t g2 = (color2 >> 8) & 0xff;
int b2 = color2 & 0xff; uint32_t b2 = color2 & 0xff;
uint32_t w3 = ((w2 * blend) + (w1 * (255 - blend))) >> 8; uint32_t w3 = ((w2 * blend) + (w1 * (255 - blend))) >> 8;
uint32_t r3 = ((r2 * blend) + (r1 * (255 - blend))) >> 8; uint32_t r3 = ((r2 * blend) + (r1 * (255 - blend))) >> 8;

View File

@ -98,7 +98,7 @@
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 1910072 #define VERSION 1910073
char versionString[] = "0.8.5"; char versionString[] = "0.8.5";