-
Notifications
You must be signed in to change notification settings - Fork 0
/
Effect_KR.h
72 lines (65 loc) · 1.75 KB
/
Effect_KR.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
//mode 1: red kr effect
//mode 2: rainbow kr effect
//mode 3: sound reactive kr effect (hue shift)
#define KR_WIDTH 12 // width of KR-band
#define KR_BORDER (KR_WIDTH/4)
#define KR_DIMSPEED 23
#define KR_BPM 20
void effectKRCommon() {
dimLeds(KR_DIMSPEED , &leds[OCTO_OFFSET], 1);
uint8_t startPos = beatsin8(KR_BPM,0,M_WIDTH-KR_WIDTH);
uint8_t top, bottom;
if(M_HEIGHT > 4) {
bottom = M_HEIGHT/4;
top = M_HEIGHT-(M_HEIGHT/4);
} else {
bottom = 0;
top = M_HEIGHT;
}
for(uint8_t i=bottom; i<top; i++) {
for(uint8_t j=startPos;j<startPos+KR_WIDTH;j++) {
leds[XY(j,i)] += currColor;
// fade out edges of square. -- idea: fade out in a circle or oval to get more of a HAL-9000 look...
if((j<startPos+KR_BORDER) || (j>(startPos+KR_WIDTH-1-KR_BORDER))) {
leds[XY(j,i)].fadeToBlackBy(64);
}
if(i==bottom || i==(top-1)) {
leds[XY(j,i)].fadeToBlackBy(128);
if(j==startPos || j==(startPos+KR_WIDTH-1)) {
leds[XY(j,i)].fadeToBlackBy(128);
}
}
}
}
}
void eff_redKR() {
if(!cnf.isModeInit) {
cnf.currDelay = DELAY_KR;
cnf.currBright = NORMBRIGHT;
currColor = CRGB(192,6,0); // red
cnf.canShowText = 0;
cnf.isModeInit = true;
}
effectKRCommon();
}
void eff_rainbowKR() {
if(!cnf.isModeInit) {
cnf.currDelay = DELAY_KR;
cnf.currBright = NORMBRIGHT;
cnf.canShowText = 0;
cnf.isModeInit = true;
}
currColor = CHSV(cnf.currHue,255,255);
effectKRCommon();
}
void eff_soundKR() {
if(!cnf.isModeInit) {
cnf.currDelay = DELAY_KR;
cnf.currBright = NORMBRIGHT;
cnf.canShowText = 0;
cnf.isModeInit = true;
}
currColor = Wheel(520 + cnf.eqVol[1]);
currColor.fadeToBlackBy(128-(cnf.eqVol[1]/2));
effectKRCommon();
}