Go Down

Topic: Smooth animation with an 8x8 RGB LED matrix (Read 25 times) previous topic - next topic

Helmuth

#15
Oct 09, 2013, 09:01 am Last Edit: Oct 09, 2013, 01:36 pm by Helmuth Reason: 1
...mapped to a 240 LED Strip with WS2812 on a cylindrical matrix...

http://www.youtube.com/watch?v=y7jLOD_df7g&feature=player_embedded

Helmuth

Because many people asked here a quick solution how to map the whole matrix to a strip:

Code: [Select]
/*
* Copyright (C) 2013 Gilad Dayagi.  All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/

/*
  * An example for the Arduino particle system library
  * Creates a spinning galaxy effect
  *
  * Note: this example uses the colorduino library becuse that is what I had,
  * but any device that supports setting a pixel to an RGB value can be used
  */

//#include <Colorduino.h>
#include <FastSPI_LED2.h>
#include "ParticleSys.h"
#include "Particle_Bounce.h"
#include "Emitter_Spin.h"
#include "PartMatrix.h"

#define NUM_LEDS 240

CRGB leds[NUM_LEDS];

const byte numParticles = 600;

Particle_Bounce particles[numParticles];
Emitter_Spin emitter(112, 112, 5, 7);
ParticleSys pSys(numParticles, particles, &emitter);
PartMatrix pMatrix;

/**
* Render the particles into a low-resolution matrix
*/
void drawMatrix(){
    pMatrix.fade();
    pMatrix.render(particles, numParticles);
    //update the actual LED matrix
   for (byte y=0;y<8;y++) {
        for(byte x=0;x<8;x++) {
            //Colorduino.SetPixel(x, y, pMatrix.matrix[x][y].r, pMatrix.matrix[x][y].g, pMatrix.matrix[x][y].b);
    leds[40+(x*2)+y*20].r = pMatrix.matrix[x][y].r;
    leds[41+(x*2)+y*20].r = pMatrix.matrix[x][y].r;
    leds[40+(x*2)+y*20].g = pMatrix.matrix[x][y].g;
    leds[41+(x*2)+y*20].g = pMatrix.matrix[x][y].g;
    leds[40+(x*2)+y*20].b = pMatrix.matrix[x][y].b;
    leds[41+(x*2)+y*20].b = pMatrix.matrix[x][y].b;
        }
    }
}

void setup()
{
  //Colorduino.Init(); // initialize the board
  FastLED.addLeds<WS2812, 6, GRB>(leds, NUM_LEDS);
  // compensate for relative intensity differences in R/G/B brightness
  // array of 6-bit base values for RGB (0~63)
  // whiteBalVal[0]=red
  // whiteBalVal[1]=green
  // whiteBalVal[2]=blue
  byte whiteBalVal[3] = {36,63,7}; // for LEDSEE 6x6cm round matrix
  //Colorduino.SetWhiteBal(whiteBalVal);
 
  randomSeed(analogRead(0));
 
  pMatrix.reset();

  //Colorduino.FlipPage(); // swap screen buffers to show it
 
  emitter.oscilate = true;
}

void loop()
{
    pSys.update();
    drawMatrix();
    //Colorduino.FlipPage();
    FastSPI_LED.show();
    delay(5);
}

Go Up