add new patterns
This commit is contained in:
parent
a70dc9ca8e
commit
5e80414b06
2 changed files with 61 additions and 13 deletions
|
@ -17,13 +17,13 @@ FASTLED_USING_NAMESPACE
|
||||||
|
|
||||||
#define DATA_PIN 32
|
#define DATA_PIN 32
|
||||||
//#define CLK_PIN 4
|
//#define CLK_PIN 4
|
||||||
#define LED_TYPE WS2812B
|
#define LED_TYPE WS2812
|
||||||
#define COLOR_ORDER BGR
|
#define COLOR_ORDER RGB
|
||||||
#define NUM_LEDS 100
|
#define NUM_LEDS 100
|
||||||
CRGB leds[NUM_LEDS];
|
CRGB leds[NUM_LEDS];
|
||||||
|
|
||||||
define BRIGHTNESS 96
|
#define BRIGHTNESS 96
|
||||||
define FRAMES_PER_SECOND 120
|
#define FRAMES_PER_SECOND 120
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
delay(3000); // 3 second delay for recovery
|
delay(3000); // 3 second delay for recovery
|
||||||
|
@ -47,7 +47,7 @@ uint8_t gHue = 0; // rotating "base color" used by many of the patterns
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// Call the current pattern function once, updating the 'leds' array
|
// Call the current pattern function once, updating the 'leds' array
|
||||||
gPatterns[2]();
|
gPatterns[gCurrentPatternNumber]();
|
||||||
|
|
||||||
// send the 'leds' array out to the actual LED strip
|
// send the 'leds' array out to the actual LED strip
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
|
@ -56,7 +56,7 @@ void loop()
|
||||||
|
|
||||||
// do some periodic updates
|
// do some periodic updates
|
||||||
EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
|
EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
|
||||||
//EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
|
EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
|
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
|
||||||
|
|
|
@ -5,22 +5,25 @@
|
||||||
#define COLOR_ORDER RGB
|
#define COLOR_ORDER RGB
|
||||||
#define NUM_LEDS 100
|
#define NUM_LEDS 100
|
||||||
#define PIN 32
|
#define PIN 32
|
||||||
#define BRIGHTNESS 30
|
#define BRIGHTNESS 100
|
||||||
#define FPS 120
|
#define FPS 120
|
||||||
#define NUM_PATTERNS 4
|
#define NUM_PATTERNS 7
|
||||||
|
|
||||||
CRGB leds[NUM_LEDS];
|
CRGB leds[NUM_LEDS];
|
||||||
|
|
||||||
int posx, posy, dx, dy, current_pattern;
|
int posx, posy, dx, dy, current_pattern;
|
||||||
|
|
||||||
|
bool panelUpFade = true;
|
||||||
|
|
||||||
typedef void (*PatternList[])();
|
typedef void (*PatternList[])();
|
||||||
|
|
||||||
uint8_t hue = 0;
|
uint8_t hue = 0, panelBrightness = 0;
|
||||||
|
CHSV panelColor;
|
||||||
|
|
||||||
void confetti() {
|
void confetti() {
|
||||||
fadeToBlackBy(leds, NUM_LEDS, 10);
|
fadeToBlackBy(leds, NUM_LEDS, 10);
|
||||||
int pos = random16(NUM_LEDS);
|
int pos = random16(NUM_LEDS);
|
||||||
leds[pos] += CHSV(hue + random8(64), 200, 255);
|
leds[pos] += CHSV(hue + random8(64), 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_pong() {
|
void setup_pong() {
|
||||||
|
@ -55,7 +58,7 @@ void pong() {
|
||||||
fadeToBlackBy(leds, NUM_LEDS, 10);
|
fadeToBlackBy(leds, NUM_LEDS, 10);
|
||||||
|
|
||||||
if (posx < 10 && posy < 10) {
|
if (posx < 10 && posy < 10) {
|
||||||
leds[(posy * 10) + posx] += CHSV(hue, 200, 255);
|
leds[(posy * 10) + posx] += CHSV(hue, 255, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,15 +80,57 @@ void raindbowWithGlitter() {
|
||||||
addGlitter(80);
|
addGlitter(80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fullPanel() {
|
||||||
|
if (panelUpFade) {
|
||||||
|
if (panelBrightness < 255) {
|
||||||
|
panelBrightness = min(255, panelBrightness + (255 / FPS));
|
||||||
|
} else {
|
||||||
|
panelUpFade = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (panelBrightness > 0) {
|
||||||
|
panelBrightness = max(0, panelBrightness - (255 / FPS));
|
||||||
|
} else {
|
||||||
|
panelUpFade = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fill_solid(leds, NUM_LEDS, CRGB(CHSV(hue, 255, panelBrightness)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void scanLineHorz() {
|
||||||
|
fadeToBlackBy(leds, NUM_LEDS, 10);
|
||||||
|
for (int i = (posx / 10) % (int)sqrt(NUM_LEDS);
|
||||||
|
i < NUM_LEDS;
|
||||||
|
i += (int)sqrt(NUM_LEDS)) {
|
||||||
|
leds[i] = CRGB(CHSV(hue, 255, 255));
|
||||||
|
}
|
||||||
|
posx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void scanLineVert() {
|
||||||
|
fadeToBlackBy(leds, NUM_LEDS, 10);
|
||||||
|
for (int i = (posx / 10) % (int)sqrt(NUM_LEDS) * (int)sqrt(NUM_LEDS);
|
||||||
|
i < ((posx / 10) % (int)sqrt(NUM_LEDS) * (int)sqrt(NUM_LEDS)) +
|
||||||
|
(int)sqrt(NUM_LEDS);
|
||||||
|
i++) {
|
||||||
|
leds[i] = CRGB(CHSV(hue, 255, 255));
|
||||||
|
}
|
||||||
|
posx++;
|
||||||
|
}
|
||||||
|
|
||||||
PatternList patterns = {
|
PatternList patterns = {
|
||||||
confetti,
|
confetti,
|
||||||
pong,
|
pong,
|
||||||
rainbow,
|
rainbow,
|
||||||
raindbowWithGlitter
|
raindbowWithGlitter,
|
||||||
|
fullPanel,
|
||||||
|
scanLineHorz,
|
||||||
|
scanLineVert
|
||||||
};
|
};
|
||||||
|
|
||||||
void nextPattern(){
|
void nextPattern(){
|
||||||
current_pattern = (current_pattern + 1) % NUM_PATTERNS;
|
current_pattern = (current_pattern + 1) % NUM_PATTERNS;
|
||||||
|
panelUpFade = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
@ -108,5 +153,8 @@ void loop() {
|
||||||
FastLED.delay(1000/FPS * 2);
|
FastLED.delay(1000/FPS * 2);
|
||||||
|
|
||||||
EVERY_N_MILLISECONDS(20) {hue++;}
|
EVERY_N_MILLISECONDS(20) {hue++;}
|
||||||
EVERY_N_SECONDS(10) {nextPattern();}
|
EVERY_N_SECONDS(10) {
|
||||||
|
setup_pong();
|
||||||
|
nextPattern();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue