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.
5
6Windows/MacOS binaries: https://github.com/FastLED/FastLED/releases
7
8Python
9
10Install: pip install fastled
11Run: fastled <this sketch directory>
12This will compile and preview the sketch in the browser, and enable
13all the UI elements you see below.
14*/
15
16#include "fl/ui.h"
17#include "fx/2d/wave.h"
18#include <Arduino.h>
19#include <FastLED.h>
20
21using namespace fl;
22
23#define HEIGHT 100
24#define WIDTH 100
25#define NUM_LEDS ((WIDTH) * (HEIGHT))
26#define IS_SERPINTINE true
27
29
30UITitle title("Wave2D Demo");
31UIDescription description("Shows the use of the Wave2d effect. By default the wave is cyclical on the x-axis and waves will spill over to the other side.");
32
33UIButton button("Trigger");
34UICheckbox xCyclical("X Is Cyclical", true); // The wave keeps on propagating across the x-axis, when true.
35
36UICheckbox autoTrigger("Auto Trigger", true);
37UISlider extraFrames("Extra Frames", 0.0f, 0.0f, 8.0f, 1.0f);
38UISlider slider("Speed", 0.18f, 0.0f, 1.0f);
39UISlider dampening("Dampening", 9.0f, 0.0f, 20.0f, 0.1f);
40UICheckbox halfDuplex("Half Duplex", true);
41UISlider superSample("SuperSampleExponent", 1.f, 0.f, 3.f, 1.f);
42
44
46
47
48
50 switch (int(superSample)) {
51 case 0:
53 case 1:
55 case 2:
57 case 3:
59 default:
61 }
62}
63
65 int x = random() % WIDTH;
66 int y = random() % HEIGHT;
67 waveSim.setf(x, y, 1);
68}
69
70void setup() {
71 Serial.begin(115200);
72 FastLED.addLeds<NEOPIXEL, 2>(leds, NUM_LEDS).setScreenMap(xyMap);
73}
74
75void loop() {
76 // Your code here
77 waveSim.setXCylindrical(xCyclical.value());
78 waveSim.setSpeed(slider);
79 waveSim.setDampening(dampening);
80 waveSim.setHalfDuplex(halfDuplex);
81 waveSim.setSuperSample(getSuperSample());
82 if (button) {
84 }
85
86
88 if (autoTrigger) {
90 }
91 }
92
93 waveSim.update();
94 for (int y = 0; y < HEIGHT; y++) {
95 for (int x = 0; x < WIDTH; x++) {
96 uint8_t value8 = waveSim.getu8(x, y);
97 uint32_t idx = xyMap.mapToIndex(x, y);
98 leds[idx] = CRGB(value8, value8, value8);
99 }
100 }
101 FastLED.show();
102}
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
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:62
central include file for FastLED, defines the CFastLED class/object
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83
#define IS_SERPINTINE
Definition FxEngine.ino:35
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:70
UISlider dampening("Dampening", 9.0f, 0.0f, 20.0f, 0.1f)
UICheckbox halfDuplex("Half Duplex", true)
UIButton button("Trigger")
UIDescription description("Shows the use of the Wave2d effect. By default the wave is cyclical on the x-axis and waves will spill over to the other side.")
SuperSample getSuperSample()
Definition Wave2d.ino:49
UISlider superSample("SuperSampleExponent", 1.f, 0.f, 3.f, 1.f)
UICheckbox xCyclical("X Is Cyclical", true)
WaveSimulation2D waveSim(WIDTH, HEIGHT, SUPER_SAMPLE_4X)
void loop()
Definition Wave2d.ino:75
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:155
XYMap xyMap
Definition gfx.cpp:8
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
Definition lib8tion.h:1341
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:55
UICheckbox autoTrigger("Auto Trigger", true)
UIButton button("Trigger")
UICheckbox xCyclical("X Is Cyclical", false)
void triggerRipple()
Definition wavefx.cpp:147
UISlider superSample("SuperSampleExponent", 1.f, 0.f, 3.f, 1.f)