Browse Source

Misc work.

Changed some more faulty transistors. cubeInit now displays short test
animation. Moved header files in own folder.
Thomas Buck 12 years ago
parent
commit
fe9794e99e

+ 29
- 0
CubeFirmware/cube.c View File

83
 	ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
83
 	ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
84
 		changedFlag = 1;
84
 		changedFlag = 1;
85
 		imgFlag = 0;
85
 		imgFlag = 0;
86
+		toggleFlag = 0;
86
 		for (i = 0; i < 8; i++) {
87
 		for (i = 0; i < 8; i++) {
87
 			for (j = 0; j < 8; j++) {
88
 			for (j = 0; j < 8; j++) {
88
 				imgBuffer[j][i] = ~(img[j + (i * 8)]);
89
 				imgBuffer[j][i] = ~(img[j + (i * 8)]);
96
 	ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
97
 	ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
97
 		changedFlag = 1;
98
 		changedFlag = 1;
98
 		imgFlag = 0;
99
 		imgFlag = 0;
100
+		toggleFlag = 0;
99
 		for (i = 0; i < 8; i++) {
101
 		for (i = 0; i < 8; i++) {
100
 			for (j = 0; j < 8; j++) {
102
 			for (j = 0; j < 8; j++) {
101
 				imgBuffer[i][j] = ~(val);
103
 				imgBuffer[i][j] = ~(val);
109
 }
111
 }
110
 
112
 
111
 void initCube(void) {
113
 void initCube(void) {
114
+	uint8_t x, y;
115
+
112
 	TCCR1B |= (1 << CS10) | (1 << WGM12); // Prescaler: 1, CTC Mode
116
 	TCCR1B |= (1 << CS10) | (1 << WGM12); // Prescaler: 1, CTC Mode
113
 	OCR1A = COUNT;
117
 	OCR1A = COUNT;
114
 	TIMSK = (1 << OCIE1A); // Enable Output Compare Interrupt
118
 	TIMSK = (1 << OCIE1A); // Enable Output Compare Interrupt
119
+
120
+	fillBuffer(0); // Clear memory
121
+	sei(); // Enable interrupts
122
+
123
+	// Show test animation
124
+	for (x = 0; x < 8; x++) {
125
+		for (y = 0; y < 8; y++) {
126
+			ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
127
+				imgBuffer[x][y] &= ~(0xFF); // Set a pixel
128
+				changedFlag = 1;
129
+				imgFlag = 0;
130
+				toggleFlag = COUNT2; // Ensure next interrupts starts displaying
131
+			}
132
+			while(imgFlag < 1); // Wait for frame to display
133
+			/* ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
134
+				imgBuffer[x][y] |= (0xFF); // Clear pixel
135
+			} */
136
+		}
137
+	}
138
+
139
+	cli(); // Disable interrupts
140
+
141
+	timesTriggered = 0;
142
+	imgFlag = 0;
143
+	toggleFlag = 0;
115
 }
144
 }
116
 
145
 
117
 void close(void) {
146
 void close(void) {

CubeFirmware/audio.h → CubeFirmware/header/audio.h View File


CubeFirmware/cube.h → CubeFirmware/header/cube.h View File


CubeFirmware/mem.h → CubeFirmware/header/mem.h View File


CubeFirmware/memLayer.h → CubeFirmware/header/memLayer.h View File


CubeFirmware/serial.h → CubeFirmware/header/serial.h View File


CubeFirmware/strings.h → CubeFirmware/header/strings.h View File


CubeFirmware/time.h → CubeFirmware/header/time.h View File


CubeFirmware/twi.h → CubeFirmware/header/twi.h View File


+ 24
- 8
CubeFirmware/main.c View File

56
 #define ISERROR(x, e) ((x) & (e))
56
 #define ISERROR(x, e) ((x) & (e))
57
 
57
 
58
 // Length of an idle animation frame, 24 -> 1 second
58
 // Length of an idle animation frame, 24 -> 1 second
59
-#define IDLELENGTH 24
59
+#define IDLELENGTH 48
60
 
60
 
61
 void serialHandler(char c);
61
 void serialHandler(char c);
62
 void sendAudioData(void);
62
 void sendAudioData(void);
107
 								0x1e, 0x22, 0x22, 0x22, 0x1e, 0x02, 0x02, 0x02,
107
 								0x1e, 0x22, 0x22, 0x22, 0x1e, 0x02, 0x02, 0x02,
108
 								0x1e, 0x22, 0x22, 0x22, 0x1e, 0x02, 0x02, 0x02 };
108
 								0x1e, 0x22, 0x22, 0x22, 0x1e, 0x02, 0x02, 0x02 };
109
 
109
 
110
+uint8_t defaultImageCube[64] = {	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
111
+									0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF,
112
+									0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF,
113
+									0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF,
114
+									0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF,
115
+									0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF,
116
+									0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF,
117
+									0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
118
+
110
 #define IDLEANIMATIONCOUNT 3
119
 #define IDLEANIMATIONCOUNT 3
111
 uint8_t *idleAnimation[IDLEANIMATIONCOUNT] = { defaultImageA, defaultImageB, defaultImageC };
120
 uint8_t *idleAnimation[IDLEANIMATIONCOUNT] = { defaultImageA, defaultImageB, defaultImageC };
112
 
121
 
128
 	MCUCSR = 0;
137
 	MCUCSR = 0;
129
 	wdt_disable();
138
 	wdt_disable();
130
 
139
 
140
+	DDRA = 0xFF; // Latch Data Bus as Output
141
+	DDRD = 0xFC; DDRB = 24; // Mosfets as Output
142
+	DDRC = 0xFC; DDRB |= 6; // Latch Enable as Output
143
+	DDRB &= ~(1 << PB0); // Pushbutton as Input
144
+
131
 	initCube();
145
 	initCube();
132
 	serialInit(25, 8, NONE, 1);
146
 	serialInit(25, 8, NONE, 1);
133
 	i2c_init();
147
 	i2c_init();
134
 	initSystemTimer();
148
 	initSystemTimer();
135
 	sei(); // Enable Interrupts
149
 	sei(); // Enable Interrupts
136
 
150
 
151
+#ifndef DEBUG
137
 	// wdt_enable(WDTO_500MS); // Enable watchdog reset after 500ms
152
 	// wdt_enable(WDTO_500MS); // Enable watchdog reset after 500ms
138
 	wdt_enable(WDTO_1S); // Watchdog reset after 1 second
153
 	wdt_enable(WDTO_1S); // Watchdog reset after 1 second
154
+#endif
139
 
155
 
140
-	DDRA = 0xFF; // Latch Data Bus as Output
141
-	DDRD = 0xFC; DDRB = 24; // Mosfets as Output
142
-	DDRC = 0xFC; DDRB |= 6; // Latch Enable as Output
143
-	DDRB &= ~(1 << PB0); // Pushbutton as Input
144
-
145
-	setImage(defaultImageA); // Display something
156
+	setImage(defaultImageCube); // Display something
146
 
157
 
147
 #ifdef DEBUG
158
 #ifdef DEBUG
148
 	// Kill animation counter in debug mode
159
 	// Kill animation counter in debug mode
344
 
355
 
345
 void serialHandler(char c) {
356
 void serialHandler(char c) {
346
 	// Used letters:
357
 	// Used letters:
347
-	// a, c, d, e, g, i, n, q, r, s, t, v, x, y, 0, 1, 2
358
+	// a, c, d, e, g, i, n, q, r, s, t, v, x, y, 0, 1, 2, 3
348
 #ifdef DEBUG
359
 #ifdef DEBUG
349
 	uint8_t i, y, z;
360
 	uint8_t i, y, z;
350
 	serialWrite(c);
361
 	serialWrite(c);
459
 		DebugDone |= 4;
470
 		DebugDone |= 4;
460
 		break;
471
 		break;
461
 
472
 
473
+	case '3':
474
+		setImage(defaultImageCube);
475
+		DebugDone |= 4;
476
+		break;
477
+
462
 	case '2':
478
 	case '2':
463
 		DebugDone |= 4;
479
 		DebugDone |= 4;
464
 		fillBuffer(0);
480
 		fillBuffer(0);

+ 1
- 1
CubeFirmware/makefile View File

69
 
69
 
70
 # List any extra directories to look for include files here.
70
 # List any extra directories to look for include files here.
71
 #     Each directory must be seperated by a space.
71
 #     Each directory must be seperated by a space.
72
-EXTRAINCDIRS = 
72
+EXTRAINCDIRS = header
73
 
73
 
74
 
74
 
75
 # Compiler flag to set the C Standard level.
75
 # Compiler flag to set the C Standard level.

+ 3
- 3
CubeFirmware/strings.c View File

40
 char stringHelp3[] PROGMEM = "(y)Set fixed animation count\n"; // 8
40
 char stringHelp3[] PROGMEM = "(y)Set fixed animation count\n"; // 8
41
 char stringHelp4[] PROGMEM = "S(e)lf Test, (m)ode\n"; // 9
41
 char stringHelp4[] PROGMEM = "S(e)lf Test, (m)ode\n"; // 9
42
 char stringHelp5[] PROGMEM = "Play S(n)ake\n"; // 10
42
 char stringHelp5[] PROGMEM = "Play S(n)ake\n"; // 10
43
-char stringHelp6[] PROGMEM = "(0): All LEDs Off\n"; // 11
44
-char stringHelp7[] PROGMEM = "(1): All LEDs On\n"; // 12
45
-char stringHelp8[] PROGMEM = "(2): Test Anim. 1\n"; // 13
43
+char stringHelp6[] PROGMEM = "All LEDs Off/On (0/1)\n"; // 11
44
+char stringHelp7[] PROGMEM = "(2): Test Anim. 1\n"; // 12
45
+char stringHelp8[] PROGMEM = "(3): All Surface LEDs on\n"; // 13
46
 char stringTime[] PROGMEM = "System Time: "; // 14
46
 char stringTime[] PROGMEM = "System Time: "; // 14
47
 char stringFrames[] PROGMEM = " Frames stored\n"; // 15
47
 char stringFrames[] PROGMEM = " Frames stored\n"; // 15
48
 char stringByte[] PROGMEM = "Send a byte... "; // 16
48
 char stringByte[] PROGMEM = "Send a byte... "; // 16

Loading…
Cancel
Save