//source: https://editor.soulmatelights.com/gallery/250-flower
#include "FastLED.h"
#define DATA_PIN 2
#define BRIGHTNESS 255
#define NUM_LEDS 256
#define NUM_COLS 16
#define NUM_ROWS 16
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
//#define FRAMES_PER_SECOND 60
const uint8_t kMatrixWidth = 16;
const uint8_t kMatrixHeight = 16;
const bool kMatrixSerpentineLayout = false;
float c = 0.3; //diameter
float angle = 0.1;
int counter = 0;
void setup() {
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS); //setCorrection(TypicalLEDStrip);
//FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
//Serial.begin(115200);
}
void loop()
{
EVERY_N_MILLISECONDS(4000) {
angle +=0.1;
}
float n = triwave8( counter)*2.2;
float a = n * angle;
float r = c * sqrt16(n);
byte x = r * cos(a)+NUM_COLS/2;
byte y = r * sin(a)+NUM_ROWS/2;
leds [XY(x,y)] += CHSV (millis(),255,BRIGHTNESS);
counter +=1;
fadeToBlackBy(leds, NUM_LEDS, 10); //20
//blur2d(leds,NUM_COLS, NUM_ROWS, 8 );
FastLED.show();
}
uint16_t XY( uint8_t x, uint8_t y)
{
uint16_t i;
if( kMatrixSerpentineLayout == false) {
i = (y * kMatrixWidth) + x;
}
if( kMatrixSerpentineLayout == true) {
if( y & 0x01) {
// Odd rows run backwards
uint8_t reverseX = (kMatrixWidth - 1) - x;
i = (y * kMatrixWidth) + reverseX;
} else {
// Even rows run forwards
i = (y * kMatrixWidth) + x;
}
}
return i;
}