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

◆ loop()

void loop ( )

Definition at line 93 of file FxWater.h.

93 {
94 // swap the src/dest buffers on each frame
95 static uint8_t buffer = 0; // okay static in header
96 uint8_t * const bufA = &water[buffer][0];
97 buffer = (buffer + 1) % 2;
98 uint8_t * const bufB = &water[buffer][0];
99
100 // add a moving stimulus
101 wu_water(bufA, beatsin16(13, 256, HEIGHT * 256), beatsin16(7, 256, WIDTH * 256), beatsin8(160, 64, 255));
102
103 // animate the water
104 process_water(bufA, bufB);
105
106
107 // display the water effect on the LEDs
108 uint8_t * input = bufB + WATERWIDTH - 1;
109 static uint16_t pal_offset = 0; // okay static in header
110 pal_offset += 256;
111 for (uint8_t y = 0; y < HEIGHT; y++) {
112 input += 2;
113 for (uint8_t x = 0; x < WIDTH; x++) {
114 leds[XY(x, y)] = MyColorFromPaletteExtended(RainbowColors_p, pal_offset + (*input++ << 8), 255, LINEARBLEND);
115 }
116 }
117 FastLED.show();
118}
fl::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.
void process_water(uint8_t *src, uint8_t *dst)
Definition FxWater.h:120
fl::CRGB MyColorFromPaletteExtended(const fl::CRGBPalette16 &pal, uint16_t index, uint8_t brightness, TBlendType blendType)
Definition FxWater.h:39
uint16_t XY(uint8_t x, uint8_t y)
Definition FxWater.h:89
void wu_water(uint8_t *const buf, uint16_t x, uint16_t y, uint8_t bright)
Definition FxWater.h:140
uint8_t water[2][WATERWIDTH *WATERHEIGHT]
Definition FxWater.h:28
#define WATERWIDTH
Definition FxWater.h:26
#define WIDTH
#define HEIGHT
const TProgmemRGBPalette16 RainbowColors_p
HSV Rainbow.
LIB8STATIC u8 beatsin8(accum88 beats_per_minute, u8 lowest=0, u8 highest=255, u32 timebase=0, u8 phase_offset=0) FL_NOEXCEPT
Generates an 8-bit sine wave at a given BPM that oscillates within a given range.
Definition beat.h:105
LIB8STATIC u16 beatsin16(accum88 beats_per_minute, u16 lowest=0, u16 highest=65535, u32 timebase=0, u16 phase_offset=0) FL_NOEXCEPT
Generates a 16-bit sine wave at a given BPM that oscillates within a given range.
Definition beat.h:84
fl::u16 uint16_t
Definition s16x16x4.h:214
unsigned char uint8_t
Definition s16x16x4.h:209

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

+ Here is the call graph for this function: