From 61101987f933eefc96b29dc0d399b08db3087079 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 1 Mar 2021 19:50:14 +0100 Subject: [PATCH] Minor tweaks to Chunchun & Plasma FX. --- wled00/FX.cpp | 22 +++++++++++++--------- wled00/FX.h | 10 +++++----- wled00/wled.h | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 6d4f3e67d..e01722618 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3159,13 +3159,17 @@ uint16_t WS2812FX::mode_tetrix(void) { / adapted from https://github.com/atuline/FastLED-Demos/blob/master/plasma/plasma.ino */ uint16_t WS2812FX::mode_plasma(void) { - uint8_t thisPhase = beatsin8(6+_segment_index%3,-64,64); // Setting phase change for a couple of waves. - uint8_t thatPhase = beatsin8(7+_segment_index%3,-64,64); + // initialize phases on start + if (SEGENV.call == 0) { + SEGENV.aux0 = random8(0,2); // add a bit of randomness + } + uint8_t thisPhase = beatsin8(6+SEGENV.aux0,-64,64); + uint8_t thatPhase = beatsin8(7+SEGENV.aux0,-64,64); for (int i = 0; i < SEGLEN; i++) { // For each of the LED's in the strand, set color & brightness based on a wave as follows: - uint8_t colorIndex = cubicwave8((i*(1+ 3*(SEGMENT.speed >> 5)))+(thisPhase) & 0xFF)/2 // factor=23 // Create a wave and add a phase change and add another wave with its own phase change. - + cos8((i*(1+ 2*(SEGMENT.speed >> 5)))+(thatPhase) & 0xFF)/2; // factor=15 // Hey, you can even change the frequencies if you wish. - uint8_t thisBright = qsub8(colorIndex, beatsin8(6,0, (255 - SEGMENT.intensity)|0x01 )); + uint8_t colorIndex = cubicwave8((i*(2+ 3*(SEGMENT.speed >> 5))+thisPhase) & 0xFF)/2 // factor=23 // Create a wave and add a phase change and add another wave with its own phase change. + + cos8((i*(1+ 2*(SEGMENT.speed >> 5))+thatPhase) & 0xFF)/2; // factor=15 // Hey, you can even change the frequencies if you wish. + uint8_t thisBright = qsub8(colorIndex, beatsin8(7,0, (128 - (SEGMENT.intensity>>1)))); CRGB color = ColorFromPalette(currentPalette, colorIndex, thisBright, LINEARBLEND); setPixelColor(i, color.red, color.green, color.blue); } @@ -3593,15 +3597,15 @@ uint16_t WS2812FX::mode_chunchun(void) { fill(SEGCOLOR(1)); uint16_t counter = now*(6 + (SEGMENT.speed >> 4)); - uint16_t numBirds = SEGLEN >> 2; - uint16_t span = SEGMENT.intensity << 8; + uint16_t numBirds = 2 + (SEGLEN >> 3); // 2 + 1/8 of a segment + uint16_t span = (SEGMENT.intensity << 8) / numBirds; for (uint16_t i = 0; i < numBirds; i++) { - counter -= span/numBirds; + counter -= span; uint16_t megumin = sin16(counter) + 0x8000; uint32_t bird = (megumin * SEGLEN) >> 16; - uint32_t c = color_from_palette((i * 255)/ numBirds, false, true, 0); + uint32_t c = color_from_palette((i * 255)/ numBirds, false, false, 0); // no palette wrapping setPixelColor(bird, c); } return FRAMETIME; diff --git a/wled00/FX.h b/wled00/FX.h index ba139a000..01d83b386 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -322,11 +322,11 @@ class WS2812FX { // segment runtime parameters typedef struct Segment_runtime { // 28 bytes - unsigned long next_time; - uint32_t step; - uint32_t call; - uint16_t aux0; - uint16_t aux1; + unsigned long next_time; // millis() of next update + uint32_t step; // custom "step" var + uint32_t call; // call counter + uint16_t aux0; // custom var + uint16_t aux1; // custom var byte* data = nullptr; bool allocateData(uint16_t len){ if (data && _dataLen == len) return true; //already allocated diff --git a/wled00/wled.h b/wled00/wled.h index 6698021a7..ae75b5a0b 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2103011 +#define VERSION 2103012 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG