// https://forum.makerforums.info/t/2-dimensional-blur-this-video-shows-the-new-blur2d-capability-newly-available-on-the-fastled/64648
// https://gist.github.com/kriegsman/5adca44e14ad025e6d3b
#include <FastLED.h>
const uint8_t kMatrixWidth = 16;
const uint8_t kMatrixHeight = 16;
const uint8_t kBorderWidth = 1;
#define NUM_LEDS (kMatrixWidth*kMatrixHeight)
CRGB leds[NUM_LEDS];
// Color correction for the SmartMatrix
#define COLOR_CORRECTION CRGB(255,110,178)
void setup()
{
// Serial.begin(115200);
FastLED.addLeds<NEOPIXEL, 3>(leds, NUM_LEDS).setCorrection(COLOR_CORRECTION);
}
void loop()
{
static uint8_t counter = 0 ;
// Apply some blurring to whatever's already on the matrix
// Note that we never actually clear the matrix, we just constantly
// blur it repeatedly. Since the blurring is 'lossy', there's
// an automatic trend toward black -- by design.
if( counter % 3 == 0 ) {
uint8_t blurAmount = beatsin8(2, 100, 150);
blur2d( leds, kMatrixWidth, kMatrixHeight, blurAmount);
// Serial.println(blurAmount);
}
counter++;
// Use two out-of-sync sine waves
uint8_t i = beatsin8( 27, kBorderWidth, kMatrixHeight - kBorderWidth);
uint8_t j = beatsin8( 41, kBorderWidth, kMatrixWidth - kBorderWidth);
// Also calculate some reflections
uint8_t ni = (kMatrixWidth - 1) - i;
uint8_t nj = (kMatrixWidth - 1) - j;
// The color of each point shifts over time, each at a different speed.
uint16_t ms = millis();
leds[XY( i, j)] += CHSV( ms / 11, 255, 255);
leds[XY( j, i)] += CHSV( ms / 13, 255, 255);
leds[XY(ni, nj)] += CHSV( ms / 17, 255, 255);
leds[XY(nj, ni)] += CHSV( ms / 29, 255, 255);
leds[XY( i, nj)] += CHSV( ms / 37, 255, 255);
leds[XY(ni, j)] += CHSV( ms / 41, 255, 255);
FastLED.show();
}
uint16_t XY(uint8_t x, uint8_t y) {
if (x >= kMatrixWidth) return NUM_LEDS;
if (y >= kMatrixHeight) return NUM_LEDS;
return y * kMatrixWidth + x;
}
mega:SCL
mega:SDA
mega:AREF
mega:GND.1
mega:13
mega:12
mega:11
mega:10
mega:9
mega:8
mega:7
mega:6
mega:5
mega:4
mega:3
mega:2
mega:1
mega:0
mega:14
mega:15
mega:16
mega:17
mega:18
mega:19
mega:20
mega:21
mega:5V.1
mega:5V.2
mega:22
mega:23
mega:24
mega:25
mega:26
mega:27
mega:28
mega:29
mega:30
mega:31
mega:32
mega:33
mega:34
mega:35
mega:36
mega:37
mega:38
mega:39
mega:40
mega:41
mega:42
mega:43
mega:44
mega:45
mega:46
mega:47
mega:48
mega:49
mega:50
mega:51
mega:52
mega:53
mega:GND.4
mega:GND.5
mega:IOREF
mega:RESET
mega:3.3V
mega:5V
mega:GND.2
mega:GND.3
mega:VIN
mega:A0
mega:A1
mega:A2
mega:A3
mega:A4
mega:A5
mega:A6
mega:A7
mega:A8
mega:A9
mega:A10
mega:A11
mega:A12
mega:A13
mega:A14
mega:A15
neopixels:DOUT
neopixels:VDD
neopixels:VSS
neopixels:DIN
FPS: 0
Power: 0.00W
Power: 0.00W