FastLED 3.9.15
Loading...
Searching...
No Matches
Blur2d.ino
Go to the documentation of this file.
1// @filter: (memory is large)
2
12
13// UIDescription: This example shows how to blur a strip of LEDs in 2d.
14
15#include <Arduino.h>
16#include <FastLED.h>
17
18#include "fl/ui/ui.h"
19#include "fl/math/xymap.h"
20
21
22#define WIDTH 22
23#define HEIGHT 22
24
25#define NUM_LEDS (WIDTH * HEIGHT)
26#define BLUR_AMOUNT 172
27#define DATA_PIN 2 // Change this to match your LED strip's data pin
28#define BRIGHTNESS 255
29#define SERPENTINE true
30
32uint8_t pos = 0;
33bool toggle = false;
35
36void setup() {
37 FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS)
38 .setScreenMap(xymap); // Necessary when using the FastLED web compiler to display properly on a web page.
39 FastLED.setBrightness(BRIGHTNESS);
40 Serial.println("setup");
41}
42
43void loop() {
44 static int x = random(WIDTH);
45 static int y = random(HEIGHT);
46 static fl::CRGB c = fl::CRGB(0, 0, 0);
49 x = random(WIDTH);
50 y = random(HEIGHT);
51 uint8_t r = random(255);
52 uint8_t g = random(255);
53 uint8_t b = random(255);
54 c = fl::CRGB(r, g, b);
55 }
56 leds[xymap(x, y)] = c;
57 FastLED.show();
58 delay(20);
59}
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
#define BRIGHTNESS
XYMap xymap
int y
Definition simple.h:93
int x
Definition simple.h:92
#define SERPENTINE
Definition Blur2d.ino:29
#define BLUR_AMOUNT
Definition Blur2d.ino:26
void setup()
Definition Blur2d.ino:36
fl::XYMap xymap(WIDTH, HEIGHT, SERPENTINE)
void loop()
Definition Blur2d.ino:43
uint8_t pos
Definition Blur.ino:11
bool toggle
Definition Blur.ino:12
#define DATA_PIN
Definition ClientReal.h:82
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
#define WIDTH
#define HEIGHT
void blur2d(fl::span< CRGB > leds, u8 width, u8 height, fract8 blur_amount, const XYMap &xymap) FL_NOEXCEPT
Definition blur.h:153
constexpr EOrder GRB
Definition eorder.h:19
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
Definition lib8tion.h:1045
fl::CRGB CRGB
Definition video.h:15
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
#define Serial
Definition serial.h:304
Aggregator header for the fl/ui/ family of per-element UI types.