-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathd_bitBars.ino
83 lines (64 loc) · 1.62 KB
/
d_bitBars.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
// DRUM MODE
// each drum hit adds a "building block"
//sparkle mode data
uint16_t DBBsize = int(NPIX / 4);
uint8_t DBBwhiteDim = 4;
uint8_t DBBwhiteMax = 64;
uint8_t DBBcolorDim = 32;
uint8_t DBBcolorMax = 120;
uint8_t DBBcolorStep = 4;
uint8_t DBBcolorHue[161];
uint8_t DBBbarPos = 0;
void bitBarsSetup() {
for (uint16_t b=0; b<DBBsize; b++) {
DBBcolorHue[b] = 15;
}
DBBbarPos = DBBsize;
for (uint16_t p=0; p<NPIX; p++) {
pixelBrightness[p] = random(DBBwhiteDim, DBBwhiteMax);
uint8_t dir = random(2);
if (dir < 1) {
pixelBrightness[p] *= -1;
}
}
}
void bitBarsInit() {
midiClearAll();
detachInterrupt(0);
attachInterrupt(0, fourBitInput, FALLING);
fourBitInput();
bitBarsSetup();
for (;;) {
bitBarsLoop();
if (progBreak) {
return;
}
}
}
void bitBarsLoop() {
midiOutput();
if (fourBitHits > 0) {
DBBbarPos++;
if (DBBbarPos >= DBBsize) {
DBBbarPos = 0;
}
DBBcolorHue[DBBbarPos] = fourBitHits;
DBBcolorHue[(DBBbarPos+1)] = 15; //colorWhite
fourBitHits = 0;
} else {
//for (int p=0; p<NPIX; p++) {
// pixelNextVal(p, DBBcolorDim, DBBcolorMax, DBBcolorStep);
// strip.setPixelColor(p, pixelSetHue(fourBitColors[DBBcolorHue[p/4]], pixelBrightness[p]));
//}
for (uint16_t b=0; b<DBBsize; b++) {
pixelNextVal(b, DBBcolorDim, DBBcolorMax, DBBcolorStep);
uint32_t c = pixelSetHue(fourBitColors[DBBcolorHue[b]], pixelBrightness[b]);
uint16_t p = b*4;
for (uint8_t i=0; i<4; i++) {
strip.setPixelColor(p+i, c);
}
}
}
strip.show();
//delay(5);
}