Browse Source

Implemented Audio Mode again.

Beware: freeing static, unallocated memory will cause very strange
behavior!
Thomas Buck 12 years ago
parent
commit
690c102d75
4 changed files with 1235 additions and 1219 deletions
  1. 1
    1
      CubeFirmware/cube.c
  2. 28
    11
      CubeFirmware/main.c
  3. 1205
    1206
      CubeFirmware/main.hex
  4. 1
    1
      CubeFirmware/visualizer.c

+ 1
- 1
CubeFirmware/cube.c View File

113
 		toggleFlag = 0;
113
 		toggleFlag = 0;
114
 		for (i = 0; i < 8; i++) {
114
 		for (i = 0; i < 8; i++) {
115
 			for (j = 0; j < 8; j++) {
115
 			for (j = 0; j < 8; j++) {
116
-				imgBuffer[j][i] = ~(bitSwitch(img[j + (i * 8)]));
116
+				imgBuffer[j][7 - i] = ~(bitSwitch(img[j + (i * 8)]));
117
 			}
117
 			}
118
 		}
118
 		}
119
 	}
119
 	}

+ 28
- 11
CubeFirmware/main.c View File

59
 uint8_t defaultImageCube[64] = {	0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81,
59
 uint8_t defaultImageCube[64] = {	0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81,
60
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62
+									0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81,
63
+									0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81,
62
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64
-									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65
-									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66
-									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
66
+									0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 };
67
 
67
 
68
 #define NOERROR 0
68
 #define NOERROR 0
69
 // Audio does not answer
69
 // Audio does not answer
99
 	uint8_t i;
99
 	uint8_t i;
100
 	uint8_t imageIndex = 0, imageCount = 0;
100
 	uint8_t imageIndex = 0, imageCount = 0;
101
 	uint8_t idleIndex = 0, idleCount = 0;
101
 	uint8_t idleIndex = 0, idleCount = 0;
102
-	uint8_t lastButtonCheck, fpsWasSent = 0;
103
-	uint32_t temp;
102
+	uint8_t lastButtonCheck;
103
+	// uint8_t fpsWasSent = 0;
104
+	// uint32_t temp;
104
 	uint8_t *imageData = NULL, *audioData = NULL;
105
 	uint8_t *imageData = NULL, *audioData = NULL;
105
 	uint8_t duration = 0;
106
 	uint8_t duration = 0;
106
 
107
 
141
 			serialHandler((char)(serialGet()));
142
 			serialHandler((char)(serialGet()));
142
 		}
143
 		}
143
 
144
 
144
-		if ((getSystemTime() - lastButtonCheck) > 150) { // Check button state every 150ms
145
+		if ((getSystemTime() - lastButtonCheck) >= 150) { // Check button state every 150ms
145
 			audioModeSelected();
146
 			audioModeSelected();
146
 			lastButtonCheck = getSystemTime();
147
 			lastButtonCheck = getSystemTime();
147
 		}
148
 		}
174
 			}
175
 			}
175
 		} else {
176
 		} else {
176
 			// An audiomode is selected
177
 			// An audiomode is selected
177
-
178
+			if (disableAudioData == 0) {
179
+				if (isFinished()) {
180
+					audioData = getAudioData();
181
+					if (audioData != NULL) {
182
+						runVisualization(audioData, (lastButtonState - 1));
183
+					} else {
184
+						lastButtonState = 0;
185
+						duration = 24;
186
+						setImage(defaultImageCube); // Quasi Error Screen
187
+					}
188
+				}
189
+			} else {
190
+				lastButtonState = 0;
191
+			}
178
 		}
192
 		}
179
 
193
 
180
 		// Print fps after one second
194
 		// Print fps after one second
181
-		if ((getSystemTime() >= 1000) && (fpsWasSent == 0)) {
195
+		/* if ((getSystemTime() >= 1000) && (fpsWasSent == 0)) {
182
 			temp = getTriggerCount();
196
 			temp = getTriggerCount();
183
 			serialWriteString(ltoa(temp, buffer, 10));
197
 			serialWriteString(ltoa(temp, buffer, 10));
184
 			serialWriteString(getString(27));
198
 			serialWriteString(getString(27));
185
 			serialWriteString(ltoa((temp / 8), buffer, 10));
199
 			serialWriteString(ltoa((temp / 8), buffer, 10));
186
 			serialWriteString(getString(28));
200
 			serialWriteString(getString(28));
187
 			fpsWasSent = 1;
201
 			fpsWasSent = 1;
188
-		}
202
+		} */
189
 
203
 
190
 	}
204
 	}
191
 
205
 
230
 	if (data == NULL) {
244
 	if (data == NULL) {
231
 		result |= AUDIOERROR;
245
 		result |= AUDIOERROR;
232
 	} else {
246
 	} else {
233
-		free(data);
234
 	}
247
 	}
235
 
248
 
236
 	data = memGetBytes(0, 1);
249
 	data = memGetBytes(0, 1);
334
 		break;
347
 		break;
335
 
348
 
336
 	case 'm': case 'M':
349
 	case 'm': case 'M':
337
-		lastButtonState = !lastButtonState;
350
+		if (lastButtonState < (maxButtonState - 1)) {
351
+			lastButtonState++;
352
+		} else {
353
+			lastButtonState = 0;
354
+		}
338
 		if (lastButtonState) {
355
 		if (lastButtonState) {
339
 			serialWriteString(getString(41));
356
 			serialWriteString(getString(41));
340
 		} else {
357
 		} else {

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


+ 1
- 1
CubeFirmware/visualizer.c View File

56
 		max = data[i] / FACTOR;
56
 		max = data[i] / FACTOR;
57
 		for (h = 0; h < max; h++) {
57
 		for (h = 0; h < max; h++) {
58
 			if (i == 0) {
58
 			if (i == 0) {
59
-				buffSetPixel(buff, i, h / 2, z);
59
+				buffSetPixel(buff, i, (h * 10 / 15), z);
60
 			}
60
 			}
61
 			buffSetPixel(buff, i + 1, h, z);
61
 			buffSetPixel(buff, i + 1, h, z);
62
 		}
62
 		}

Loading…
Cancel
Save