FastLED 3.9.3
Loading...
Searching...
No Matches
NoisePlayground.ino
Go to the documentation of this file.
1
2
3
7
8#include <FastLED.h>
9
10#if defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtinyxy4__)
11// too large for ATtiny85, so skip this.
12void setup() {};
13void loop() {};
14#else
15
16// Params for width and height
17const uint8_t kMatrixWidth = 16;
18const uint8_t kMatrixHeight = 16;
19
20#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
21
22// Param for different pixel layouts
23#define kMatrixSerpentineLayout true
24
25// led array
26CRGB leds[kMatrixWidth * kMatrixHeight];
27
28// x,y, & time values
29uint32_t x,y,v_time,hue_time,hxy;
30
31// Play with the values of the variables below and see what kinds of effects they
32// have! More octaves will make things slower.
33
34// how many octaves to use for the brightness and hue functions
35uint8_t octaves=1;
36uint8_t hue_octaves=3;
37
38// the 'distance' between points on the x and y axis
39int xscale=57771;
40int yscale=57771;
41
42// the 'distance' between x/y points for the hue noise
43int hue_scale=1;
44
45// how fast we move through time & hue noise
46int time_speed=1111;
47int hue_speed=31;
48
49// adjust these values to move along the x or y axis between frames
50int x_speed=331;
51int y_speed=1111;
52
53void loop() {
54 // fill the led array 2/16-bit noise values
55 fill_2dnoise16(leds, kMatrixWidth, kMatrixHeight, kMatrixSerpentineLayout,
56 octaves,x,xscale,y,yscale,v_time,
57 hue_octaves,hxy,hue_scale,hxy,hue_scale,hue_time, false);
58
59 FastLED.show();
60
61 // adjust the intra-frame time values
62 x += x_speed;
63 y += y_speed;
64 v_time += time_speed;
65 hue_time += hue_speed;
66 // delay(50);
67}
68
69
70void setup() {
71 // initialize the x/y and time values
73 random16_add_entropy(analogRead(3));
74
75 Serial.begin(57600);
76 Serial.println("resetting!");
77
78 delay(3000);
79 FastLED.addLeds<WS2811,2,GRB>(leds,NUM_LEDS);
81
82 hxy = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
83 x = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
84 y = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
85 v_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
86 hue_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
87
88}
89
90#endif
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
WS2811 controller class.
Definition FastLED.h:233
void fill_2dnoise16(CRGB *leds, int width, int height, bool serpentine, uint8_t octaves, uint32_t x, int xscale, uint32_t y, int yscale, uint32_t time, uint8_t hue_octaves, uint16_t hue_x, int hue_xscale, uint16_t hue_y, uint16_t hue_yscale, uint16_t hue_time, bool blend, uint16_t hue_shift)
Fill an LED matrix with random colors, using 16-bit noise.
Definition noise.cpp:860
LIB8STATIC void random16_add_entropy(uint16_t entropy)
Add entropy into the random number generator.
Definition random8.h:97
LIB8STATIC uint16_t random16()
Generate a 16-bit random number.
Definition random8.h:50
LIB8STATIC void random16_set_seed(uint16_t seed)
Set the 16-bit seed used for the random number generator.
Definition random8.h:91
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39