|
@@ -36,17 +36,18 @@
|
36
|
36
|
uint8_t maxVal(uint8_t data, uint8_t log);
|
37
|
37
|
void setRow(uint8_t x, uint8_t z, uint8_t height, uint8_t *buf);
|
38
|
38
|
uint8_t average(uint8_t *data);
|
39
|
|
-void filterData(uint8_t *data);
|
|
39
|
+void filterData(uint8_t *data, uint8_t log);
|
40
|
40
|
void simpleVisualization(uint8_t *data);
|
41
|
41
|
void fullDepthVisualization(uint8_t *data);
|
42
|
42
|
void horribleWave(uint8_t *audioData);
|
43
|
43
|
void simpleLog(uint8_t *data);
|
44
|
44
|
void fullDepthLog(uint8_t *data);
|
|
45
|
+void linLog(uint8_t *data);
|
45
|
46
|
|
46
|
|
-#define NUMOFVISUALIZATIONS 5
|
|
47
|
+#define NUMOFVISUALIZATIONS 6
|
47
|
48
|
void (*visualizations[NUMOFVISUALIZATIONS])(uint8_t *data) = { &simpleVisualization,
|
48
|
49
|
&fullDepthVisualization, &horribleWave,
|
49
|
|
- &simpleLog, &fullDepthLog };
|
|
50
|
+ &simpleLog, &fullDepthLog, &linLog };
|
50
|
51
|
uint8_t logScale[8] = { 2, 4, 8, 16, 31, 63, 125, 250 }; // --> ca. (1 << (led + 1));
|
51
|
52
|
|
52
|
53
|
uint8_t numberOfVisualizations(void) {
|
|
@@ -55,8 +56,13 @@ uint8_t numberOfVisualizations(void) {
|
55
|
56
|
|
56
|
57
|
void runVisualization(uint8_t *data, uint8_t id) {
|
57
|
58
|
if (id < NUMOFVISUALIZATIONS) {
|
58
|
|
- filterData(data);
|
59
|
|
- visualizations[id](data);
|
|
59
|
+ if ((id <= 5) && (id > 2)) {
|
|
60
|
+ filterData(data, 1);
|
|
61
|
+ visualizations[id](data);
|
|
62
|
+ } else {
|
|
63
|
+ filterData(data, 0);
|
|
64
|
+ visualizations[id](data);
|
|
65
|
+ }
|
60
|
66
|
}
|
61
|
67
|
}
|
62
|
68
|
|
|
@@ -81,9 +87,15 @@ uint8_t average(uint8_t *data) {
|
81
|
87
|
return (uint8_t)sum;
|
82
|
88
|
}
|
83
|
89
|
|
84
|
|
-void filterData(uint8_t *data) {
|
|
90
|
+void filterData(uint8_t *data, uint8_t log) {
|
85
|
91
|
uint8_t i;
|
86
|
|
- if (average(data) < THRESHOLD) {
|
|
92
|
+ uint8_t max;
|
|
93
|
+ if (log) {
|
|
94
|
+ max = THRESHOLD / 2;
|
|
95
|
+ } else {
|
|
96
|
+ max = THRESHOLD;
|
|
97
|
+ }
|
|
98
|
+ if (average(data) < max) {
|
87
|
99
|
for (i = 0; i < 7; i++) {
|
88
|
100
|
data[i] = 0;
|
89
|
101
|
}
|
|
@@ -129,6 +141,20 @@ void simpleVisualization(uint8_t *data) {
|
129
|
141
|
buffFree(buff);
|
130
|
142
|
}
|
131
|
143
|
|
|
144
|
+void linLog(uint8_t *data) {
|
|
145
|
+ uint8_t *buff;
|
|
146
|
+ buff = buffNew();
|
|
147
|
+
|
|
148
|
+ buffClearAllPixels(buff);
|
|
149
|
+
|
|
150
|
+ simpleVUMeter(data, buff, 2, 1);
|
|
151
|
+ filterData(data, 0);
|
|
152
|
+ simpleVUMeter(data, buff, 5, 0);
|
|
153
|
+
|
|
154
|
+ setImage(buff);
|
|
155
|
+ buffFree(buff);
|
|
156
|
+}
|
|
157
|
+
|
132
|
158
|
void fullDepthLog(uint8_t *data) {
|
133
|
159
|
uint8_t *buff;
|
134
|
160
|
uint8_t i;
|