FastLED 3.9.15
Loading...
Searching...
No Matches
Wave.ino
Go to the documentation of this file.
1
2/*
3This demo is best viewed using the FastLED compiler.
4Install: pip install fastled
5Run: fastled <this sketch directory>
6This will compile and preview the sketch in the browser, and enable
7all the UI elements you see below.
8*/
9
10#include "fl/math_macros.h"
11#include "fl/ui.h"
12#include "fl/wave_simulation.h"
13#include <Arduino.h>
14#include <FastLED.h>
15
16using namespace fl;
17
18#define NUM_LEDS 100
19#define IS_SERPINTINE true
20
22
23UITitle title("Wave Demo");
24UIDescription description("Shows the use of the Wave1D effect.");
25
26UIButton button("Trigger");
28
29UISlider slider("Speed", 0.18f, 0.0f, 1.0f);
30UISlider extraFrames("Extra Frames", 1.0f, 0.0f, 8.0f, 1.0f);
31UISlider dampening("Dampening", 6.0f, 0.0f, 10.0f, 0.1f);
32UICheckbox halfDuplex("Half Duplex", false);
33UISlider superSample("SuperSampleExponent", 0.f, 0.f, 3.f, 1.f);
34
35void setup() {
36 Serial.begin(115200);
37 FastLED.addLeds<NEOPIXEL, 2>(leds, NUM_LEDS);
38}
39
41
42 for (int i = x - 1; i <= x + 1; i++) {
43 if (i < 0 || i >= NUM_LEDS)
44 continue;
45 FASTLED_WARN("Setting " << i);
46 waveSim.setf(i, -1.f);
47 }
48}
49
51 switch (int(superSample)) {
52 case 0:
54 case 1:
56 case 2:
58 case 3:
60 default:
62 }
63}
64
65void loop() {
66 // Your code here
67 waveSim.setSpeed(slider);
68 waveSim.setDampening(dampening);
69 waveSim.setHalfDuplex(halfDuplex);
70 waveSim.setSuperSample(getSuperSample());
71 static int x = 0;
72 if (button.clicked()) {
73 x = random() % NUM_LEDS;
74 }
75 if (button.isPressed()) {
76 FASTLED_WARN("Button is pressed at " << x);
78 }
79 waveSim.update();
80 for (int i = 0; i < extraFrames.value(); i++) {
81 waveSim.update();
82 }
83 for (int x = 0; x < NUM_LEDS; x++) {
84 // float value = waveSim.get(x);
85 uint8_t value8 = waveSim.getu8(x);
86 leds[x] = CRGB(value8, value8, value8);
87 }
88 FastLED.show();
89}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define NUM_LEDS
Definition Apa102.ino:6
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
UIButton button("Trigger")
void triggerRipple()
Definition FxWave2d.ino:120
UISlider superSample("SuperSampleExponent", 1.f, 0.f, 3.f, 1.f)
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)
UITitle title("Wave Demo")
void setup()
Definition Wave.ino:35
UIButton button("Trigger")
UISlider superSample("SuperSampleExponent", 0.f, 0.f, 3.f, 1.f)
UIDescription description("Shows the use of the Wave1D effect.")
SuperSample getSuperSample()
Definition Wave.ino:50
WaveSimulation1D waveSim(NUM_LEDS, SuperSample::SUPER_SAMPLE_2X)
UISlider extraFrames("Extra Frames", 1.0f, 0.0f, 8.0f, 1.0f)
void loop()
Definition Wave.ino:65
LED controller for WS2812 LEDs with GRB color order.
Definition FastLED.h:138
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
#define FASTLED_WARN
Definition warn.h:7