FastLED 3.9.15
Loading...
Searching...
No Matches

◆ loop()

void loop ( )

Definition at line 84 of file FxWater.ino.

84 {
85 // swap the src/dest buffers on each frame
86 static uint8_t buffer = 0;
87 uint8_t * const bufA = &water[buffer][0];
88 buffer = (buffer + 1) % 2;
89 uint8_t * const bufB = &water[buffer][0];
90
91 // add a moving stimulus
92 wu_water(bufA, beatsin16(13, 256, HEIGHT * 256), beatsin16(7, 256, WIDTH * 256), beatsin8(160, 64, 255));
93
94 // animate the water
95 process_water(bufA, bufB);
96
97
98 // display the water effect on the LEDs
99 uint8_t * input = bufB + WATERWIDTH - 1;
100 static uint16_t pal_offset = 0;
101 pal_offset += 256;
102 for (uint8_t y = 0; y < HEIGHT; y++) {
103 input += 2;
104 for (uint8_t x = 0; x < WIDTH; x++) {
105 leds[XY(x, y)] = MyColorFromPaletteExtended(RainbowColors_p, pal_offset + (*input++ << 8), 255, LINEARBLEND);
106 }
107 }
108 FastLED.show();
109}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
int y
Definition Audio.ino:72
#define WIDTH
Definition Audio.ino:33
int x
Definition Audio.ino:71
#define HEIGHT
Definition Audio.ino:32
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:58
void process_water(uint8_t *src, uint8_t *dst)
Definition FxWater.ino:111
void wu_water(uint8_t *const buf, uint16_t x, uint16_t y, uint8_t bright)
Definition FxWater.ino:131
CRGB MyColorFromPaletteExtended(const CRGBPalette16 &pal, uint16_t index, uint8_t brightness, TBlendType blendType)
Definition FxWater.ino:30
uint8_t water[2][WATERWIDTH *WATERHEIGHT]
Definition FxWater.ino:19
#define WATERWIDTH
Definition FxWater.ino:17
LIB8STATIC uint16_t beatsin16(accum88 beats_per_minute, uint16_t lowest=0, uint16_t highest=65535, uint32_t timebase=0, uint16_t phase_offset=0)
Generates a 16-bit sine wave at a given BPM that oscillates within a given range.
Definition lib8tion.h:939
LIB8STATIC uint8_t beatsin8(accum88 beats_per_minute, uint8_t lowest=0, uint8_t highest=255, uint32_t timebase=0, uint8_t phase_offset=0)
Generates an 8-bit sine wave at a given BPM that oscillates within a given range.
Definition lib8tion.h:957
const TProgmemRGBPalette16 RainbowColors_p
HSV Rainbow.
uint16_t XY(uint8_t x, uint8_t y)
Definition blur.cpp:21

References beatsin16(), beatsin8(), FastLED, HEIGHT, leds, MyColorFromPaletteExtended(), process_water(), RainbowColors_p, water, WATERWIDTH, WIDTH, wu_water(), x, fl::XY(), and y.

+ Here is the call graph for this function: