Przeglądaj źródła

Implemented Audio Mode again.

Beware: freeing static, unallocated memory will cause very strange
behavior!
Thomas Buck 12 lat temu
rodzic
commit
690c102d75
4 zmienionych plików z 1235 dodań i 1219 usunięć
  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 Wyświetl plik

@@ -113,7 +113,7 @@ void setImage(uint8_t *img) {
113 113
 		toggleFlag = 0;
114 114
 		for (i = 0; i < 8; i++) {
115 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 Wyświetl plik

@@ -59,11 +59,11 @@ void serialHandler(char c);
59 59
 uint8_t defaultImageCube[64] = {	0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81,
60 60
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 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 64
 									0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63 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 68
 #define NOERROR 0
69 69
 // Audio does not answer
@@ -99,8 +99,9 @@ int main(void) {
99 99
 	uint8_t i;
100 100
 	uint8_t imageIndex = 0, imageCount = 0;
101 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 105
 	uint8_t *imageData = NULL, *audioData = NULL;
105 106
 	uint8_t duration = 0;
106 107
 
@@ -141,7 +142,7 @@ int main(void) {
141 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 146
 			audioModeSelected();
146 147
 			lastButtonCheck = getSystemTime();
147 148
 		}
@@ -174,18 +175,31 @@ int main(void) {
174 175
 			}
175 176
 		} else {
176 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 194
 		// Print fps after one second
181
-		if ((getSystemTime() >= 1000) && (fpsWasSent == 0)) {
195
+		/* if ((getSystemTime() >= 1000) && (fpsWasSent == 0)) {
182 196
 			temp = getTriggerCount();
183 197
 			serialWriteString(ltoa(temp, buffer, 10));
184 198
 			serialWriteString(getString(27));
185 199
 			serialWriteString(ltoa((temp / 8), buffer, 10));
186 200
 			serialWriteString(getString(28));
187 201
 			fpsWasSent = 1;
188
-		}
202
+		} */
189 203
 
190 204
 	}
191 205
 
@@ -230,7 +244,6 @@ uint8_t selfTest(void) {
230 244
 	if (data == NULL) {
231 245
 		result |= AUDIOERROR;
232 246
 	} else {
233
-		free(data);
234 247
 	}
235 248
 
236 249
 	data = memGetBytes(0, 1);
@@ -334,7 +347,11 @@ void serialHandler(char c) {
334 347
 		break;
335 348
 
336 349
 	case 'm': case 'M':
337
-		lastButtonState = !lastButtonState;
350
+		if (lastButtonState < (maxButtonState - 1)) {
351
+			lastButtonState++;
352
+		} else {
353
+			lastButtonState = 0;
354
+		}
338 355
 		if (lastButtonState) {
339 356
 			serialWriteString(getString(41));
340 357
 		} else {

+ 1205
- 1206
CubeFirmware/main.hex
Plik diff jest za duży
Wyświetl plik


+ 1
- 1
CubeFirmware/visualizer.c Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz