FastLED 3.9.3
Loading...
Searching...
No Matches
Overclock.ino
Go to the documentation of this file.
1
3
4
5#define FASTLED_W2812_OVERCLOCK 1.1 // Overclocks by 10%, I've seen 25% work fine.
6
7#include "fx/2d/noisepalette.hpp"
8#include "fx/fx.h"
9#include <FastLED.h>
10
11#define LED_PIN 3
12#define BRIGHTNESS 96
13#define LED_TYPE WS2811
14#define COLOR_ORDER GRB
15
16#define MATRIX_WIDTH 22
17#define MATRIX_HEIGHT 22
18#define GRID_SERPENTINE 1
19
20#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
21
22// This example combines two features of FastLED to produce a remarkable range
23// of effects from a relatively small amount of code. This example combines
24// FastLED's color palette lookup functions with FastLED's Perlin noise
25// generator, and the combination is extremely powerful.
26//
27// You might want to look at the "ColorPalette" and "Noise" examples separately
28// if this example code seems daunting.
29//
30//
31// The basic setup here is that for each frame, we generate a new array of
32// 'noise' data, and then map it onto the LED matrix through a color palette.
33//
34// Periodically, the color palette is changed, and new noise-generation
35// parameters are chosen at the same time. In this example, specific
36// noise-generation values have been selected to match the given color palettes;
37// some are faster, or slower, or larger, or smaller than others, but there's no
38// reason these parameters can't be freely mixed-and-matched.
39//
40// In addition, this example includes some fast automatic 'data smoothing' at
41// lower noise speeds to help produce smoother animations in those cases.
42//
43// The FastLED built-in color palettes (Forest, Clouds, Lava, Ocean, Party) are
44// used, as well as some 'hand-defined' ones, and some proceedurally generated
45// palettes.
46
47// Scale determines how far apart the pixels in our noise matrix are. Try
48// changing these values around to see how it affects the motion of the display.
49// The higher the value of scale, the more "zoomed out" the noise iwll be. A
50// value of 1 will be so zoomed in, you'll mostly see solid colors.
51#define SCALE 20
52
53// We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll
54// use the z-axis for "time". speed determines how fast time moves forward. Try
55// 1 for a very slow moving effect, or 60 for something that ends up looking
56// like water.
57#define SPEED 30
58
59CRGB leds[NUM_LEDS];
60XYMap xyMap(MATRIX_WIDTH, MATRIX_HEIGHT, GRID_SERPENTINE);
61NoisePalette noisePalette(xyMap);
62
63
64void setup() {
65 delay(1000); // sanity delay
66 FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
67 .setCorrection(TypicalLEDStrip).setScreenMap(xyMap);
69 noisePalette.setSpeed(SPEED);
70 noisePalette.setScale(SCALE);
71}
72
73void loop() {
74 EVERY_N_MILLISECONDS(5000) { noisePalette.changeToRandomPalette(); }
75 noisePalette.draw(Fx::DrawContext(millis(), leds));
76 FastLED.show();
77}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:33
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:722
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:82
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:67
void draw(DrawContext context) override
Definition xymap.h:39
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:19
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
Definition lib8tion.h:1323
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39