forked from fivefishstudios/AuroraDrop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDiagnostics.h
311 lines (192 loc) · 8.76 KB
/
Diagnostics.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
// Color definitions
//
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
uint32_t actual_render_ms = 0;
uint32_t start_render_ms = millis();
uint32_t total_render_ms = 0;
uint32_t actual_fps = 0;
void UpdateDiagnosticsData() {
#ifdef ONBOARD_RGB_LED_PIN
if (actual_render_ms > 1000/20) { // slower than 20fps
statuscontroller->leds()[0] = CRGB::Red;
statuscontroller->showLeds(10);
} else if (actual_render_ms > 1000/30) { // slower than 30fps
statuscontroller->leds()[0] = CRGB::Yellow;
statuscontroller->showLeds(10);
} else { // doing better than 30fps
statuscontroller->leds()[0] = CRGB::Green;
statuscontroller->showLeds(10);
}
#endif
// ------------------------ INFO --------------------------
// ---------------- show total render time ----------------
// show actual render time if over limit, 50 = 20fps
//
if (option3ShowRenderTime || option1Diagnostics) {
dma_display->setTextSize(1);
// display total render time
//
dma_display->setTextColor(WHITE);
if (actual_render_ms > 50) {
dma_display->setTextColor(YELLOW);
}
dma_display->setCursor(40,55);
dma_display->print(actual_render_ms);
dma_display->print("ms");
}
// if WiFi has just connected, show IP address and version notice
//
#ifdef USE_WIFI
if (wifiMessage > 0) {
wifiMessage--;
dma_display->setTextSize(1);
dma_display->setTextColor(WHITE, BLUE);
dma_display->setCursor(0,8);
dma_display->print(WiFi.localIP());
}
#endif
if (option5ShowEffectsStack) {
int startx = 2;
int starty = 2;
int yinc = 8;
dma_display->setTextSize(1);
dma_display->setTextColor(WHITE);
dma_display->setTextWrap(false);
for (uint8_t i=0; i < CountPlaylistsBackground; i++) {
dma_display->setCursor(startx,starty);
dma_display->printf("%02d %s",playlistBackground[i].render_ms, playlistBackground[i].getCurrentPatternName());
starty += yinc;
}
for (uint8_t i=0; i < CountPlaylistsAudio; i++) {
dma_display->setCursor(startx,starty);
dma_display->printf("%02d %s",playlistAudio[i].render_ms, playlistAudio[i].getCurrentPatternName());
starty += yinc;
}
for (uint8_t i=0; i < CountPlaylistsStatic; i++) {
dma_display->setCursor(startx,starty);
dma_display->printf("%02d %s",playlistStatic[i].render_ms, playlistStatic[i].getCurrentPatternName());
starty += yinc;
}
for (uint8_t i=0; i < CountPlaylistsForeground; i++) {
dma_display->setCursor(startx,starty);
dma_display->printf("%02d %s",playlistForeground[i].render_ms, playlistForeground[i].getCurrentPatternName());
starty += yinc;
}
}
// ---------------------- DIAGNOSTICS -------------------------
if (option1Diagnostics) {
for (uint8_t i=0; i < 16; i++) {
uint8_t height = map8(fftResult[i],0,32);
dma_display->drawFastVLine(0+(i*4)+0, 0, height, BLUE);
dma_display->drawFastVLine(0+(i*4)+1, 0, height, BLUE);
dma_display->drawFastVLine(0+(i*4)+2, 0, height, BLUE);
dma_display->drawFastVLine(0+(i*4)+3, 0, height, BLUE);
}
for (uint8_t i=0; i < 128; i++) {
uint8_t height = map8(fftData.specData[i],0,32);
dma_display->drawFastVLine(i, MATRIX_HEIGHT-32, height, GREEN);
}
for (uint8_t i=0; i < 16; i++) {
uint8_t height = map8(fftData.specData16[i],0,32);
dma_display->drawFastVLine(64+(i*4)+0, 0, height, GREEN);
dma_display->drawFastVLine(64+(i*4)+1, 0, height, GREEN);
dma_display->drawFastVLine(64+(i*4)+2, 0, height, GREEN);
dma_display->drawFastVLine(64+(i*4)+3, 0, height, GREEN);
}
dma_display->setTextSize(1);
dma_display->setTextColor(WHITE);
dma_display->setCursor(40,46);
dma_display->print(total_render_ms);
dma_display->print("ms");
// actual fps
dma_display->setCursor(2,46);
dma_display->print("G ");
dma_display->print(multAgc);
dma_display->setCursor(2,55);
dma_display->print(fftData.bpm);
dma_display->print("bpm");
for (uint8_t i=0; i < CountPlaylistsBackground; i++) {
dma_display->setTextColor(WHITE);
dma_display->setCursor(2+(i*20),1);
dma_display->print(playlistBackground[i].getCurrentPatternId());
if (playlistBackground[i].render_ms > 10) {
dma_display->setTextColor(YELLOW);
}
if (playlistBackground[i].render_ms > 15) {
dma_display->setTextColor(MAGENTA);
}
dma_display->print(playlistBackground[i].render_ms);
}
for (uint8_t i=0; i < CountPlaylistsAudio; i++) {
dma_display->setTextColor(WHITE);
dma_display->setCursor(2+(i*20),1+8);
dma_display->print(playlistAudio[i].getCurrentPatternId());
if (playlistAudio[i].render_ms > 10) {
dma_display->setTextColor(YELLOW);
}
if (playlistAudio[i].render_ms > 15) {
dma_display->setTextColor(MAGENTA);
}
dma_display->print(playlistAudio[i].render_ms);
}
for (uint8_t i=0; i < CountPlaylistsStatic; i++) {
dma_display->setTextColor(WHITE);
dma_display->setCursor(2+(i*20),1+8+8);
dma_display->print(playlistStatic[i].getCurrentPatternId());
if (playlistStatic[i].render_ms > 10) {
dma_display->setTextColor(YELLOW);
}
if (playlistStatic[i].render_ms > 15) {
dma_display->setTextColor(MAGENTA);
}
dma_display->print(playlistStatic[i].render_ms);
}
for (uint8_t i=0; i < CountPlaylistsForeground; i++) {
dma_display->setTextColor(WHITE);
dma_display->setCursor(2+(i*20),1+8+8+8);
dma_display->print(playlistForeground[i].getCurrentPatternId());
if (playlistForeground[i].render_ms > 10) {
dma_display->setTextColor(YELLOW);
}
if (playlistForeground[i].render_ms > 15) {
dma_display->setTextColor(MAGENTA);
}
dma_display->print(playlistForeground[i].render_ms);
}
for (uint8_t i=MATRIX_HEIGHT-10; i<MATRIX_HEIGHT-8; i++) {
// saw wave
//
dma_display->drawPixelRGB888(effects.beatSawOsciWidth[0], i, 0, 0, 128); // blue - fast
dma_display->drawPixelRGB888(effects.beatSawOsciWidth[1], i, 0, 128, 0); // green
dma_display->drawPixelRGB888(effects.beatSawOsciWidth[2], i, 128, 0, 0); // red
dma_display->drawPixelRGB888(effects.beatSawOsciWidth[3], i, 128, 128, 128); // white - slow
// sine wave
//
dma_display->drawPixelRGB888(effects.beatSineOsciWidth[0], i-1, 0, 0, 128);
dma_display->drawPixelRGB888(effects.beatSineOsciWidth[1], i-1, 0, 128, 0);
dma_display->drawPixelRGB888(effects.beatSineOsciWidth[2], i-1, 128, 0, 0);
dma_display->drawPixelRGB888(effects.beatSineOsciWidth[3], i-1, 128, 128, 128); // white - slow
// square wave
//
dma_display->drawPixelRGB888(effects.beatSquareOsci8[0] / 4, i, 128, 0, 128);
}
// BLINK BPM still testing bpm! (paint last so it's over top)
//
if (effects.beatSawOsci8[0] > 200) {
dma_display->drawPixelRGB888(MATRIX_WIDTH - 4, 2, 255, 255, 255);
dma_display->drawPixelRGB888(MATRIX_WIDTH - 3, 2, 255, 255, 255);
dma_display->drawPixelRGB888(MATRIX_WIDTH - 4, 3, 255, 255, 255);
dma_display->drawPixelRGB888(MATRIX_WIDTH - 3, 3, 255, 255, 255);
}
#ifdef DEDICATION
#include "dedication.h"
#endif
}
}