-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsplendida-apr.ino
69 lines (55 loc) · 1.77 KB
/
splendida-apr.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Splendida AquaPurple Rotate
Author: Anderson Costa
Date: 2021-03-06
*/
#include <FastLED.h>
// LED settings
#define NUM_LEDS 256
#define CHIPSET WS2812B
#define DATA_PIN 3
// LED brightness
#define BRIGHTNESS 255
CRGB leds[NUM_LEDS];
CRGB colorBlack = CRGB::Black;
CRGB colorAqua = CHSV(HUE_AQUA, 255, 255);
CRGB colorPurple = CHSV(HUE_PURPLE, 255, 255);
CRGBPalette16 currentPalette(colorBlack);
CRGBPalette16 targetPalette = CRGBPalette16(
colorAqua, colorAqua,
colorBlack, colorBlack,
colorPurple, colorPurple,
colorBlack, colorBlack,
colorAqua, colorAqua,
colorBlack, colorBlack,
colorPurple, colorPurple,
colorBlack, colorBlack
);
TBlendType currentBlending = LINEARBLEND; // or NOBLEND
bool switchPallete = false;
void animateLEDsFromPalette(uint8_t colorIndex, uint8_t speed, uint8_t slice) {
for (int i = 0; i < NUM_LEDS; i++) {
uint8_t colorIndex = (millis() / speed) + (i * slice);
if (colorIndex > 128) colorIndex = 0;
leds[i] = ColorFromPalette(currentPalette, colorIndex, 255);
}
}
void setup() {
FastLED.addLeds<CHIPSET, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
static uint8_t startIndex = 0;
static uint8_t sliceIndex = 1;
EVERY_N_MILLISECONDS(60) {
nblendPaletteTowardPalette(currentPalette, targetPalette, 16);
}
EVERY_N_MILLISECONDS(20) {
animateLEDsFromPalette(startIndex++, 1, sliceIndex);
}
EVERY_N_SECONDS(10) {
sliceIndex++;
if (sliceIndex > 6) sliceIndex = 1;
}
FastLED.show();
}