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

◆ loop()

void loop ( )

Definition at line 94 of file FxWater.h.

94 {
95 // swap the src/dest buffers on each frame
96 static uint8_t buffer = 0;
97 uint8_t * const bufA = &water[buffer][0];
98 buffer = (buffer + 1) % 2;
99 uint8_t * const bufB = &water[buffer][0];
100
101 // add a moving stimulus
102 wu_water(bufA, beatsin16(13, 256, HEIGHT * 256), beatsin16(7, 256, WIDTH * 256), beatsin8(160, 64, 255));
103
104 // animate the water
105 process_water(bufA, bufB);
106
107
108 // display the water effect on the LEDs
109 uint8_t * input = bufB + WATERWIDTH - 1;
110 static uint16_t pal_offset = 0;
111 pal_offset += 256;
112 for (uint8_t y = 0; y < HEIGHT; y++) {
113 input += 2;
114 for (uint8_t x = 0; x < WIDTH; x++) {
115 leds[XY(x, y)] = MyColorFromPaletteExtended(RainbowColors_p, pal_offset + (*input++ << 8), 255, LINEARBLEND);
116 }
117 }
118 FastLED.show();
119}
CRGB leds[NUM_LEDS]
int y
Definition simple.h:93
int x
Definition simple.h:92
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:74
void process_water(uint8_t *src, uint8_t *dst)
Definition FxWater.h:121
void wu_water(uint8_t *const buf, uint16_t x, uint16_t y, uint8_t bright)
Definition FxWater.h:141
CRGB MyColorFromPaletteExtended(const CRGBPalette16 &pal, uint16_t index, uint8_t brightness, TBlendType blendType)
Definition FxWater.h:40
uint8_t water[2][WATERWIDTH *WATERHEIGHT]
Definition FxWater.h:29
#define WATERWIDTH
Definition FxWater.h:27
#define WIDTH
Definition advanced.h:36
#define HEIGHT
Definition advanced.h:37
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:819
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:837
const TProgmemRGBPalette16 RainbowColors_p
HSV Rainbow.
fl::u16 XY(fl::u8 x, fl::u8 y)
Definition blur.cpp:22

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: