Go Down

Topic: Smooth animation with an 8x8 RGB LED matrix (Read 34152 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);
}

electroGUS

would like to know if someone successfully ported the led matrix code to the led strip hardware.

im working on it , but it seams that in not only a conversion of coordinates and also adapting to use the led strip functions, but it seams that the libraries itself needs to be modified .
As i still don't think this make sense, im inclined to think , that a better knowledge of how to modify the fountain generation parameters , for a certain led pattern is what is needed.

Then my question, is if somebody have any documentation on the libraries.

thanks
gus

janvier123

We are looking for Arduino Projects. Register today and post your project.

electroGUS

anybody knows how to modify the code in order to include a wider matrix?
I have tried by changing the y range to 30 , but this doesn't work .





/*
 * 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
 * A wandering particle that emits colorful smoke
 *
 * 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
 */

//'r' for rainbowduino, 'c' for colorduino
//#define BOARD 'r'

//#if BOARD == 'c'
//#include <Colorduino.h>
//#else
//#include <Rainbowduino.h>
//#endif
#include "FastLED.h"
#include "ParticleSys.h"
#include "Particle_Std.h"
#include "Particle_Fixed.h"
#include "Emitter_Fountain.h"
#include "PartMatrix.h"

const byte numParticles = 40;
boolean pulseOn = false;

Particle_Std particles[numParticles];
Particle_Fixed source;
Emitter_Fountain emitter(0, 1, 10, &source);
ParticleSys pSys(numParticles, particles, &emitter);
PartMatrix pMatrix;

#define NUM_LEDS 237

CRGB leds[NUM_LEDS];

/**
 * Render the particles into a low-resolution matrix
 */
void drawMatrix(){
    pMatrix.reset();
    pMatrix.render(particles, numParticles);
    //update the actual LED matrix
    int LEDnum ;
    for (byte y=0;y<8;y++) {
        for(byte x=0;x<8;x++) {
//#if BOARD == 'c'
//            Colorduino.SetPixel(x, y, pMatrix.matrix
  • [y].r, pMatrix.matrix
  • [y].g, pMatrix.matrix
  • [y].b);

//#else
//            Rb.setPixelXY(PS_PIXELS_Y-y-1, x, pMatrix.matrix
  • [y].r, pMatrix.matrix
  • [y].g, pMatrix.matrix
  • [y].b);

//#endif

  if ((y & 01) == 0) {
    LEDnum = (y+1)*30 - x-1;
  } else {
    LEDnum=y*30+x;
  } 

    leds[LEDnum].r = pMatrix.matrix
  • [y].r;

    leds[LEDnum].g = pMatrix.matrix
  • [y].g;

    leds[LEDnum].b = pMatrix.matrix
  • [y].b;

        }
    }
}
//  *******************************************//

void setup()
{
//#if BOARD == 'c'   
   // Colorduino.Init(); // initialize the board
     FastLED.addLeds<WS2812B, 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);
//#else
  //  Rb.init();
//#endif   

    randomSeed(analogRead(0));

    //source.vx = 3;
    //source.vy = 1;
    source.x = 0;
    source.y = 1;
    Emitter_Fountain::minLife = 20;
    Emitter_Fountain::maxLife = 80;
    Particle_Std::ay = 1;
    //PartMatrix::isOverflow = false;

    //init all pixels to zero
    pMatrix.reset();
}

void loop()
{
    pSys.update();
    drawMatrix();
//#if BOARD == 'c'   
    //Colorduino.FlipPage();
     FastLED.show();
//#endif   
    delay(40);
}
gus

robtillaart

these are the important lines.
Code: [Select]

   for (byte y=0;y<8;y++) {
        for(byte x=0;x<8;x++) {


And please modify your post and put the code between [code]...[/code] tags
it is now unreadable
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up