FastLED 3.9.15
Loading...
Searching...
No Matches
Wave2d.ino
Go to the documentation of this file.
1
2
3/*
4This demo is best viewed using the FastLED compiler.
5Install: pip install fastled
6Run: fastled <this sketch directory>
7This will compile and preview the sketch in the browser, and enable
8all the UI elements you see below.
9*/
10
11#include "fl/ui.h"
12#include "fx/2d/wave.h"
13#include <Arduino.h>
14#include <FastLED.h>
15
16using namespace fl;
17
18#define HEIGHT 100
19#define WIDTH 100
20#define NUM_LEDS ((WIDTH) * (HEIGHT))
21#define IS_SERPINTINE true
22
24
25UITitle title("Wave2D Demo");
26UIDescription description("Shows the use of the Wave2d effect.");
27
28UIButton button("Trigger");
29UICheckbox autoTrigger("Auto Trigger", true);
30UISlider extraFrames("Extra Frames", 0.0f, 0.0f, 8.0f, 1.0f);
31UISlider slider("Speed", 0.18f, 0.0f, 1.0f);
32UISlider dampening("Dampening", 9.0f, 0.0f, 20.0f, 0.1f);
33UICheckbox halfDuplex("Half Duplex", true);
34UISlider superSample("SuperSampleExponent", 1.f, 0.f, 3.f, 1.f);
35
37
39
40void setup() {
41 Serial.begin(115200);
42 FastLED.addLeds<NEOPIXEL, 2>(leds, NUM_LEDS).setScreenMap(xyMap);
43}
44
46 switch (int(superSample)) {
47 case 0:
49 case 1:
51 case 2:
53 case 3:
55 default:
57 }
58}
59
61 int x = random() % WIDTH;
62 int y = random() % HEIGHT;
63 waveSim.setf(x, y, 1);
64}
65
66void loop() {
67 // Your code here
68 waveSim.setSpeed(slider);
69 waveSim.setDampening(dampening);
70 waveSim.setHalfDuplex(halfDuplex);
71 waveSim.setSuperSample(getSuperSample());
72 if (button) {
74 }
75
76
78 if (autoTrigger) {
80 }
81 }
82
83 waveSim.update();
84 for (int y = 0; y < HEIGHT; y++) {
85 for (int x = 0; x < WIDTH; x++) {
86 uint8_t value8 = waveSim.getu8(x, y);
87 uint32_t idx = xyMap.mapToIndex(x, y);
88 leds[idx] = CRGB(value8, value8, value8);
89 }
90 }
91 FastLED.show();
92}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define NUM_LEDS
Definition Apa102.ino:6
#define WIDTH
Definition Blur2d.ino:9
#define HEIGHT
Definition Blur2d.ino:10
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:58
central include file for FastLED, defines the CFastLED class/object
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
XYMap xyMap(HEIGHT, WIDTH, SERPENTINE)
#define IS_SERPINTINE
Definition FxEngine.ino:35
UICheckbox autoTrigger("Auto Trigger", true)
UIButton button("Trigger")
void triggerRipple()
Definition FxWave2d.ino:120
UISlider superSample("SuperSampleExponent", 1.f, 0.f, 3.f, 1.f)
UITitle title("Wave2D Demo")
XYMap xyMap(WIDTH, HEIGHT, IS_SERPINTINE)
UISlider slider("Speed", 0.18f, 0.0f, 1.0f)
UICheckbox autoTrigger("Auto Trigger", true)
UISlider extraFrames("Extra Frames", 0.0f, 0.0f, 8.0f, 1.0f)
void setup()
Definition Wave2d.ino:40
UIDescription description("Shows the use of the Wave2d effect.")
UISlider dampening("Dampening", 9.0f, 0.0f, 20.0f, 0.1f)
UICheckbox halfDuplex("Half Duplex", true)
UIButton button("Trigger")
SuperSample getSuperSample()
Definition Wave2d.ino:45
UISlider superSample("SuperSampleExponent", 1.f, 0.f, 3.f, 1.f)
WaveSimulation2D waveSim(WIDTH, HEIGHT, SUPER_SAMPLE_4X)
void loop()
Definition Wave2d.ino:66
UISlider slider("Speed", 0.18f, 0.0f, 1.0f)
UISlider dampening("Dampening", 6.0f, 0.0f, 10.0f, 0.1f)
UICheckbox halfDuplex("Half Duplex", false)
WaveSimulation1D waveSim(NUM_LEDS, SuperSample::SUPER_SAMPLE_2X)
LED controller for WS2812 LEDs with GRB color order.
Definition FastLED.h:138
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
Definition lib8tion.h:1359
SuperSample
Definition supersample.h:4
@ SUPER_SAMPLE_8X
Definition supersample.h:8
@ SUPER_SAMPLE_2X
Definition supersample.h:6
@ SUPER_SAMPLE_4X
Definition supersample.h:7
@ SUPER_SAMPLE_NONE
Definition supersample.h:5
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