38 if (ctx.leds ==
nullptr || mNumLeds == 0) {
43 uint8_t brightdepth =
beatsin88(341, 96, 224);
44 uint16_t brightnessthetainc16 =
beatsin88(203, (25 * 256), (40 * 256));
45 uint8_t msmultiplier =
beatsin88(147, 23, 60);
47 uint16_t hue16 = mHue16;
48 uint16_t hueinc16 =
beatsin88(113, 1, 3000);
50 uint16_t ms = millis();
51 uint16_t deltams = ms - mLastMillis;
53 mPseudotime += deltams * msmultiplier;
55 uint16_t brightnesstheta16 = mPseudotime;
58 for (uint16_t i = 0; i < mNumLeds; i++) {
60 uint8_t hue8 = hue16 / 256;
62 brightnesstheta16 += brightnessthetainc16;
63 uint16_t b16 =
sin16(brightnesstheta16) + 32768;
65 uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
66 uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
67 bri8 += (255 - brightdepth);
69 CRGB newcolor =
CHSV(hue8, sat8, bri8);
71 uint16_t pixelnumber = (mNumLeds - 1) - i;
73 nblend(ctx.leds[pixelnumber], newcolor, 64);
LIB8STATIC uint16_t beatsin88(accum88 beats_per_minute_88, 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.
CRGB & nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay)
Destructively modifies one color, blending in a given fraction of an overlay color.