FastLED 3.9.15
Loading...
Searching...
No Matches
Wave2d.h
Go to the documentation of this file.
1
10
11// Author: Stefan Petrick
12
13/*
14This demo is best viewed using the FastLED compiler.
15
16Windows/MacOS binaries: https://github.com/FastLED/FastLED/releases
17
18Python
19
20Install: pip install fastled
21Run: fastled <this sketch directory>
22This will compile and preview the sketch in the browser, and enable
23all the UI elements you see below.
24*/
25
26#include "fl/ui.h"
27#include "fx/2d/wave.h"
28#include <Arduino.h>
29#include <FastLED.h>
30
31using namespace fl;
32
33#define HEIGHT 100
34#define WIDTH 100
35#define NUM_LEDS ((WIDTH) * (HEIGHT))
36#define IS_SERPINTINE true
37
39
40UITitle title("Wave2D Demo");
41UIDescription 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.");
42
43UIButton button("Trigger");
44UICheckbox xCyclical("X Is Cyclical", true); // The wave keeps on propagating across the x-axis, when true.
45
46UICheckbox autoTrigger("Auto Trigger", true);
47UISlider extraFrames("Extra Frames", 0.0f, 0.0f, 8.0f, 1.0f);
48UISlider slider("Speed", 0.18f, 0.0f, 1.0f);
49UISlider dampening("Dampening", 9.0f, 0.0f, 20.0f, 0.1f);
50UICheckbox halfDuplex("Half Duplex", true);
51UISlider superSample("SuperSampleExponent", 1.f, 0.f, 3.f, 1.f);
52
53// Group related UI elements using UIGroup template multi-argument constructor
56
58
60
61
62
64 switch (int(superSample)) {
65 case 0:
67 case 1:
69 case 2:
71 case 3:
73 default:
75 }
76}
77
79 int x = random(WIDTH);
80 int y = random(HEIGHT);
81 waveSim.setf(x, y, 1);
82}
83
84void setup() {
85 Serial.begin(115200);
86 FastLED.addLeds<NEOPIXEL, 2>(leds, NUM_LEDS).setScreenMap(xyMap);
87}
88
89void loop() {
90 // Your code here
91 waveSim.setXCylindrical(xCyclical.value());
92 waveSim.setSpeed(slider);
93 waveSim.setDampening(dampening);
94 waveSim.setHalfDuplex(halfDuplex);
95 waveSim.setSuperSample(getSuperSample());
96 if (button) {
98 }
99
100
102 if (autoTrigger) {
104 }
105 }
106
107 waveSim.update();
108 for (int y = 0; y < HEIGHT; y++) {
109 for (int x = 0; x < WIDTH; x++) {
110 uint8_t value8 = waveSim.getu8(x, y);
111 uint32_t idx = xyMap.mapToIndex(x, y);
112 leds[idx] = CRGB(value8, value8, value8);
113 }
114 }
115 FastLED.show();
116}
CRGB leds[NUM_LEDS]
#define NUM_LEDS
int y
Definition simple.h:93
int x
Definition simple.h:92
#define IS_SERPINTINE
Definition simple.h:50
fl::XYMap xyMap
Definition ColorBoost.h:61
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:74
central include file for FastLED, defines the CFastLED class/object
UISlider extraFrames("Extra Frames", 0.0f, 0.0f, 8.0f, 1.0f)
UISlider slider("Speed", 0.18f, 0.0f, 1.0f)
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.")
UISlider superSample("SuperSampleExponent", 1.f, 0.f, 3.f, 1.f)
UICheckbox autoTrigger("Auto Trigger", true)
void setup()
Definition Wave2d.h:84
UICheckbox xCyclical("X Is Cyclical", true)
void triggerRipple(WaveSimulation2D &waveSim)
Definition Wave2d.h:78
UITitle title("Wave2D Demo")
UISlider dampening("Dampening", 9.0f, 0.0f, 20.0f, 0.1f)
WaveSimulation2D waveSim(WIDTH, HEIGHT, SUPER_SAMPLE_4X)
UIGroup waveSimControls("Wave Simulation", slider, dampening, halfDuplex, superSample, xCyclical)
SuperSample getSuperSample()
Definition Wave2d.h:63
UIButton button("Trigger")
UIGroup triggerControls("Trigger Controls", button, autoTrigger, extraFrames)
UICheckbox halfDuplex("Half Duplex", true)
void loop()
Definition Wave2d.h:89
#define WIDTH
Definition advanced.h:36
#define HEIGHT
Definition advanced.h:37
LED controller for WS2812 LEDs with GRB color order.
Definition FastLED.h:158
UISlider slider("Speed", 0.18f, 0.0f, 1.0f)
UICheckbox halfDuplex("Half Duplex", false)
WaveSimulation1D waveSim(NUM_LEDS, SuperSample::SUPER_SAMPLE_2X)
UISlider dampening("Dampening", 6.0f, 0.0f, 10.0f, 0.1f)
UISlider superSample("SuperSampleExponent", 0.f, 0.f, 3.f, 1.f)
UISlider extraFrames("Extra Frames", 1.0f, 0.0f, 8.0f, 1.0f)
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
Definition lib8tion.h:1221
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
IMPORTANT!
Definition crgb.h:20
UIButton button("Button")
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86