//Perlin noise fire procedure
//16x16 rgb led matrix demo
//Yaroslaw Turbin, 22.06.2020
//Modified by Marc Miller add more white near engines, and push fire to end.
#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];
extern const TProgmemRGBPalette16 RocketColors_p FL_PROGMEM =
{
0xFF0000, 0xFF3300, 0xFF6600, 0xFF9900,
0xFFCC00, 0xFFFF00, 0xFFFF33, 0xFFFF66,
0xFFFF99, 0xFFFFCC, 0xFFFFCC, 0xFFFFFF,
0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF
};
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() * 2;
for (byte i = 0; i < NUM_COLS; i++) {
for (byte j = 0; j < NUM_ROWS; j++) {
uint8_t index = qsub8 (inoise8 (i * scalenoise , j * scalenoise+ a , a /3), abs8(j - (NUM_ROWS-1)) * 255 / (NUM_ROWS+4));
leds[XY(i,j)] = ColorFromPalette (RocketColors_p , scale8(index, 220), BRIGHTNESS);
}
}
FastLED.show();
}
uint16_t XY (uint8_t x, uint8_t y) { return (y * NUM_COLS + x);}