|
@@ -63,19 +63,16 @@
|
63
|
63
|
|
64
|
64
|
void serialHandler(char c);
|
65
|
65
|
uint8_t audioModeSelected(void);
|
66
|
|
-#ifdef DEBUG
|
67
|
66
|
void printErrors(uint8_t e);
|
68
|
67
|
uint8_t selfTest(void);
|
69
|
68
|
void printTime(void);
|
70
|
69
|
|
71
|
|
-#include "snake.c"
|
72
|
|
-#endif
|
|
70
|
+// #include "snake.c"
|
73
|
71
|
|
74
|
72
|
uint8_t shouldRestart = 0;
|
75
|
73
|
uint8_t refreshAnimationCount = 1;
|
76
|
74
|
uint8_t lastButtonState = 0;
|
77
|
75
|
uint8_t maxButtonState = 0;
|
78
|
|
-uint8_t mcusr_mirror;
|
79
|
76
|
char buffer[11];
|
80
|
77
|
|
81
|
78
|
#include "builtInFrames.c"
|
|
@@ -90,11 +87,8 @@ int main(void) {
|
90
|
87
|
uint16_t count;
|
91
|
88
|
uint64_t lastChecked;
|
92
|
89
|
uint8_t idleCounter = 0;
|
93
|
|
-#ifdef DEBUG
|
94
|
90
|
uint32_t temp;
|
95
|
|
-#endif
|
96
|
91
|
|
97
|
|
- mcusr_mirror = MCUCSR;
|
98
|
92
|
MCUCSR = 0;
|
99
|
93
|
wdt_disable();
|
100
|
94
|
|
|
@@ -113,37 +107,17 @@ int main(void) {
|
113
|
107
|
|
114
|
108
|
wdt_enable(WDTO_1S); // Watchdog reset after 1 second
|
115
|
109
|
|
116
|
|
-#ifdef DEBUG
|
117
|
|
- // Kill animation counter in debug mode
|
118
|
|
- // => Don't preserve animations while power down
|
119
|
|
- setAnimationCount(0);
|
120
|
|
-
|
121
|
|
- serialWriteString(getString(2));
|
|
110
|
+ serialWriteString(getString(2)); // "Initialized: "
|
122
|
111
|
|
123
|
112
|
i = selfTest();
|
124
|
113
|
if (i) {
|
125
|
|
- serialWriteString(getString(1));
|
|
114
|
+ serialWriteString(getString(1)); // Selftest error
|
126
|
115
|
serialWriteString(itoa(i, buffer, 2));
|
127
|
116
|
serialWrite('\n');
|
128
|
117
|
printErrors(i);
|
129
|
118
|
}
|
130
|
119
|
|
131
|
|
- serialWriteString(getString(0));
|
132
|
|
-
|
133
|
|
- if (mcusr_mirror & WDRF) {
|
134
|
|
- serialWriteString(getString(31));
|
135
|
|
- } else if (mcusr_mirror & BORF) {
|
136
|
|
- serialWriteString(getString(32));
|
137
|
|
- } else if (mcusr_mirror & EXTRF) {
|
138
|
|
- serialWriteString(getString(34));
|
139
|
|
- } else if (mcusr_mirror & JTRF) {
|
140
|
|
- serialWriteString(getString(35));
|
141
|
|
- } else if (mcusr_mirror & PORF) {
|
142
|
|
- serialWriteString(getString(36));
|
143
|
|
- } else {
|
144
|
|
- serialWriteString(getString(33));
|
145
|
|
- }
|
146
|
|
-#endif
|
|
120
|
+ serialWriteString(getString(0)); // Version
|
147
|
121
|
|
148
|
122
|
maxButtonState = numberOfVisualizations() + 1; // All visualizations and anim mode
|
149
|
123
|
|
|
@@ -219,8 +193,7 @@ int main(void) {
|
219
|
193
|
serialHandler((char)(serialGet()));
|
220
|
194
|
}
|
221
|
195
|
|
222
|
|
-#ifdef DEBUG
|
223
|
|
- // Print frames per second
|
|
196
|
+ // Print fps after one second
|
224
|
197
|
if ((getSystemTime() >= 1000) && ((DebugDone & 1) == 0)) {
|
225
|
198
|
temp = getTriggerCount();
|
226
|
199
|
serialWriteString(ltoa(temp, buffer, 10));
|
|
@@ -229,7 +202,6 @@ int main(void) {
|
229
|
202
|
serialWriteString(getString(28));
|
230
|
203
|
DebugDone |= 1;
|
231
|
204
|
}
|
232
|
|
-#endif
|
233
|
205
|
|
234
|
206
|
if ((getSystemTime() - lastChecked) > 150) { // Check button state every 150ms
|
235
|
207
|
audioModeSelected();
|
|
@@ -252,19 +224,10 @@ uint8_t audioModeSelected(void) {
|
252
|
224
|
lastButtonState = 0;
|
253
|
225
|
}
|
254
|
226
|
|
255
|
|
-#ifdef DEBUG
|
256
|
|
- if (lastButtonState) {
|
257
|
|
- serialWriteString(getString(38));
|
258
|
|
- } else {
|
259
|
|
- serialWriteString(getString(39));
|
260
|
|
- }
|
261
|
|
-#endif
|
262
|
|
-
|
263
|
227
|
}
|
264
|
228
|
return lastButtonState;
|
265
|
229
|
}
|
266
|
230
|
|
267
|
|
-#ifdef DEBUG
|
268
|
231
|
uint8_t selfTest(void) {
|
269
|
232
|
uint8_t result = NOERROR;
|
270
|
233
|
|
|
@@ -329,16 +292,11 @@ void randomAnimation(void) {
|
329
|
292
|
}
|
330
|
293
|
free(b);
|
331
|
294
|
}
|
332
|
|
-#endif
|
333
|
295
|
|
334
|
296
|
void serialHandler(char c) {
|
335
|
297
|
// Used letters:
|
336
|
298
|
// a, b, c, d, e, g, i, n, q, r, s, t, v, x, y, 0, 1, 2, 3, #
|
337
|
|
-#ifdef DEBUG
|
338
|
299
|
uint8_t i, y, z;
|
339
|
|
- serialWrite(c);
|
340
|
|
- serialWriteString(": ");
|
341
|
|
-#endif
|
342
|
300
|
|
343
|
301
|
switch(c) {
|
344
|
302
|
case OK:
|
|
@@ -347,7 +305,6 @@ void serialHandler(char c) {
|
347
|
305
|
|
348
|
306
|
case 'h': case 'H': case '?':
|
349
|
307
|
serialWriteString(getString(6));
|
350
|
|
-#ifdef DEBUG
|
351
|
308
|
serialWriteString(getString(7));
|
352
|
309
|
serialWriteString(getString(8));
|
353
|
310
|
serialWriteString(getString(9));
|
|
@@ -356,20 +313,13 @@ void serialHandler(char c) {
|
356
|
313
|
serialWriteString(getString(12));
|
357
|
314
|
serialWriteString(getString(13));
|
358
|
315
|
serialWriteString(getString(26));
|
359
|
|
-#endif
|
360
|
316
|
break;
|
361
|
317
|
|
362
|
318
|
case 'd': case 'D':
|
363
|
319
|
clearMem();
|
364
|
|
-#ifndef DEBUG
|
365
|
320
|
serialWrite(OK);
|
366
|
|
-#endif
|
367
|
|
-#ifdef DEBUG
|
368
|
|
- serialWriteString(getString(29));
|
369
|
|
-#endif
|
370
|
321
|
break;
|
371
|
322
|
|
372
|
|
-#ifndef DEBUG
|
373
|
323
|
case 'g': case 'G':
|
374
|
324
|
transmitAnimations();
|
375
|
325
|
break;
|
|
@@ -377,13 +327,11 @@ void serialHandler(char c) {
|
377
|
327
|
case 's': case 'S':
|
378
|
328
|
recieveAnimations();
|
379
|
329
|
break;
|
380
|
|
-#endif
|
381
|
330
|
|
382
|
331
|
case 'v': case 'V':
|
383
|
332
|
serialWriteString(getString(0));
|
384
|
333
|
break;
|
385
|
334
|
|
386
|
|
-#ifdef DEBUG
|
387
|
335
|
case 'm': case 'M':
|
388
|
336
|
lastButtonState = !lastButtonState;
|
389
|
337
|
if (lastButtonState) {
|
|
@@ -439,7 +387,7 @@ void serialHandler(char c) {
|
439
|
387
|
break;
|
440
|
388
|
|
441
|
389
|
case 'n': case 'N':
|
442
|
|
- snake();
|
|
390
|
+ // snake();
|
443
|
391
|
break;
|
444
|
392
|
|
445
|
393
|
case '0':
|
|
@@ -492,7 +440,6 @@ killMeForIt:
|
492
|
440
|
serialWriteString(ltoa(getTriggerCount(), buffer, 10));
|
493
|
441
|
serialWrite('\n');
|
494
|
442
|
break;
|
495
|
|
-#endif
|
496
|
443
|
|
497
|
444
|
default:
|
498
|
445
|
serialWrite(ERROR);
|
|
@@ -501,7 +448,6 @@ killMeForIt:
|
501
|
448
|
// c was used as temp var and does not contain the char anymore...!
|
502
|
449
|
}
|
503
|
450
|
|
504
|
|
-#ifdef DEBUG
|
505
|
451
|
void printTime(void) {
|
506
|
452
|
serialWriteString(getString(14));
|
507
|
453
|
serialWriteString(ltoa(getSystemTime(), buffer, 10));
|
|
@@ -528,4 +474,3 @@ void printTime(void) {
|
528
|
474
|
serialWrite('\n');
|
529
|
475
|
}
|
530
|
476
|
}
|
531
|
|
-#endif
|