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