#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 15 // resolution of cilindrical lookup table
#define LED_ROWS 16
#define NUM_LEDS 240
//+++++++++++++++++++
#define COLOR_ORDER GRB
// LED brightness
#define BRIGHTNESS 255
//+++++++++++++++++++++++++++++++
// Params for width and height
//CRGB leds[ NUM_LEDS ];
CRGB leds [NUM_LEDS+1];
//++++++++++++++++++++++++++++++++++
//Lotus
//Stepko and Sutaburosu
//14/04/23
#define petals 5
bool setupm = 1;
const uint8_t C_X = LED_COLS / 2;
const uint8_t C_Y = LED_ROWS / 2;
const uint8_t mapp = 255 / LED_COLS;
struct{
uint8_t angle;
uint8_t radius;
} rMap[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();
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++) {
rMap[x + C_X][y + C_Y].angle = 128 * (atan2(y, x) / PI);
rMap[x + C_X][y + C_Y].radius = hypot(x, y) * mapp; //thanks Sutaburosu
}
}
}
static byte speed = 2;
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 = rMap[x][y].angle;
byte radius = rMap[x][y].radius;
leds[XY(x, y)] = CHSV(248,181,sin8(t-radius+sin8(t + angle*petals)/5));
}
}
delay(20);
}
//static byte setup = 1;
uint16_t XY (uint8_t x, uint8_t y) { return (y * LED_COLS + x);}
//++++++++++++++++++++++++++++++++++++++