Pages: 1 [2]   Go Down
Author Topic: Smooth animation with an 8x8 RGB LED matrix  (Read 20571 times)
0 Members and 2 Guests are viewing this topic.
Europe / Germany
Offline Offline
Sr. Member
****
Karma: 13
Posts: 383
keep it simple
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...mapped to a 240 LED Strip with WS2812 on a cylindrical matrix...

« Last Edit: October 09, 2013, 06:36:01 am by Helmuth » Logged

Europe / Germany
Offline Offline
Sr. Member
****
Karma: 13
Posts: 383
keep it simple
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
/*
 * 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);
}
Logged

Pages: 1 [2]   Go Up
Jump to: