13#include "math_macros.h"
24#define COLOR_ORDER GRB
30Slider brightness(
"Brightness", 255, 0, 255);
31Slider scale(
"Scale", 4, .1, 4, .1);
32Slider timeBitshift(
"Time Bitshift", 5, 0, 16, 1);
33Slider timescale(
"Time Scale", 1, .1, 10, .1);
37float current_brightness = 0;
40uint8_t update_brightness(
bool clicked, uint32_t now) {
42 timer.start(millis(), 1000 * 60 * 3);
44 if (timer.update(now)) {
45 current_brightness += .6;
47 current_brightness *= .97;
49 uint32_t brightness = current_brightness;
50 if (brightness > 255) {
58 ScreenMap xyMap = ScreenMap::Circle(NUM_LEDS, 2.0, 2.0);
66 const bool detectMotion = pir.detect();
67 const bool detected_motion = detectMotion || first || detectMotion;
69 uint8_t bri = update_brightness(detected_motion, millis());
71 uint32_t now = millis();
72 double angle_offset = double(now) / 32000.0 * 2 * M_PI;
74 now = (now << timeBitshift.as<
int>()) * timescale.as<
double>();
77 for (
int i = 0; i < NUM_LEDS; i++) {
78 float angle = i * 2 * M_PI / NUM_LEDS + angle_offset;
81 x *= 0xffff * scale.as<
double>();
82 y *= 0xffff * scale.as<
double>();
83 uint16_t noise =
inoise16(x, y, now);
84 uint16_t noise2 =
inoise16(x, y, 0xfff + now);
85 uint16_t noise3 =
inoise16(x, y, 0xffff + now);
87 int16_t noise4 = map(noise3, 0, 255, -64, 255);
92 leds[i] =
CHSV(noise >> 8, MAX(128, noise2 >> 8), noise4);
CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z)
16-bit, fixed point implementation of Perlin's noise.
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Representation of an RGB pixel (Red, Green, Blue)