Browse Source

Storing frames no longer corrupts them!

Thomas Buck 12 years ago
parent
commit
521b36d7fe

+ 1
- 0
CubeFirmware/header/memLayer.h View File

25
 uint8_t *getFrame(uint16_t frameNumber);
25
 uint8_t *getFrame(uint16_t frameNumber);
26
 // 65 bytes framedata, data and duration...
26
 // 65 bytes framedata, data and duration...
27
 void setFrame(uint16_t frameNumber, uint8_t *frameData);
27
 void setFrame(uint16_t frameNumber, uint8_t *frameData);
28
+void setDuration(uint16_t frameNumber, uint8_t duration);
28
 
29
 
29
 void clearMem(void);
30
 void clearMem(void);
30
 
31
 

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

28
 void dumpFrame(uint8_t *f);
28
 void dumpFrame(uint8_t *f);
29
 uint8_t *readLine(void);
29
 uint8_t *readLine(void);
30
 uint8_t readNumber(uint8_t base);
30
 uint8_t readNumber(uint8_t base);
31
-uint8_t *readAFrame(void);
31
+void writeNumber(uint8_t num, uint8_t base);
32
+uint8_t *readAFrame(void);
33
+void simpleAnimationInput(void);

+ 20
- 1
CubeFirmware/main.c View File

327
 
327
 
328
 void serialHandler(char c) {
328
 void serialHandler(char c) {
329
 	// Used letters:
329
 	// Used letters:
330
-	// a, b, c, d, e, f, g, h, i, m, 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, p, q, r, s, t, u, v, x, y, 0, 1, 2, 3, #
331
 	uint8_t i, y, z;
331
 	uint8_t i, y, z;
332
 	uint8_t *tmp;
332
 	uint8_t *tmp;
333
 
333
 
344
 		serialWriteString(getString(10));
344
 		serialWriteString(getString(10));
345
 		serialWriteString(getString(26));
345
 		serialWriteString(getString(26));
346
 		serialWriteString(getString(34));
346
 		serialWriteString(getString(34));
347
+		serialWriteString(getString(17));
347
 
348
 
348
 		serialWriteString(getString(11));
349
 		serialWriteString(getString(11));
349
 		serialWriteString(getString(12));
350
 		serialWriteString(getString(12));
421
 		free(tmp);
422
 		free(tmp);
422
 		break;
423
 		break;
423
 
424
 
425
+	case 'o': case 'O':
426
+		serialWriteString(getString(36)); // Start:
427
+		i = readNumber(10);
428
+		serialWriteString(getString(39)); // Ende:
429
+		y = readNumber(10);
430
+		serialWriteString(getString(35)); // Duration:
431
+		z = readNumber(10);
432
+		for (c = i; c <= y; c++) {
433
+			setDuration(c, z);
434
+		}
435
+		serialWriteString(getString(33)); // Done
436
+		break;
437
+
424
 	case 'x': case 'X':
438
 	case 'x': case 'X':
425
 		// Get byte, store as animation count
439
 		// Get byte, store as animation count
426
 		serialWriteString(getString(16)); // "New animation count: "
440
 		serialWriteString(getString(16)); // "New animation count: "
427
 		setAnimationCount(readNumber(10));
441
 		setAnimationCount(readNumber(10));
442
+		refreshAnimationCount = 1;
443
+		break;
444
+
445
+	case 'p': case 'P':
446
+		simpleAnimationInput();
428
 		break;
447
 		break;
429
 
448
 
430
 	case 'y': case 'Y':
449
 	case 'y': case 'Y':

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


+ 4
- 4
CubeFirmware/mem.c View File

36
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
36
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
37
 		memAddress |= 2;
37
 		memAddress |= 2;
38
 	}
38
 	}
39
-	addA = address & 0xFF00;
39
+	addA = (address & 0xFF00) >> 8;
40
 	addB = address & 0xFF;
40
 	addB = address & 0xFF;
41
 
41
 
42
 	if (i2c_start(memAddress | I2C_WRITE) == 0) { // Send start, write address to read
42
 	if (i2c_start(memAddress | I2C_WRITE) == 0) { // Send start, write address to read
59
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
59
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
60
 		memAddress |= 2;
60
 		memAddress |= 2;
61
 	}
61
 	}
62
-	addA = address & 0xFF00;
62
+	addA = (address & 0xFF00) >> 8;
63
 	addB = address & 0xFF;
63
 	addB = address & 0xFF;
64
 	ret = (uint8_t *)malloc(length); // Allocate memory for values read
64
 	ret = (uint8_t *)malloc(length); // Allocate memory for values read
