|
@@ -28,12 +28,6 @@
|
28
|
28
|
#define OK 0x42
|
29
|
29
|
#define ERROR 0x23
|
30
|
30
|
|
31
|
|
-#ifdef DEBUG
|
32
|
|
-#define VERSION "v2 (Debug Build)\nNOT COMPATIBLE WITH CubeControl!\n"
|
33
|
|
-#else
|
34
|
|
-#define VERSION "v2 Release\n"
|
35
|
|
-#endif
|
36
|
|
-
|
37
|
31
|
#include <avr/io.h>
|
38
|
32
|
#include <util/delay.h>
|
39
|
33
|
#include <avr/interrupt.h>
|
|
@@ -48,6 +42,7 @@
|
48
|
42
|
#include "mem.h"
|
49
|
43
|
#include "memLayer.h"
|
50
|
44
|
#include "twi.h"
|
|
45
|
+#include "strings.h"
|
51
|
46
|
|
52
|
47
|
#define NOERROR 0
|
53
|
48
|
// Audio does not answer
|
|
@@ -114,7 +109,7 @@ int main(void) {
|
114
|
109
|
|
115
|
110
|
i = selfTest();
|
116
|
111
|
if (i) {
|
117
|
|
- serialWriteString("Self-Test Error: 0b");
|
|
112
|
+ serialWriteString(getString(1));
|
118
|
113
|
serialWriteString(itoa(i, buffer, 2));
|
119
|
114
|
serialWrite('\n');
|
120
|
115
|
printErrors(i);
|
|
@@ -122,8 +117,8 @@ int main(void) {
|
122
|
117
|
#endif
|
123
|
118
|
|
124
|
119
|
#ifdef DEBUG
|
125
|
|
- serialWriteString("\n\nInitialized: ");
|
126
|
|
- serialWriteString(VERSION);
|
|
120
|
+ serialWriteString(getString(2));
|
|
121
|
+ serialWriteString(getString(0));
|
127
|
122
|
serialWriteString("Took ");
|
128
|
123
|
serialWriteString(itoa(getSystemTime(), buffer, 10));
|
129
|
124
|
serialWriteString(" ms!\n");
|
|
@@ -214,13 +209,13 @@ uint8_t selfTest(void) {
|
214
|
209
|
|
215
|
210
|
void printErrors(uint8_t e) {
|
216
|
211
|
if (ISERROR(e, AUDIOERROR)) {
|
217
|
|
- serialWriteString(" => No answer from Audio!\n");
|
|
212
|
+ serialWriteString(getString(3));
|
218
|
213
|
}
|
219
|
214
|
if (ISERROR(e, MEMORYERROR)) {
|
220
|
|
- serialWriteString(" => No answer from Memory!\n");
|
|
215
|
+ serialWriteString(getString(4));
|
221
|
216
|
}
|
222
|
217
|
if (ISERROR(e, MEMORYWRITEERROR)) {
|
223
|
|
- serialWriteString(" => Can't write to Memory!\n");
|
|
218
|
+ serialWriteString(getString(5));
|
224
|
219
|
}
|
225
|
220
|
}
|
226
|
221
|
#endif
|
|
@@ -228,6 +223,7 @@ void printErrors(uint8_t e) {
|
228
|
223
|
void serialHandler(char c) {
|
229
|
224
|
// Used letters:
|
230
|
225
|
// a, c, d, g, s, t, v, x
|
|
226
|
+ uint8_t i, y, z;
|
231
|
227
|
#ifdef DEBUG
|
232
|
228
|
serialWrite(c);
|
233
|
229
|
serialWriteString(": ");
|
|
@@ -239,14 +235,15 @@ void serialHandler(char c) {
|
239
|
235
|
break;
|
240
|
236
|
|
241
|
237
|
case 'h': case 'H': case '?':
|
242
|
|
- serialWriteString("(d)elete, (g)et anims, (s)et anims, (v)ersion\n");
|
|
238
|
+ serialWriteString(getString(6));
|
243
|
239
|
#ifdef DEBUG
|
244
|
|
- serialWriteString("(t)ime, (a)udio, (c)ount, (x)Custom count\n");
|
245
|
|
- serialWriteString("(y)Set fixed animation count\n");
|
246
|
|
- serialWriteString("S(e)lf Test\n");
|
247
|
|
- serialWriteString("Play S(n)ake\n");
|
248
|
|
- serialWriteString("(0): All LEDs Off\n");
|
249
|
|
- serialWriteString("(1): All LEDs On\n");
|
|
240
|
+ serialWriteString(getString(7));
|
|
241
|
+ serialWriteString(getString(8));
|
|
242
|
+ serialWriteString(getString(9));
|
|
243
|
+ serialWriteString(getString(10));
|
|
244
|
+ serialWriteString(getString(11));
|
|
245
|
+ serialWriteString(getString(12));
|
|
246
|
+ serialWriteString(getString(13));
|
250
|
247
|
#endif
|
251
|
248
|
break;
|
252
|
249
|
|
|
@@ -264,12 +261,12 @@ void serialHandler(char c) {
|
264
|
261
|
break;
|
265
|
262
|
|
266
|
263
|
case 'v': case 'V':
|
267
|
|
- serialWriteString(VERSION);
|
|
264
|
+ serialWriteString(getString(0));
|
268
|
265
|
break;
|
269
|
266
|
|
270
|
267
|
#ifdef DEBUG
|
271
|
268
|
case 't': case 'T':
|
272
|
|
- serialWriteString("System Time: ");
|
|
269
|
+ serialWriteString(getString(14));
|
273
|
270
|
serialWriteString(ltoa(getSystemTime(), buffer, 10));
|
274
|
271
|
serialWriteString("ms");
|
275
|
272
|
if (getSystemTime() > 1000) {
|
|
@@ -296,27 +293,27 @@ void serialHandler(char c) {
|
296
|
293
|
|
297
|
294
|
case 'c': case 'C':
|
298
|
295
|
serialWriteString(itoa(getAnimationCount(), buffer, 10));
|
299
|
|
- serialWriteString(" Frames stored\n");
|
|
296
|
+ serialWriteString(getString(15));
|
300
|
297
|
break;
|
301
|
298
|
|
302
|
299
|
case 'x': case 'X':
|
303
|
300
|
// Get byte, store as animation count
|
304
|
|
- serialWriteString("Send a byte... ");
|
|
301
|
+ serialWriteString(getString(16));
|
305
|
302
|
while (!serialHasChar());
|
306
|
303
|
c = serialGet();
|
307
|
304
|
setAnimationCount(c);
|
308
|
305
|
serialWriteString(itoa(c, buffer, 10));
|
309
|
|
- serialWriteString(" written!\n");
|
|
306
|
+ serialWriteString(getString(17));
|
310
|
307
|
break;
|
311
|
308
|
|
312
|
309
|
case 'y': case 'Y':
|
313
|
310
|
setAnimationCount(0x2201);
|
314
|
|
- serialWriteString("Animation count now 8705!\n");
|
|
311
|
+ serialWriteString(getString(18));
|
315
|
312
|
break;
|
316
|
313
|
|
317
|
314
|
case 'e': case 'E':
|
318
|
315
|
c = selfTest();
|
319
|
|
- serialWriteString("Self-Test: 0b");
|
|
316
|
+ serialWriteString(getString(19));
|
320
|
317
|
serialWriteString(itoa(c, buffer, 2));
|
321
|
318
|
serialWrite('\n');
|
322
|
319
|
printErrors(c);
|
|
@@ -327,17 +324,40 @@ void serialHandler(char c) {
|
327
|
324
|
break;
|
328
|
325
|
|
329
|
326
|
case '0':
|
330
|
|
- fillBuffer(0x00);
|
|
327
|
+ fillBuffer(0);
|
331
|
328
|
setAnimationCount(0);
|
332
|
329
|
refreshAnimationCount = 1;
|
333
|
|
- serialWriteString("Killed Animation Counter!\n");
|
|
330
|
+ serialWriteString(getString(20));
|
334
|
331
|
break;
|
335
|
332
|
|
336
|
333
|
case '1':
|
337
|
334
|
fillBuffer(0xFF);
|
338
|
335
|
setAnimationCount(0);
|
339
|
336
|
refreshAnimationCount = 1;
|
340
|
|
- serialWriteString("Killed Animation Counter!\n");
|
|
337
|
+ serialWriteString(getString(20));
|
|
338
|
+ break;
|
|
339
|
+
|
|
340
|
+ case '2':
|
|
341
|
+ fillBuffer(0);
|
|
342
|
+ for (i = 0; i < 64; i++) {
|
|
343
|
+ defaultImage[i] = 0;
|
|
344
|
+ }
|
|
345
|
+ while(1) {
|
|
346
|
+ for (i = 0; i < 8; i++) {
|
|
347
|
+ for (y = 0; y < 8; y++) {
|
|
348
|
+ defaultImage[y + (i * 8)] = 0;
|
|
349
|
+ for (z = 0; z < 8; z++) {
|
|
350
|
+ defaultImage[y + (i * 8)] |= (1 << z);
|
|
351
|
+ setImage(defaultImage);
|
|
352
|
+ while (isFinished() == 0);
|
|
353
|
+ }
|
|
354
|
+ defaultImage[y + (i * 8)] = 0;
|
|
355
|
+ }
|
|
356
|
+ }
|
|
357
|
+ if (serialHasChar()) {
|
|
358
|
+ break;
|
|
359
|
+ }
|
|
360
|
+ }
|
341
|
361
|
break;
|
342
|
362
|
#endif
|
343
|
363
|
|
|
@@ -353,9 +373,9 @@ void sendAudioData(void) {
|
353
|
373
|
uint8_t i;
|
354
|
374
|
uint8_t *audioData = getAudioData();
|
355
|
375
|
if (audioData == NULL) {
|
356
|
|
- serialWriteString("Could not access device!\n");
|
|
376
|
+ serialWriteString(getString(21));
|
357
|
377
|
} else {
|
358
|
|
- serialWriteString("Audio Data:\n");
|
|
378
|
+ serialWriteString(getString(22));
|
359
|
379
|
for (i = 0; i < 7; i++) {
|
360
|
380
|
serialWrite(i + '0');
|
361
|
381
|
serialWriteString(": ");
|