Browse Source

Can now upload frames "by hand"

Thomas Buck 12 years ago
parent
commit
ff5d0d9043
5 changed files with 1368 additions and 1286 deletions
  1. 4
    1
      CubeFirmware/header/transmit.h
  2. 9
    16
      CubeFirmware/main.c
  3. 1309
    1261
      CubeFirmware/main.hex
  4. 6
    6
      CubeFirmware/strings.c
  5. 40
    2
      CubeFirmware/transmit.c

+ 4
- 1
CubeFirmware/header/transmit.h View File

@@ -25,4 +25,7 @@ void recieveAnimations(void);
25 25
 void transmitAnimations(void);
26 26
 void sendAudioData(void);
27 27
 void printTime(void);
28
-void dumpFrame(uint8_t *f);
28
+void dumpFrame(uint8_t *f);
29
+uint8_t *readLine(void);
30
+uint8_t readNumber(uint8_t base);
31
+uint8_t *readAFrame(void);

+ 9
- 16
CubeFirmware/main.c View File

@@ -327,7 +327,7 @@ void randomAnimation(void) {
327 327
 
328 328
 void serialHandler(char c) {
329 329
 	// Used letters:
330
-	// a, b, c, d, e, f, g, h, i, n, q, r, s, t, u, v, x, y, 0, 1, 2, 3, #
330
+	// a, b, c, d, e, f, g, h, i, m, n, q, r, s, t, u, v, x, y, 0, 1, 2, 3, #
331 331
 	uint8_t i, y, z;
332 332
 	uint8_t *tmp;
333 333
 
@@ -416,30 +416,23 @@ void serialHandler(char c) {
416 416
 
417 417
 	case 'u': case 'U':
418 418
 		serialWriteString(getString(31));
419
-		while(!serialHasChar()) {
420
-			wdt_reset();
421
-		}
422
-		i = serialGet() - '0';
423
-		serialWrite(i + '0');
424
-		serialWrite('\n');
425
-		tmp = getFrame(i);
419
+		tmp = getFrame(readNumber(10));
426 420
 		dumpFrame(tmp);
427 421
 		free(tmp);
428 422
 		break;
429 423
 
430 424
 	case 'x': case 'X':
431 425
 		// Get byte, store as animation count
432
-		serialWriteString(getString(16));
433
-		while (!serialHasChar());
434
-		c = serialGet();
435
-		setAnimationCount(c);
436
-		serialWriteString(itoa(c, buffer, 10));
437
-		serialWriteString(getString(17));
426
+		serialWriteString(getString(16)); // "New animation count: "
427
+		setAnimationCount(readNumber(10));
438 428
 		break;
439 429
 
440 430
 	case 'y': case 'Y':
441
-		setAnimationCount(0x2201);
442
-		serialWriteString(getString(18));
431
+		serialWriteString(getString(18)); // "Frame to change: "
432
+		i = readNumber(10);
433
+		tmp = readAFrame();
434
+		setFrame(i, tmp);
435
+		free(tmp);
443 436
 		break;
444 437
 
445 438
 	case 'e': case 'E':

+ 1309
- 1261
CubeFirmware/main.hex
File diff suppressed because it is too large
View File


+ 6
- 6
CubeFirmware/strings.c View File

@@ -32,17 +32,17 @@ const char stringMemError[] PROGMEM = " => No answer from Memory!\n"; // 4
32 32
 const char stringMemWriteError[] PROGMEM = " => Can't write to Memory!\n"; // 5
33 33
 const char stringHelp1[] PROGMEM = "(d)elete, (g)et anims, (s)et anims, (v)ersion\n"; // 6
34 34
 const char stringHelp2[] PROGMEM = "(t)ime, (a)udio, (c)ount, (x)Custom count\n"; // 7
35
-const char stringHelp3[] PROGMEM = "(y)Set fixed animation count\n"; // 8
36
-const char stringHelp4[] PROGMEM = "S(e)lf Test, (m)ode, d(u)mp\n"; // 9
35
+const char stringHelp3[] PROGMEM = "(y)Set a frame\n"; // 8
36
+const char stringHelp4[] PROGMEM = "t(e)st, (m)ode, d(u)mp\n"; // 9
37 37
 const char stringHelp5[] PROGMEM = "Play S(n)ake\n"; // 10
38 38
 const char stringHelp6[] PROGMEM = "All LEDs Off/On (0/1)\n"; // 11
39 39
 const char stringHelp7[] PROGMEM = "(2): Test Anim. 1\n"; // 12
40 40
 const char stringHelp8[] PROGMEM = "(3): All Surface LEDs on\n"; // 13
41 41
 const char stringTime[] PROGMEM = "System Time: "; // 14
42 42
 const char stringFrames[] PROGMEM = " Frames stored\n"; // 15
43
-const char stringByte[] PROGMEM = "Send a byte... "; // 16
44
-const char stringWritten[] PROGMEM = " written!\n"; // 17
45
-const char stringCount[] PROGMEM = "Animation count now 8705!\n"; // 18
43
+const char stringByte[] PROGMEM = "New animation count: "; // 16
44
+const char stringWritten[] PROGMEM = ""; // 17
45
+const char stringCount[] PROGMEM = "Frame to change: "; // 18
46 46
 const char stringSelfTest[] PROGMEM = "Self-Test: 0b"; // 19
47 47
 const char stringKillCount[] PROGMEM = "Killed Animation Counter!\n"; // 20
48 48
 const char stringAccessError[] PROGMEM = "Could not access device!\n"; // 21
@@ -59,7 +59,7 @@ const char stringWatchdog[] PROGMEM = "Enter frame to dump: "; // 31
59 59
 const char stringBrownout[] PROGMEM = "Formatting memory... "; // 32
60 60
 const char stringNothing[] PROGMEM = "Done!\n"; // 33
61 61
 const char stringExtern[] PROGMEM = "(f)ormat memory\n"; // 34
62
-const char stringJtag[] PROGMEM = ""; // 35
62
+const char stringJtag[] PROGMEM = "Duration: "; // 35
63 63
 const char stringPowerOn[] PROGMEM = ""; // 36
64 64
 const char stringMinute[] PROGMEM = ""; // 37
65 65
 const char stringAudioMode[] PROGMEM = ""; // 38

+ 40
- 2
CubeFirmware/transmit.c View File

@@ -148,7 +148,6 @@ void recieveAnimations(void) {
148 148
 	setAnimationCount(completeCount);
149 149
 }
150 150
 
151
-// TODO: Rewrite for new Serial API
152 151
 void transmitAnimations(void) {
153 152
 	serialWrite(ERROR);
154 153
 }
@@ -209,8 +208,47 @@ void dumpFrame(uint8_t *f) {
209 208
 		}
210 209
 		serialWrite('\n');
211 210
 	}
212
-	serialWriteString("Duration: ");
211
+	serialWriteString(getString(35));
213 212
 	itoa(f[64], buffer, 10);
214 213
 	serialWriteString(buffer);
215 214
 	serialWrite('\n');
216 215
 }
216
+
217
+uint8_t *readLine(void) {
218
+	uint8_t ptr = 0;
219
+	while(1) {
220
+		wdt_reset();
221
+		if (serialHasChar()) {
222
+			buffer[ptr] = serialGet();
223
+			serialWrite(buffer[ptr]);
224
+			if ((buffer[ptr] == '\n') || (ptr == sizeof(buffer) - 1)) {
225
+				buffer[ptr] = '\0';
226
+				return (uint8_t *)buffer;
227
+			}
228
+			ptr++;
229
+		}
230
+
231
+	}
232
+}
233
+
234
+uint8_t readNumber(uint8_t base) {
235
+	uint8_t *s = readLine();
236
+	uint8_t val = (uint8_t)strtoul((char *)s, NULL, base);
237
+	return val;
238
+}
239
+
240
+uint8_t *readAFrame(void) {
241
+	uint8_t *frame = (uint8_t *)malloc(65);
242
+	uint8_t byte;
243
+
244
+	serialWriteString(getString(35)); // "Duration: "
245
+	frame[64] = readNumber(10);
246
+	for (byte = 0; byte < 64; byte++) {
247
+		itoa(byte, buffer, 10);
248
+		serialWriteString(buffer);
249
+		serialWriteString(": "); // "xx: "
250
+		frame[byte] = readNumber(16);
251
+	}
252
+	serialWriteString(getString(33));
253
+	return frame;
254
+}

Loading…
Cancel
Save