13#define NUM_LEDS ((WIDTH) * (HEIGHT))
17#define WATERWIDTH (WIDTH + 2)
18#define WATERHEIGHT (HEIGHT + 2)
21void wu_water(uint8_t *
const buf, uint16_t
x, uint16_t
y, uint8_t bright);
32 uint8_t index_4bit = (index >> 12);
34 uint8_t offset = (uint8_t)(index >> 4);
36 const CRGB* entry = &(pal[0]) + index_4bit;
37 uint8_t red1 = entry->red;
38 uint8_t green1 = entry->green;
39 uint8_t blue1 = entry->blue;
43 if (index_4bit == 15) {
50 uint8_t f1 = 255 - offset;
56 uint8_t red2 = entry->red;
57 uint8_t green2 = entry->green;
58 uint8_t blue2 = entry->blue;
73 return CRGB(red1, green1, blue1);
80uint16_t
XY(uint8_t
x, uint8_t
y) {
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];
100 static uint16_t pal_offset = 0;
104 for (uint8_t
x = 0;
x <
WIDTH;
x++) {
124 dst[0] -= dst[0] >> 6;
131void wu_water(uint8_t *
const buf, uint16_t
x, uint16_t
y, uint8_t bright) {
133 uint8_t xx =
x & 0xff, yy =
y & 0xff, ix = 255 - xx, iy = 255 - yy;
135 #define WU_WEIGHT(a, b) ((uint8_t)(((a) * (b) + (a) + (b)) >> 8))
141 for (uint8_t i = 0; i < 4; i++) {
142 uint8_t local_x = (
x >> 8) + (i & 1);
143 uint8_t local_y = (
y >> 8) + ((i >> 1) & 1);
146 uint16_t this_bright = bright * wu[i];
147 buf[
xy] =
qadd8(buf[
xy], this_bright >> 8);
CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
XYMap xyMap(HEIGHT, WIDTH, SERPENTINE)
UISlider brightness("Brightness", 255, 0, 255, 1)
void process_water(uint8_t *src, uint8_t *dst)
XYMap xyMap(WIDTH, HEIGHT, false)
uint16_t XY(uint8_t x, uint8_t y)
void wu_water(uint8_t *const buf, uint16_t x, uint16_t y, uint8_t bright)
CRGB MyColorFromPaletteExtended(const CRGBPalette16 &pal, uint16_t index, uint8_t brightness, TBlendType blendType)
uint8_t water[2][WATERWIDTH *WATERHEIGHT]
unsigned int xy(unsigned int x, unsigned int y)
RGB color palette with 16 discrete values.
LED controller for WS2812 LEDs with GRB color order.
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.
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.
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
Computes a new color blended some fraction of the way between two other colors.
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
TBlendType
Color interpolation options for palette.
@ NOBLEND
No interpolation between palette entries.
@ LINEARBLEND
Linear interpolation between palette entries, with wrap-around from end to the beginning again.
const TProgmemRGBPalette16 RainbowColors_p
HSV Rainbow.
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_LEAVING_R1_DIRTY(uint8_t i, fract8 scale)
This version of scale8() does not clean up the R1 register on AVR.
LIB8STATIC void nscale8x3(uint8_t &r, uint8_t &g, uint8_t &b, fract8 scale)
Scale three one-byte values by a fourth one, which is treated as the numerator of a fraction whose de...
Implements a simple red square effect for 2D LED grids.
Representation of an RGB pixel (Red, Green, Blue)