-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sine.ino
66 lines (64 loc) · 1.67 KB
/
Sine.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
void sinWave (uint16_t color, int Delay, int n, float mult) {
float w = matrix.width() * n;
float he = matrix.height();
float h = he / 2;
float a = (h - 1) / w;
float co;
int c;
for (int i = 0; i < w; i++) {
co = i * a;
c = ceil(h - co);
double r = sin(i * mult) * double(c);
// Serial.println("X: " + String(i) + " Y: " + String(round(r) + 8) + " C: " + String(c, 9) + " CO: " + String(co));
matrix.drawPixel(floor(i / n), (round(r) + 8), color);
updateScreen();
delay(Delay);
}
delay(Delay * 2);
int bri = BRIGHT;
for (int i = 0; i < 15; i++) {
if (bri > ceil(BRIGHT / 15.0)) {
bri -= ceil(BRIGHT / 15.0);
} else {
bri = 0;
}
brightOver(bri);
updateScreen();
delay(Delay);
}
Reset();
}
const double piOver = 3.14159265358979323846264338327950 / 180;
void sinWaveM (uint16_t color, int Delay, unsigned long Stop, float n, float s) {
unsigned long Start = millis();
Stop += Start;
int w = round(matrix.width() * n);
bool ad = false;
int he = floor(matrix.height() / 2.0);
float c = he;
while (Start < Stop) {
for (int i = 0; i < w; i++) {
float Sin = sin((i * piOver));
float si = Sin * c;
Serial.println("X: " + String(round(i / n)) + ", Y: " + String(round(si) + 8) + ", I: " + String(i) + ", Sin: " + String(Sin, 3) + ", Si: " + String((si + 8.0), 3));
matrix.drawPixel(round(i / n), round(si) + 8, color);
}
if (ad) {
c += s;
} else {
c -= s;
}
if (c > he) {
c = 8 - c;
ad = false;
}
if (c < 0) {
c = 0 - c;
ad = true;
}
matrix.show();
matrix.clear();
// delay(Delay);
}
Start = millis();
}