-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfireworks.h
88 lines (76 loc) · 1.52 KB
/
fireworks.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef FIREWORKS_H
#define FIREWORKS_H
#include "animation.h"
class Fireworks : public Animation {
public:
Fireworks()
{
position = 0;
delay_time = 20;
explode_phase = 0;
current_color = CRGB::Blue;//fix later
}
void explode(CRGB *leds)
{
//if first phase, set current led to black and +-1 LED to color
if(explode_phase == 1){
}
}
void step()
{
leds[position] = CRGB::Black;
//index position of lit LED
if(position == NUM_LEDS/2)
{
if(explode_phase == 2)
{
leds[position+2] = CRGB::Black;
leds[position-2] = CRGB::Black;
explode_phase++;
}
if(explode_phase == 1)
{
leds[position+1] = CRGB::Black;
leds[position-1] = CRGB::Black;
leds[position+2] = current_color;
leds[position-2] = current_color;
explode_phase++;
}
if(explode_phase == 0)
{
delay_time = 150;
leds[position+1] = current_color;
leds[position-1] = current_color;
explode_phase++;
}
if(explode_phase == 3)
{
//reset things
position = 0;
explode_phase = 0;
delay_time = 20;
current_color = CHSV(random(255),random(255),random(255));
leds[position] = current_color;
}
}
else
{
position++;
leds[position] = current_color;
delay_time = delay_time+1;
}
// load the CRGB values into led
FastLED.show();
delay(delay_time);
}
private:
int position;
int delay_time;
int explode_phase;
CRGB current_color;
CRGB buffer[NUM_LEDS];
};
Animation * fireworks_factory() {
return new Fireworks();
}
#endif