Browse Source

Added random animation.

Thomas Buck 12 years ago
parent
commit
4d3f3f45fb
4 changed files with 38 additions and 12 deletions
  1. 33
    7
      CubeFirmware/main.c
  2. 2
    2
      CubeFirmware/makefile
  3. 3
    3
      CubeFirmware/strings.c
  4. BIN
      Hardware/Layout.png

+ 33
- 7
CubeFirmware/main.c View File

@@ -253,11 +253,39 @@ void printErrors(uint8_t e) {
253 253
 		serialWriteString(getString(5));
254 254
 	}
255 255
 }
256
+
257
+void randomAnimation(void) {
258
+	uint8_t *b = (uint8_t *)malloc(64);
259
+	uint8_t x, y, z;
260
+	if (b == NULL) {
261
+		serialWriteString(getString(24));
262
+		return;
263
+	}
264
+	for (x = 0; x < 64; x++) {
265
+		b[x] = 0;
266
+	}
267
+	while(1) {
268
+		setImage(b);
269
+		while(isFinished() == 0);
270
+		x = rand() / 4096;
271
+		y = rand() / 4096;
272
+		z = rand() / 4096;
273
+		b[x + (8 * y)] ^= (1 << z);
274
+
275
+		if (serialHasChar()) {
276
+			serialWriteString(getString(25));
277
+			free(b);
278
+			serialHandler(serialGet());
279
+			return;
280
+		}
281
+	}
282
+	free(b);
283
+}
256 284
 #endif
257 285
 
258 286
 void serialHandler(char c) {
259 287
 	// Used letters:
260
-	// a, c, d, e, g, n, s, t, v, x, 0, 1, 2
288
+	// a, c, d, e, g, i, n, r, s, t, v, x, y, 0, 1, 2
261 289
 	uint8_t i, y, z;
262 290
 #ifdef DEBUG
263 291
 	serialWrite(c);
@@ -308,6 +336,10 @@ void serialHandler(char c) {
308 336
 		break;
309 337
 
310 338
 #ifdef DEBUG
339
+	case 'r': case 'R':
340
+		randomAnimation();
341
+		break;
342
+
311 343
 	case 't': case 'T':
312 344
 		printTime();
313 345
 		break;
@@ -350,17 +382,11 @@ void serialHandler(char c) {
350 382
 
351 383
 	case '0':
352 384
 		fillBuffer(0);
353
-		setAnimationCount(0);
354
-		refreshAnimationCount = 1;
355
-		serialWriteString(getString(20));
356 385
 		DebugDone |= 4;
357 386
 		break;
358 387
 
359 388
 	case '1':
360 389
 		fillBuffer(0xFF);
361
-		setAnimationCount(0);
362
-		refreshAnimationCount = 1;
363
-		serialWriteString(getString(20));
364 390
 		DebugDone |= 4;
365 391
 		break;
366 392
 

+ 2
- 2
CubeFirmware/makefile View File

@@ -288,8 +288,8 @@ end:
288 288
 
289 289
 
290 290
 # Display size of file.
291
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
292
-ELFSIZE = $(SIZE) -A $(TARGET).elf
291
+HEXSIZE = $(SIZE)  --mcu=$(MCU) --target=$(FORMAT) $(TARGET).hex
292
+ELFSIZE = $(SIZE)  --mcu=$(MCU) -C $(TARGET).elf
293 293
 sizebefore:
294 294
 	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
295 295
 

+ 3
- 3
CubeFirmware/strings.c View File

@@ -27,7 +27,7 @@ char buffer[60];
27 27
 #ifdef DEBUG
28 28
 char stringVersion[] PROGMEM = "v2 (Debug Build)\nNOT COMPATIBLE WITH CubeControl!\n"; // 0
29 29
 #else
30
-char stringVersion[] PROGMEM = "v2 Release\n" // 0
30
+char stringVersion[] PROGMEM = "v2 Release\n"; // 0
31 31
 #endif
32 32
 
33 33
 char stringInit[] PROGMEM = "\n\nInitialized: "; // 1
@@ -53,9 +53,9 @@ char stringKillCount[] PROGMEM = "Killed Animation Counter!\n"; // 20
53 53
 char stringAccessError[] PROGMEM = "Could not access device!\n"; // 21
54 54
 char stringAudioData[] PROGMEM = "Audio Data:\n"; // 22
55 55
 char stringSnakeControl[] PROGMEM = "Controls: W A S D Q E, x to quit\n"; // 23
56
-char stringNoMoreHeap[] PROGMEM = "Ran out of Heap... Bye\n"; // 24
56
+char stringNoMoreHeap[] PROGMEM = "Ran out of Heap!\n"; // 24
57 57
 char stringKilledAnimation[] PROGMEM = "Animation aborted!\n"; // 25
58
-char stringHelp9[] PROGMEM = "(i)nterrupt count\n"; // 26
58
+char stringHelp9[] PROGMEM = "(i)nterrupt count, (r)andom\n"; // 26
59 59
 char stringInterrupts[] PROGMEM = " Interrupts after 1000msec\n"; // 27
60 60
 char stringFrames2[] PROGMEM = " Frames per Second\n"; // 28
61 61
 char stringDeleted[] PROGMEM = "Memory deleted!\n"; // 29

BIN
Hardware/Layout.png View File


Loading…
Cancel
Save