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
 		serialWriteString(getString(5));
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
 #endif
284
 #endif
257
 
285
 
258
 void serialHandler(char c) {
286
 void serialHandler(char c) {
259
 	// Used letters:
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
 	uint8_t i, y, z;
289
 	uint8_t i, y, z;
262
 #ifdef DEBUG
290
 #ifdef DEBUG
263
 	serialWrite(c);
291
 	serialWrite(c);
308
 		break;
336
 		break;
309
 
337
 
310
 #ifdef DEBUG
338
 #ifdef DEBUG
339
+	case 'r': case 'R':
340
+		randomAnimation();
341
+		break;
342
+
311
 	case 't': case 'T':
343
 	case 't': case 'T':
312
 		printTime();
344
 		printTime();
313
 		break;
345
 		break;
350
 
382
 
351
 	case '0':
383
 	case '0':
352
 		fillBuffer(0);
384
 		fillBuffer(0);
353
-		setAnimationCount(0);
354
-		refreshAnimationCount = 1;
355
-		serialWriteString(getString(20));
356
 		DebugDone |= 4;
385
 		DebugDone |= 4;
357
 		break;
386
 		break;
358
 
387
 
359
 	case '1':
388
 	case '1':
360
 		fillBuffer(0xFF);
389
 		fillBuffer(0xFF);
361
-		setAnimationCount(0);
362
-		refreshAnimationCount = 1;
363
-		serialWriteString(getString(20));
364
 		DebugDone |= 4;
390
 		DebugDone |= 4;
365
 		break;
391
 		break;
366
 
392
 

+ 2
- 2
CubeFirmware/makefile View File

288
 
288
 
289
 
289
 
290
 # Display size of file.
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
 sizebefore:
293
 sizebefore:
294
 	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
294
 	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
295
 
295
 

+ 3
- 3
CubeFirmware/strings.c View File

27
 #ifdef DEBUG
27
 #ifdef DEBUG
28
 char stringVersion[] PROGMEM = "v2 (Debug Build)\nNOT COMPATIBLE WITH CubeControl!\n"; // 0
28
 char stringVersion[] PROGMEM = "v2 (Debug Build)\nNOT COMPATIBLE WITH CubeControl!\n"; // 0
29
 #else
29
 #else
30
-char stringVersion[] PROGMEM = "v2 Release\n" // 0
30
+char stringVersion[] PROGMEM = "v2 Release\n"; // 0
31
 #endif
31
 #endif
32
 
32
 
33
 char stringInit[] PROGMEM = "\n\nInitialized: "; // 1
33
 char stringInit[] PROGMEM = "\n\nInitialized: "; // 1
53
 char stringAccessError[] PROGMEM = "Could not access device!\n"; // 21
53
 char stringAccessError[] PROGMEM = "Could not access device!\n"; // 21
54
 char stringAudioData[] PROGMEM = "Audio Data:\n"; // 22
54
 char stringAudioData[] PROGMEM = "Audio Data:\n"; // 22
55
 char stringSnakeControl[] PROGMEM = "Controls: W A S D Q E, x to quit\n"; // 23
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
 char stringKilledAnimation[] PROGMEM = "Animation aborted!\n"; // 25
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
 char stringInterrupts[] PROGMEM = " Interrupts after 1000msec\n"; // 27
59
 char stringInterrupts[] PROGMEM = " Interrupts after 1000msec\n"; // 27
60
 char stringFrames2[] PROGMEM = " Frames per Second\n"; // 28
60
 char stringFrames2[] PROGMEM = " Frames per Second\n"; // 28
61
 char stringDeleted[] PROGMEM = "Memory deleted!\n"; // 29
61
 char stringDeleted[] PROGMEM = "Memory deleted!\n"; // 29

BIN
Hardware/Layout.png View File


Loading…
Cancel
Save