#include <FastLED.h>
#define DATA_PIN 3 //set your leds datapin change to 32 for m5 atom lite
#define LED_TYPE WS2812B //leds type
#define COLOR_ORDER GRB
//++++++++++++++++++++++++++++++++
#define LED_COLS 32 // resolution of cilindrical lookup table
#define LED_ROWS 32
#define NUM_LEDS 1024
//+++++++++++++++++++
#define COLOR_ORDER GRB
// LED brightness
#define BRIGHTNESS 255
CRGB leds [NUM_LEDS+1];
//+++++++++++++++++++++++++++++++
bool setupm = 1;
#define C_X LED_COLS / 2
#define C_Y LED_ROWS / 2
byte XY_angle[LED_COLS][LED_ROWS];
byte XY_radius[LED_COLS][LED_ROWS];
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS)
.setCorrection( TypicalLEDStrip );
//FastLED.clear();
}
void loop() {
LEDS.show();
// FastLED.clear();
if (setupm) {
setupm = 0;
for (int8_t x = -C_X; x < C_X + (LED_COLS % 2); x++) {
for (int8_t y = -C_Y; y < C_Y + (LED_ROWS % 2); y++) {
// XY_angle[x + C_X][y + C_Y] = atan2(y, x) * (180. / 2. / PI) * LED_COLS;
XY_angle[x + C_X][y + C_Y] = (atan2(x, y) / PI) * 128 + 127; //thanks ldirko
XY_radius[x + C_X][y + C_Y] = hypot(x, y); //thanks Sutaburosu
}
}
}
static byte speed = 1;
static uint32_t t;
t += speed;
for (uint8_t x = 0; x < LED_COLS; x++) {
for (uint8_t y = 0; y < LED_ROWS; y++) {
byte angle = XY_angle[x][y];
byte radius = XY_radius[x][y];
leds[XY(x, y)] = CHSV(t + radius * (255 / LED_COLS), 255, sin8(sin8(t+angle*5+( radius * (255 / LED_COLS)))+t * 4 + sin8(t * 4 - radius * (255 / LED_COLS)) + angle * 5));
}
}
delay(16);
}
uint16_t XY (uint8_t x, uint8_t y) { return (y * LED_COLS + x);}