//F_lying fibonacci 256
//Fastled fibonacci 256 RGB leds demo
//Yaroslaw Turbin, 28.01.2020 
//https://vk.com/ldirko
//https://www.reddit.com/user/ldirko/

#include "FastLED.h"

// Matrix size
#define NUM_ROWS 16 
#define NUM_COLS 16
#define NUM_LEDS NUM_ROWS*NUM_COLS
// LEDs pin
#define DATA_PIN 3
// LED brightness
#define BRIGHTNESS 255

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  FastLED.setBrightness(BRIGHTNESS);
}

void loop() {
int  a = millis();
int  a1 = a/3;
for (byte j = 0; j < NUM_ROWS; j++) { 
for (byte i = 0; i < NUM_COLS; i++) {
uint16_t ledsindex = XY(i,(NUM_ROWS-1)-j);
leds[ledsindex] = HeatColor(qsub8 (inoise8 (i * 90, j * 90+a, a1), abs8(j - (NUM_ROWS-1)) * 255 / (NUM_ROWS+4)));
}}

FastLED.show();
}

uint16_t XY (uint8_t x, uint8_t y) { return (x * NUM_ROWS + y);}