-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpozion.ino
212 lines (166 loc) · 3.7 KB
/
simpozion.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#include "FastLED.h"
#define LED_TYPE WS2812B
#define DATA_PIN 2
#define NUM_LEDS 90
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 255
#define frames 120
void setup() {
delay(3000);
Serial.begin(9600);
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
typedef void (*structura[])();
structura lista = { cursa, foc, curcubeu1, curcubeu2, confetti, joc1, extra, bataie_de_inima, party, alb negru, curcubeu };
int fpsetup = 0;
int culori = 0;
void loop()
{
lista[fpsetup]();
FastLED.show();
FastLED.delay(1000 / frames);
delay( 20 ) {
culori++;
}
delay( 10 ) {
urmatorul();
}
}
#define vector1(A) (a(A) / a((A)[0]))
void urmatorul()
{
fpsetup = (fpsetup + 1) % vector1( lista);
Serial.println(fpsetup);
}
void curcubeu1()
{
fill_curcubeu1( leds, NUM_LEDS, culori, 7);
}
void curcubeu2()
{
curcubeu1();
addGlitter(80);
}
void addGlitter( int sansa)
{
if ( random8() < sansa) {
leds[ random16(NUM_LEDS) ] += CRGB::White;
}
}
void confetti()
{
fadeToBlackBy( leds, NUM_LEDS, 10);
int pos = random16(NUM_LEDS);
leds[pos] += CHSV( culori + random8(64), 200, 255);
}
void joc1()
{
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16( 13, 0, NUM_LEDS - 1 );
leds[pos] += CHSV( culori, 255, 192);
}
void bataie_de_inima()
{
int bpm = 62;
CRGBPalette16 palette = party_p;
int beat = beatsin8( bpm, 64, 255);
for ( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette(palette, culori + (i * 2), beat - culori + (i * 10));
}
}
void extra() {
fadeToBlackBy( leds, NUM_LEDS, 20);
byte dothue = 0;
for ( int i = 0; i < 8; i++) {
leds[beatsin16( i + 7, 0, NUM_LEDS - 1 )] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
#define COOLING 55
#define boom 120
bool invers = false;
void foc()
{
int foc1[NUM_LEDS];
for ( int i = 0; i < NUM_LEDS; i++) {
foc1[i] = qsub8( foc1[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
}
for ( int k = NUM_LEDS - 1; k >= 2; k--) {
foc1[k] = (foc1[k - 1] + foc1[k - 2] + foc1[k - 2] ) / 3;
}
if ( random8() < boom ) {
int y = random8(7);
foc1[y] = qadd8( foc1[y], random8(160, 255) );
}
for ( int j = 0; j < NUM_LEDS; j++) {
CRGB color = foc1Color( foc1[j]);
int nrled;
if ( invers ) {
nrled = (NUM_LEDS - 1) - j;
} else {
nrled = j;
}
leds[nrled] = color;
}
}
void fadeall() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i].nscale8(250);
}
}
void cursa() {
int hue = 0;
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(hue++, 255, 255);
FastLED.show();
fadeall();
delay(10);
}
for (int i = (NUM_LEDS) - 1; i >= 0; i--) {
leds[i] = CHSV(hue++, 255, 255);
FastLED.show();
fadeall();
delay(10);
}
}
CRGBPalette16 cculori;
TBlendType amestec;
void party() {
if (cculori != party_p) {
cculori = party_p;
amestec = LINEARBLEND;
}
int start1 = 0;
start1 = start1 + 1;
cculoriUmplute( start1);
}
void cculoriUmplute( int colorIndex)
{
int brightness = 255;
for ( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette( cculori, colorIndex, brightness, amestec);
colorIndex += 3;
}
}
void curcubeu() {
if (cculori != curcubeu_p) {
cculori = curcubeu_p;
amestec = LINEARBLEND;
}
int start1 = 0;
start1 = start1 + 1;
cculoriUmplute( start1);
}
void alb negru()
{
fill_solid( cculori, 16, CRGB::Black);
cculori[0] = CRGB::White;
cculori[4] = CRGB::White;
cculori[8] = CRGB::White;
cculori[12] = CRGB::White;
int start1 = 0;
start1 = start1 + 1;
cculoriUmplute( start1);
}