//Perlin noise fire procedure
//16x16 rgb led matrix demo
//Yaroslaw Turbin, 22.06.2020
#include "FastLED.h"
// Matrix size
#define NUM_ROWS 12
#define NUM_COLS 5
#define NUM_LEDS NUM_ROWS * NUM_COLS
// LEDs pin
#define DATA_PIN 5
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
// LED brightness
#define BRIGHTNESS 255
#define MAX_POWER_MILLIAMPS 800
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setMaxPowerInVoltsAndMilliamps(5, MAX_POWER_MILLIAMPS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
#define scalenoise 80
int a = millis();
for (byte i = 0; i < NUM_COLS; i++) {
for (byte j = 0; j < NUM_ROWS; j++) {
leds[XY(i,j)] = ColorFromPalette (HeatColors_p , qsub8 (inoise8 (i * scalenoise , j * scalenoise+ a , a /3),
abs8(j - (NUM_ROWS-1)) * 255 / (NUM_ROWS+4)), BRIGHTNESS);
}}
FastLED.show();
}
uint16_t XY (uint8_t x, uint8_t y) { return (y * NUM_COLS + x);}