Hi Folks,
I'm trying to put together some old and new animations for a symbol I have made,
Celtic Trinity.
I have found some code online that displays rainbow and twinkles at the same time on the same pixel strip in separate sections. I have adjusted the code to work on my symbol and it look amazing (I'm quite easily pleased). Unfortunately this is a sketch of its own, not quite what I'm after.
Is it possible to put this code into its own animation so I can use it in a string with other animations ?
#include "FastLED.h"
// TwoAnimationsAtTheSameTime
// Example showing one way to run two different animations on
// two different parts of one LED array at the same time.
//
// The three keys to success here are:
//
// 1. Move the drawing of each animation into a separate 'draw' function,
// each of which is called from 'loop()'. Each 'draw' function draws
// just one frame of it's particular animation and then returns.
//
// 2. The draw functions each take two arguments that tell them
// where to draw: a starting LED number, and a length. All updating
// the leds array done inside the draw function should use these
// arguments.
//
// 3. Move any 'FastLED.show()' and 'delay()' calls OUT from the draw
// functions and into 'loop()'.
//
// -Mark Kriegsman, July 2015
#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif
#define DATA_PIN 7
//#define CLK_PIN 4
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 132
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 50
#define FRAMES_PER_SECOND 100
uint8_t gHue = 0; // rotating "base color" used by both patterns
void setup() {
delay(3000); // 3 second delay for recovery
// tell FastLED about the LED strip configuration
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS);
// set master brightness control
FastLED.setBrightness(BRIGHTNESS);
}
// The loop function calls each 'draw' function as needed to put
// some color data into some portion of the LED strip.
// The loop function then calls FastLED.show() and delay().
void loop() {
int symbolStart = 0;
int symbolLength = (NUM_LEDS - 60);
int ringStart = symbolStart + symbolLength;
int ringLength = NUM_LEDS - symbolLength;
// Draw confetti on the ring section. This does NOT call FastLED.show() or delay().
drawConfetti( ringStart, ringLength);
// Draw rainbow on the arc sections. This does NOT call FastLED.show() or delay().
drawRainbow( symbolStart, symbolLength);
// Now, here's where we call FastLED.show() and delay() -- only from loop() directly.
// send the 'leds' array out to the actual LED strip
FastLED.show();
// insert a delay to keep the framerate modest
FastLED.delay(1000/FRAMES_PER_SECOND);
// do some periodic updates
EVERY_N_MILLISECONDS( 10 ) { gHue--; } // slowly cycle the "base color" through the rainbow
}
void drawRainbow(int startpixel, int pixelcount) {
// FastLED's built-in rainbow generator
fill_rainbow( leds + startpixel, pixelcount, gHue, 17);
}
void drawConfetti(int startpixel, int pixelcount) {
// random colored speckles that blink in and fade smoothly
fadeToBlackBy( leds + startpixel, pixelcount, 30);
int pos = random16( pixelcount);
leds[pos + startpixel] += CHSV( gHue -32 + random8(64), 200, 255);
}
If this can be achieved, it will open up a whole new set of animation ideas for this, and other shapes I have. Here's 1 that I got a lot of help with from @alto777 , @gfvalvo , @xfpd ,and @Grumpy_Mike . I don't think I could have done it alone.
Impossible Triangle
A friend of mine suggested that the three number 7's it was supposed to be would make an impossible triangle, so the design changed (for the better I think).
The Trinity shape would be able to display a lot more if it can run 1 thing on the ring and something else on the arcs.
I have a few ideas for animations that require different things on different parts of the strip.
Any help is gratefully received.
Thanks