-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEffect_Sine.h
85 lines (77 loc) · 1.89 KB
/
Effect_Sine.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
// sine interference effect
//mode 1: sine 1 (red)
//mode 2: sine 2 (multi color)
//mode 3: sine 3 (variable color)
uint8_t sine_dist[M_WIDTH][M_HALFWIDTH];
int8_t sine_xoffset;
int8_t sine_yoffset;
uint16_t sine_freq;
uint16_t sine_speed;
uint8_t sine_color;
uint16_t sine_var;
void sine_init_common() {
uint8_t mlt256 = 256 / (M_HALFWIDTH + M_HEIGHT);
for(uint8_t y=0; y<M_HEIGHT; y++) {
for(uint8_t x=0; x<M_HALFWIDTH; x++) {
sine_dist[x][y] = sqrt((x+sine_xoffset)*(x+sine_xoffset) +
(y+sine_yoffset)*(y+sine_yoffset)) * mlt256;
}
}
}
void sine_step_common() {
for(uint8_t y=0; y<M_HEIGHT; y++) {
for(uint8_t x=0; x<M_HALFWIDTH; x++) {
leds[XY(M_HALFWIDTH+x,y)] = leds[XY(M_HALFWIDTH-x-1,y)] =
ColorMap(quadwave8(((sine_dist[x][y] * sine_freq) - (cnf.currFrame * sine_speed)%256)),sine_color,sine_var);
}
}
}
void eff_redwave() {
if(!cnf.isModeInit) {
cnf.currDelay = DELAY_NORMAL;
cnf.currBright = NORMBRIGHT;
sine_xoffset = 1;
sine_yoffset = -4;
sine_freq = 5;
sine_speed = 2;
sine_color = 1;
sine_var = 0;
sine_init_common();
cnf.canShowText = 1;
cnf.isModeInit = true;
}
sine_step_common();
}
void eff_redgreenwave() {
if(!cnf.isModeInit) {
cnf.currDelay = DELAY_NORMAL;
cnf.currBright = NORMBRIGHT;
sine_xoffset = 1;
sine_yoffset = -5;
sine_freq = 6;
sine_speed = 2;
sine_color = 4;
sine_var = 550;
sine_init_common();
cnf.canShowText = 1;
cnf.isModeInit = true;
}
sine_step_common();
}
void eff_rainbowwave() {
if(!cnf.isModeInit) {
cnf.currDelay = DELAY_NORMAL;
cnf.currBright = NORMBRIGHT;
sine_xoffset = -8;
sine_yoffset = 6;
sine_freq = 7;
sine_speed = 2;
sine_color = 4;
sine_var = 0;
sine_init_common();
cnf.canShowText = 1;
cnf.isModeInit = true;
}
sine_var = cnf.currFrame;
sine_step_common();
}