#include "FastLED.h"
const uint8_t kBorderWidth = 2;
#define DATA_PIN 3
#define LED_TYPE WS2812B //leds type
#define COLOR_ORDER GRB
#define COLS 15 // resolution of cilindrical lookup table
#define ROWS 16
#define NUM_LEDS 240
CRGB leds [NUM_LEDS+1];
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS)
.setCorrection( TypicalLEDStrip );
FastLED.clear();
}
void loop()
{
// Apply some blurring to whatever's already on the matrix
// Note that we never actually clear the matrix, we just constantly
// blur it repeatedly. Since the blurring is 'lossy', there's
// an automatic trend toward black -- by design.
uint8_t blurAmount = beatsin16(112,10,255);
blur2d( leds, COLS, ROWS, blurAmount);
// Use two out-of-sync sine waves
uint8_t i = beatsin16( 17, kBorderWidth, COLS-kBorderWidth);
uint8_t j = beatsin16( 14, kBorderWidth, ROWS-kBorderWidth);
// Also calculate some reflections
uint8_t ni = (COLS-1)-i;
uint8_t nj = (ROWS-1)-j;
// The color of each point shifts over time, each at a different speed.
uint16_t ms = millis();
leds[XY(ni,nj)] += CHSV( ms / 17, 20, 255);
leds[XY( i, j)] += CHSV( ms / 11, 100, 255);
leds[XY( j, i)] += CHSV( ms / 13, 200, 255);
leds[XY(ni,nj)] += CHSV( ms / 17, 200, 255);
leds[XY(nj,ni)] += CHSV( ms / 29, 200, 255);
leds[XY( i,nj)] += CHSV( ms / 37, 200, 255);
leds[XY(ni, j)] += CHSV( ms / 41, 200, 255);
leds[XY( i, j)] += CHSV( ms / 11, 200, 255);
leds[XY( j, i)] += CHSV( ms / 13, 200, 255);
leds[XY( i, j)] += CHSV( ms / 11, 200, 255);
leds[XY(nj,ni)] += CHSV( ms / 29, 200, 255);
leds[XY( i,nj)] += CHSV( ms / 37, 200, 255);
leds[XY(ni, j)] += CHSV( ms / 41, 200, 255);
leds[XY(ni, j)] += CHSV( ms / 41, 200, 255);
leds[XY( j, i)] += CHSV( ms / 13, 200, 255);
leds[XY(ni,nj)] += CHSV( ms / 17, 200, 255);
leds[XY(nj,ni)] += CHSV( ms / 29, 200, 255);
leds[XY( i,nj)] += CHSV( ms / 37, 200, 255);
FastLED.show();
}
uint16_t XY (uint8_t x, uint8_t y) { return (y * COLS + x);}