18#include "fl/math_macros.h"
20#include "fl/screenmap.h"
24#include "sensors/pir.h"
30#define COLOR_ORDER GRB
34#define PIR_LATCH_MS 60000
35#define PIR_RISING_TIME 1000
36#define PIR_FALLING_TIME 1000
42Slider brightness(
"Brightness", 1, 0, 1);
43Slider scale(
"Scale", 4, .1, 4, .1);
44Slider timeBitshift(
"Time Bitshift", 5, 0, 16, 1);
45Slider timescale(
"Time Scale", 1, .1, 10, .1);
46PirAdvanced pir(PIN_PIR, PIR_LATCH_MS, PIR_RISING_TIME, PIR_FALLING_TIME);
49float current_brightness = 0;
54 ScreenMap xyMap = ScreenMap::Circle(NUM_LEDS, 2.0, 2.0);
59 pir.activate(millis());
65 std::cout <<
"loop" << std::endl;
67 uint8_t bri = pir.transition(millis());
69 uint32_t now = millis();
70 double angle_offset = double(now) / 32000.0 * 2 * M_PI;
72 now = (now << timeBitshift.as<
int>()) * timescale.as<
double>();
75 for (
int i = 0; i < NUM_LEDS; i++) {
76 float angle = i * 2 * M_PI / NUM_LEDS + angle_offset;
79 x *= 0xffff * scale.as<
double>();
80 y *= 0xffff * scale.as<
double>();
81 uint16_t noise =
inoise16(x, y, now);
82 uint16_t noise2 =
inoise16(x, y, 0xfff + now);
83 uint16_t noise3 =
inoise16(x, y, 0xffff + now);
85 int16_t noise4 = map(noise3, 0, 255, -64, 255);
90 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.
#define EVERY_N_SECONDS(N)
Checks whether to execute a block of code every N seconds.
Implements a simple red square effect for 2D LED grids.
Noise generation classes.
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Representation of an RGB pixel (Red, Green, Blue)