18#include "fl/math_macros.h"
21#include "fl/screenmap.h"
25#include "sensors/pir.h"
29#define COLOR_ORDER GRB
33#define PIR_LATCH_MS 60000
34#define PIR_RISING_TIME 1000
35#define PIR_FALLING_TIME 1000
41UISlider brightness(
"Brightness", 1, 0, 1);
42UISlider scale(
"Scale", 4, .1, 4, .1);
43UISlider timeBitshift(
"Time Bitshift", 5, 0, 16, 1);
44UISlider timescale(
"Time Scale", 1, .1, 10, .1);
45PirAdvanced pir(PIN_PIR, PIR_LATCH_MS, PIR_RISING_TIME, PIR_FALLING_TIME);
46UICheckbox useDither(
"Use Binary Dither",
true);
49float current_brightness = 0;
53void handleSerialDither() {
54 if (Serial.available()) {
55 char input = Serial.read();
58 }
else if (input ==
'1') {
61 FASTLED_WARN(
"Invalid dither input. Use 0 or 1");
68 ScreenMap xyMap = ScreenMap::Circle(NUM_LEDS, 2.0, 2.0);
74 pir.activate(millis());
84 uint8_t bri = pir.transition(millis());
86 uint32_t now = millis();
87 double angle_offset = double(now) / 32000.0 * 2 * M_PI;
88 now = (now << timeBitshift.as<
int>()) * timescale.as<
double>();
90 for (
int i = 0; i < NUM_LEDS; i++) {
91 float angle = i * 2 * M_PI / NUM_LEDS + angle_offset;
94 x *= 0xffff * scale.as<
double>();
95 y *= 0xffff * scale.as<
double>();
96 uint16_t noise =
inoise16(x, y, now);
97 uint16_t noise2 =
inoise16(x, y, 0xfff + now);
98 uint16_t noise3 =
inoise16(x, y, 0xffff + now);
100 int16_t noise4 = map(noise3, 0, 255, -64, 255);
104 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.
Base definition for an LED controller.
CLEDController & setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode for this controller to use.
#define BINARY_DITHER
Enable dithering using binary dithering (only option)
#define DISABLE_DITHER
Disable dithering.
@ 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)