65
 	if (ret == NULL) {
65
 	if (ret == NULL) {
88
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
88
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
89
 		memAddress |= 2;
89
 		memAddress |= 2;
90
 	}
90
 	}
91
-	addA = address & 0xFF00;
91
+	addA = (address & 0xFF00) >> 8;
92
 	addB = address & 0xFF;
92
 	addB = address & 0xFF;
93
 	if (i2c_start(memAddress | I2C_WRITE) == 0) {
93
 	if (i2c_start(memAddress | I2C_WRITE) == 0) {
94
 		i2c_write(addA);
94
 		i2c_write(addA);
104
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
104
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
105
 		memAddress |= 2;
105
 		memAddress |= 2;
106
 	}
106
 	}
107
-	addA = address & 0xFF00;
107
+	addA = (address & 0xFF00) >> 8;
108
 	addB = address & 0xFF;
108
 	addB = address & 0xFF;
109
 	if (i2c_start(memAddress | I2C_WRITE) == 0) {
109
 	if (i2c_start(memAddress | I2C_WRITE) == 0) {
110
 		i2c_write(addA);
110
 		i2c_write(addA);

+ 6
- 0
CubeFirmware/memLayer.c View File

33
 // We place 2016 Frames in mem => 131040
33
 // We place 2016 Frames in mem => 131040
34
 // That gives us 32 bytes at the beginning, 0 -> 31
34
 // That gives us 32 bytes at the beginning, 0 -> 31
35
 // The first frame starts at 32
35
 // The first frame starts at 32
36
+// Framecount in 0 and 1
37
+// General Purpose bytes 0 to 29, starting at 2
36
 
38
 
37
 // Free after usage!
39
 // Free after usage!
38
 uint8_t *getFrame(uint16_t frameNumber) {
40
 uint8_t *getFrame(uint16_t frameNumber) {
44
 	memWriteBytes(32 + (65 * frameNumber), frameData, 65);
46
 	memWriteBytes(32 + (65 * frameNumber), frameData, 65);
45
 }
47
 }
46
 
48
 
49
+void setDuration(uint16_t frameNumber, uint8_t duration) {
50
+	memWriteByte(32 + 64 + (65 * frameNumber), duration);
51
+}
52
+
47
 void clearMem() {
53
 void clearMem() {
48
 	uint32_t i;
54
 	uint32_t i;
49
 	for (i = 0; i < MemLength; i++) {
55
 	for (i = 0; i < MemLength; i++) {

+ 6
- 6
CubeFirmware/strings.c View File

32
 const char stringMemWriteError[] PROGMEM = " => Can't write to Memory!\n"; // 5
32
 const char stringMemWriteError[] PROGMEM = " => Can't write to Memory!\n"; // 5
33
 const char stringHelp1[] PROGMEM = "(d)elete, (g)et anims, (s)et anims, (v)ersion\n"; // 6
33
 const char stringHelp1[] PROGMEM = "(d)elete, (g)et anims, (s)et anims, (v)ersion\n"; // 6
34
 const char stringHelp2[] PROGMEM = "(t)ime, (a)udio, (c)ount, (x)Custom count\n"; // 7
34
 const char stringHelp2[] PROGMEM = "(t)ime, (a)udio, (c)ount, (x)Custom count\n"; // 7
35
-const char stringHelp3[] PROGMEM = "(y)Set a frame\n"; // 8
35
+const char stringHelp3[] PROGMEM = "(y)Set a frame, sim(p)le anim\n"; // 8
36
 const char stringHelp4[] PROGMEM = "t(e)st, (m)ode, d(u)mp\n"; // 9
36
 const char stringHelp4[] PROGMEM = "t(e)st, (m)ode, d(u)mp\n"; // 9
37
 const char stringHelp5[] PROGMEM = "Play S(n)ake\n"; // 10
37
 const char stringHelp5[] PROGMEM = "Play S(n)ake\n"; // 10
38
 const char stringHelp6[] PROGMEM = "All LEDs Off/On (0/1)\n"; // 11
38
 const char stringHelp6[] PROGMEM = "All LEDs Off/On (0/1)\n"; // 11
41
 const char stringTime[] PROGMEM = "System Time: "; // 14
41
 const char stringTime[] PROGMEM = "System Time: "; // 14
42
 const char stringFrames[] PROGMEM = " Frames stored\n"; // 15
42
 const char stringFrames[] PROGMEM = " Frames stored\n"; // 15
43
 const char stringByte[] PROGMEM = "New animation count: "; // 16
43
 const char stringByte[] PROGMEM = "New animation count: "; // 16
44
-const char stringWritten[] PROGMEM = ""; // 17
44
+const char stringWritten[] PROGMEM = "durati(o)n"; // 17
45
 const char stringCount[] PROGMEM = "Frame to change: "; // 18
45
 const char stringCount[] PROGMEM = "Frame to change: "; // 18
46
 const char stringSelfTest[] PROGMEM = "Self-Test: 0b"; // 19
46
 const char stringSelfTest[] PROGMEM = "Self-Test: 0b"; // 19
47
 const char stringKillCount[] PROGMEM = "Killed Animation Counter!\n"; // 20
47
 const char stringKillCount[] PROGMEM = "Killed Animation Counter!\n"; // 20
60
 const char stringNothing[] PROGMEM = "Done!\n"; // 33
60
 const char stringNothing[] PROGMEM = "Done!\n"; // 33
61
 const char stringExtern[] PROGMEM = "(f)ormat memory\n"; // 34
61
 const char stringExtern[] PROGMEM = "(f)ormat memory\n"; // 34
62
 const char stringJtag[] PROGMEM = "Duration: "; // 35
62
 const char stringJtag[] PROGMEM = "Duration: "; // 35
63
-const char stringPowerOn[] PROGMEM = ""; // 36
64
-const char stringMinute[] PROGMEM = ""; // 37
65
-const char stringAudioMode[] PROGMEM = ""; // 38
66
-const char stringCubeMode[] PROGMEM = ""; // 39
63
+const char stringPowerOn[] PROGMEM = "Start: "; // 36
64
+const char stringMinute[] PROGMEM = "8 Layerbytes...\n"; // 37
65
+const char stringAudioMode[] PROGMEM = "Storing in 8 frames...\n"; // 38
66
+const char stringCubeMode[] PROGMEM = "Ende: "; // 39
67
 const char stringModeChange[] PROGMEM = "Cube mode entered!\n"; // 40
67
 const char stringModeChange[] PROGMEM = "Cube mode entered!\n"; // 40
68
 const char stringModeChange2[] PROGMEM = "Audio mode entered!\n"; // 41
68
 const char stringModeChange2[] PROGMEM = "Audio mode entered!\n"; // 41
69
 
69
 

+ 37
- 2
CubeFirmware/transmit.c View File

237
 	return val;
237
 	return val;
238
 }
238
 }
239
 
239
 
240
+void writeNumber(uint8_t num, uint8_t base) {
241
+	itoa(num, buffer, base);
242
+	serialWriteString(buffer);
243
+}
244
+
240
 uint8_t *readAFrame(void) {
245
 uint8_t *readAFrame(void) {
241
 	uint8_t *frame = (uint8_t *)malloc(65);
246
 	uint8_t *frame = (uint8_t *)malloc(65);
242
 	uint8_t byte;
247
 	uint8_t byte;
244
 	serialWriteString(getString(35)); // "Duration: "
249
 	serialWriteString(getString(35)); // "Duration: "
245
 	frame[64] = readNumber(10);
250
 	frame[64] = readNumber(10);
246
 	for (byte = 0; byte < 64; byte++) {
251
 	for (byte = 0; byte < 64; byte++) {
247
-		itoa(byte, buffer, 10);
248
-		serialWriteString(buffer);
252
+		writeNumber(byte, 10);
249
 		serialWriteString(": "); // "xx: "
253
 		serialWriteString(": "); // "xx: "
250
 		frame[byte] = readNumber(16);
254
 		frame[byte] = readNumber(16);
251
 	}
255
 	}
252
 	serialWriteString(getString(33));
256
 	serialWriteString(getString(33));
253
 	return frame;
257
 	return frame;
254
 }
258
 }
259
+
260
+void simpleAnimationInput(void) {
261
+	uint8_t start, j, d;
262
+	int8_t i;
263
+	uint8_t data[8] = {0, 0, 0, 0, 0, 0, 0, 0};
264
+	uint8_t *frame = (uint8_t *)malloc(65);
265
+	frame[64] = 2;
266
+
267
+	serialWriteString(getString(36));
268
+	start = readNumber(10);
269
+	serialWriteString(getString(37));
270
+	for (i = 0; i < 8; i++) {
271
+		writeNumber(i, 10);
272
+		serialWriteString(": ");
273
+		data[i] = readNumber(16);
274
+	}
275
+	serialWriteString(getString(38));
276
+	for (i = 0; i < 8; i++) {
277
+		d = 0;
278
+		for (j = 0; j < 64; j++) {
279
+			if ((j < (8 * (i + 1))) && (j >= (8 * i))) {
280
+				frame[j] = data[d++];
281
+			} else {
282
+				frame[j] = 0;
283
+			}
284
+		}
285
+		setFrame(i + start, frame);
286
+	}
287
+	serialWriteString(getString(33)); // Done
288
+	free(frame);
289
+}

Loading…
Cancel
Save