FastLED 3.9.12
Loading...
Searching...
No Matches
Blur2d.ino
1// UIDescription: This example shows how to blur a strip of LEDs in 2d.
2
3#include "fl/ui.h"
4#include "fl/xymap.h"
5#include <FastLED.h>
6
7using namespace fl;
8
9#define WIDTH 22
10#define HEIGHT 22
11
12#define NUM_LEDS (WIDTH * HEIGHT)
13#define BLUR_AMOUNT 172
14#define DATA_PIN 2 // Change this to match your LED strip's data pin
15#define BRIGHTNESS 255
16#define SERPENTINE true
17
18CRGB leds[NUM_LEDS];
19uint8_t pos = 0;
20bool toggle = false;
21XYMap xymap(WIDTH, HEIGHT, SERPENTINE);
22
23void setup() {
24 FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS)
25 .setScreenMap(xymap); // Necessary when using the FastLED web compiler to display properly on a web page.
26 FastLED.setBrightness(BRIGHTNESS);
27}
28
29void loop() {
30 static int x = random(WIDTH);
31 static int y = random(HEIGHT);
32 static CRGB c = CRGB(0, 0, 0);
33 blur2d(leds, WIDTH, HEIGHT, BLUR_AMOUNT, xymap);
35 x = random(WIDTH);
36 y = random(HEIGHT);
37 uint8_t r = random(255);
38 uint8_t g = random(255);
39 uint8_t b = random(255);
40 c = CRGB(r, g, b);
41 }
42 leds[xymap(x, y)] = c;
43 FastLED.show();
44 delay(20);
45}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:45
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:719
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:94
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:79
WS2812B controller class.
Definition FastLED.h:208
@ GRB
Green, Red, Blue (0102)
Definition eorder.h:17
void blur2d(CRGB *leds, uint8_t width, uint8_t height, fract8 blur_amount, const XYMap &xymap)
Two-dimensional blur filter.
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
Definition lib8tion.h:1318
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54