Browse Source

Storing frames no longer corrupts them!

Thomas Buck 11 years ago
parent
commit
521b36d7fe

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

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

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

@@ -28,4 +28,6 @@ void printTime(void);
28 28
 void dumpFrame(uint8_t *f);
29 29
 uint8_t *readLine(void);
30 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,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, 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 331
 	uint8_t i, y, z;
332 332
 	uint8_t *tmp;
333 333
 
@@ -344,6 +344,7 @@ void serialHandler(char c) {
344 344
 		serialWriteString(getString(10));
345 345
 		serialWriteString(getString(26));
346 346
 		serialWriteString(getString(34));
347
+		serialWriteString(getString(17));
347 348
 
348 349
 		serialWriteString(getString(11));
349 350
 		serialWriteString(getString(12));
@@ -421,10 +422,28 @@ void serialHandler(char c) {
421 422
 		free(tmp);
422 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 438
 	case 'x': case 'X':
425 439
 		// Get byte, store as animation count
426 440
 		serialWriteString(getString(16)); // "New animation count: "
427 441
 		setAnimationCount(readNumber(10));
442
+		refreshAnimationCount = 1;
443
+		break;
444
+
445
+	case 'p': case 'P':
446
+		simpleAnimationInput();
428 447
 		break;
429 448
 
430 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,7 +36,7 @@ uint8_t memGetByte(uint32_t address) {
36 36
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
37 37
 		memAddress |= 2;
38 38
 	}
39
-	addA = address & 0xFF00;
39
+	addA = (address & 0xFF00) >> 8;
40 40
 	addB = address & 0xFF;
41 41
 
42 42
 	if (i2c_start(memAddress | I2C_WRITE) == 0) { // Send start, write address to read
@@ -59,7 +59,7 @@ uint8_t *memGetBytes(uint32_t address, uint8_t length) {
59 59
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
60 60
 		memAddress |= 2;
61 61
 	}
62
-	addA = address & 0xFF00;
62
+	addA = (address & 0xFF00) >> 8;
63 63
 	addB = address & 0xFF;
64 64
 	ret = (uint8_t *)malloc(length); // Allocate memory for values read
65 65
 	if (ret == NULL) {
@@ -88,7 +88,7 @@ void memWriteByte(uint32_t address, uint8_t data) {
88 88
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
89 89
 		memAddress |= 2;
90 90
 	}
91
-	addA = address & 0xFF00;
91
+	addA = (address & 0xFF00) >> 8;
92 92
 	addB = address & 0xFF;
93 93
 	if (i2c_start(memAddress | I2C_WRITE) == 0) {
94 94
 		i2c_write(addA);
@@ -104,7 +104,7 @@ void memWriteBytes(uint32_t address, uint8_t *data, uint8_t length) {
104 104
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
105 105
 		memAddress |= 2;
106 106
 	}
107
-	addA = address & 0xFF00;
107
+	addA = (address & 0xFF00) >> 8;
108 108
 	addB = address & 0xFF;
109 109
 	if (i2c_start(memAddress | I2C_WRITE) == 0) {
110 110
 		i2c_write(addA);

+ 6
- 0
CubeFirmware/memLayer.c View File

@@ -33,6 +33,8 @@
33 33
 // We place 2016 Frames in mem => 131040
34 34
 // That gives us 32 bytes at the beginning, 0 -> 31
35 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 39
 // Free after usage!
38 40
 uint8_t *getFrame(uint16_t frameNumber) {
@@ -44,6 +46,10 @@ void setFrame(uint16_t frameNumber, uint8_t *frameData) {
44 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 53
 void clearMem() {
48 54
 	uint32_t i;
49 55
 	for (i = 0; i < MemLength; i++) {

+ 6
- 6
CubeFirmware/strings.c View File

@@ -32,7 +32,7 @@ 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 a frame\n"; // 8
35
+const char stringHelp3[] PROGMEM = "(y)Set a frame, sim(p)le anim\n"; // 8
36 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
@@ -41,7 +41,7 @@ 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 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 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
@@ -60,10 +60,10 @@ 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 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 67
 const char stringModeChange[] PROGMEM = "Cube mode entered!\n"; // 40
68 68
 const char stringModeChange2[] PROGMEM = "Audio mode entered!\n"; // 41
69 69
 

+ 37
- 2
CubeFirmware/transmit.c View File

@@ -237,6 +237,11 @@ uint8_t readNumber(uint8_t base) {
237 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 245
 uint8_t *readAFrame(void) {
241 246
 	uint8_t *frame = (uint8_t *)malloc(65);
242 247
 	uint8_t byte;
@@ -244,11 +249,41 @@ uint8_t *readAFrame(void) {
244 249
 	serialWriteString(getString(35)); // "Duration: "
245 250
 	frame[64] = readNumber(10);
246 251
 	for (byte = 0; byte < 64; byte++) {
247
-		itoa(byte, buffer, 10);
248
-		serialWriteString(buffer);
252
+		writeNumber(byte, 10);
249 253
 		serialWriteString(": "); // "xx: "
250 254
 		frame[byte] = readNumber(16);
251 255
 	}
252 256
 	serialWriteString(getString(33));
253 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