My FastLED-driven jacket is shaping up....

My FastLED-driven jacket is shaping up…

This sequence is using an update of Daniel’s Grid Mapping code and a modified Fire2014. The fire runs in a virtual matrix which is mapped to the actual positions of the LEDs inside the jacket. I’ve adapted a couple of the other cool effects from examples in the forum. Thanks to everyone for the inspiration!

As I approach 500 LEDs it’s starting to chug a little on the poor Flora I’m using to run it. I already had to turn of 2.1’s dithering because each frame takes too long to calculate. Might have to move up to a better micro to smooth out the animation :frowning:

BTW, does anyone have an example of plasma code built on FastLED’s lib8tion?
http://www.youtube.com/watch?v=8Zi45LUYkuk

internet high five!

I’m running off a Teensy 3.0 with 640 LEDs (WS2812Bs) and it’s plenty fast enough, even with dithering on. Here’s my plasma code. Play with those constants and palettes to vary the effects.

virtual void draw(int rawPot, int rawMic, bool button) {
    frame += 100;
    for (int x = 0; x < WIDTH; x++) {
        for (int y = 0; y < HEIGHT; y++) {
            int16_t v = 0;
            uint16_t wibble = sin8(frame);
            v += sin16(x * wibble * 8 + frame);
            v += cos16(y * (128 - wibble) * 4 + frame);
            v += sin16(y * x * cos8(-frame) / 2);
            
            pixel(x, y) = ColorFromPalette(palette, (v >> 8) + 127);
        }
    }      
}

I’m also doing noise, but I’m not sure if this will fly on a Flora:

class Perlin : public Effect {

private:
uint8_t hue;
uint16_t speed;
uint16_t scale;
uint16_t x;
uint16_t y;
uint16_t z;

uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];

public:
Perlin(CRGB *leds) : Effect(leds), hue(0), speed(16), scale(30) {
x = random16();
y = random16();
z = random16();
}

virtual void draw(int rawPot, int rawMic, bool button) {
    fillnoise8();
    for (int i = 0; i < WIDTH; i++) {
        for (int j = 0; j < HEIGHT; j++) {
            // We use the value at the (i,j) coordinate in the noise
            // array for our brightness, and the flipped value from (j,i)
            // for our pixel's hue.

// pixel(i, j) = CHSV(noise[j][i], 255, noise[i][j]);

            // You can also explore other ways to constrain the hue used, like below
            pixel(i, j) = CHSV(hue + (noise[j][i]>>2), 255, noise[i][j]);
        }
    }
    hue++;
}

void fillnoise8() {
    for (int i = 0; i < MAX_DIMENSION; i++) {
        int ioffset = scale * i;
        for (int j = 0; j < MAX_DIMENSION; j++) {
            int joffset = scale * j;
            noise[i][j] = inoise8(x + ioffset, y + joffset, z);
        }
    }
    z += speed;
}

};

This looks amazing!! Great work!

@Robert_Atkins thanks! Super helpful. Ive got your plasma up and running & will adjust it tonight with it for my slower framerate…

I’ve also got a spare Teensy 3 so I’ll see if that helps — do you have to level shift in some way to use the Teensy (3.3v) with your 2812s?

No level shifting, works fine.

(omg) you’re right - the Teensy is SO much faster. it’s handling this stuff so fast that now I have to actually slow down my sketches somehow… thanks for the hint

Heh. My main loop() waits until 60ms have passed before executing again.

Er, that is 1/60th of a second.

@Robert_Atkins hey, thanks for the Plasma effect code! It works like a charm, I’ve just made small tweaks for it to fit my matrix size and timing (adding some rotation around the center point made the whole thing a bit crazier too :slight_smile: )

Got the Teensy slowed down, and everything is much smoother. This thing is a powerhouse, so glad you inspired me to switch!

I’m wondering if you’re planning to update your bitbucket with the latest code? Reason I ask is because I’m about to write an Effect base class like your own, but I can see that you’ve since bumped up your main loop with Effect tween blends, your pot and sound readings, etc. My jacket doesn’t have any of that stuff (and due to different LED layout I can’t use your pixel-perfect Effect classes, my jacket is designed for blends like the Plasma) but that cycle & blend loop would be a real timesaver!

(Gonna clean up my own code and github it tonight…)

I’ll put it all up after the Burn! How’d you do the rotation?

Awesome. Look forward to seeing it…

For rotation I use some code adapted from Daniel’s GridMapping sample:

// Set the rotation angle
void rotate(uint8_t rotate) {
angle=rotate;
revcosval = 2 * ((int)cos8(256-angle)-128);
revsinval = 2 * ((int)sin8(256-angle)-128);
}

// Rotate any particular point around the center
void rtpt_rev(int & x, int & y) {
if(angle) {
int _x = x - MX/2;
int _y = y - MX/2;
x = (_x * revcosval) - (_y * revsinval);
y = (_x * revsinval) + (_y * revcosval);
x /= 256;
y /= 256;
x += (MX/2);
y += (MX/2);
}

(MX and MY are both 255)

IS great!! Nice work buddy.