Kaynağa Gözat

misc changes

Thomas Buck 12 yıl önce
ebeveyn
işleme
6d7dd21fe4
3 değiştirilmiş dosya ile 19 ekleme ve 6 silme
  1. 15
    3
      CubeFirmware/cube.c
  2. 1
    1
      CubeFirmware/main.c
  3. 3
    2
      CubeFirmware/strings.c

+ 15
- 3
CubeFirmware/cube.c Dosyayı Görüntüle

@@ -28,6 +28,7 @@
28 28
 
29 29
 #ifdef DEBUG
30 30
 #include "serial.h"
31
+#include "strings.h"
31 32
 #endif
32 33
 #include "cube.h"
33 34
 
@@ -63,6 +64,7 @@ volatile uint8_t layer = 0;
63 64
 inline void isrCall(void);
64 65
 
65 66
 volatile uint32_t timesTriggered = 0;
67
+volatile uint8_t warningDisplayed = 0;
66 68
 
67 69
 uint32_t getTriggerCount(void) {
68 70
 	return timesTriggered;
@@ -99,8 +101,7 @@ uint8_t isFinished(void) {
99 101
 }
100 102
 
101 103
 void initCube(void) {
102
-	TCCR1A |= (1 << WGM12); // CTC Mode
103
-	TCCR1B |= (1 << CS10); // Prescaler: 1
104
+	TCCR1B |= (1 << CS10) | (1 << WGM12); // Prescaler: 1, CTC Mode
104 105
 	OCR1A = COUNT;
105 106
 	TIMSK = (1 << OCIE1A); // Enable Output Compare Interrupt
106 107
 }
@@ -112,6 +113,17 @@ void close(void) {
112 113
 ISR(TIMER1_COMPA_vect) {
113 114
 	isrCall();
114 115
 	timesTriggered++;
116
+#ifdef DEBUG
117
+	if (TIFR & TOV1) {
118
+		if (warningDisplayed) {
119
+			serialWrite('!');
120
+		} else {
121
+			serialWriteString(getString(27));
122
+			warningDisplayed++;
123
+		}
124
+		TIFR |= (1 << TOV1); // Clear flag
125
+	}
126
+#endif
115 127
 }
116 128
 
117 129
 // Data is sent to 8 Fet bits...
@@ -142,7 +154,7 @@ inline void isrCall(void) {
142 154
 		layer = 0;
143 155
 		changedFlag = 0;
144 156
 	}
145
-	// setFet(0);
157
+	setFet(0);
146 158
 	for (; latchCtr < 8; latchCtr++) {
147 159
 		setLatch(latchCtr, imgBuffer[layer][latchCtr]); // Put out all the data
148 160
 	}

+ 1
- 1
CubeFirmware/main.c Dosyayı Görüntüle

@@ -189,7 +189,7 @@ int main(void) {
189 189
 			serialHandler((char)(serialGet()));
190 190
 		}
191 191
 
192
-		if ((getSystemTime() >= 10000) && ((DebugDone & 1) == 0)) {
192
+		if ((getSystemTime() >= 1000) && ((DebugDone & 1) == 0)) {
193 193
 			printTime();
194 194
 			serialWriteString(ltoa(getTriggerCount(), buffer, 10));
195 195
 			serialWrite('\n');

+ 3
- 2
CubeFirmware/strings.c Dosyayı Görüntüle

@@ -56,9 +56,10 @@ char stringSnakeControl[] PROGMEM = "Controls: W A S D Q E, x to quit\n"; // 23
56 56
 char stringNoMoreHeap[] PROGMEM = "Ran out of Heap... Bye\n"; // 24
57 57
 char stringKilledAnimation[] PROGMEM = "Animation aborted!\n"; // 25
58 58
 char stringHelp9[] PROGMEM = "(i)nterrupt count\n"; // 26
59
+char stringTimerOverflow[] PROGMEM = "Cube Timer Overflowed (now !)\n"; // 27
59 60
 
60 61
 // Last index + 1
61
-#define STRINGNUM 27
62
+#define STRINGNUM 28
62 63
 
63 64
 PGM_P stringTable[STRINGNUM] PROGMEM = { stringVersion, stringSelfTestError, stringInit,
64 65
 								stringAudioError, stringMemError, stringMemWriteError,
@@ -67,7 +68,7 @@ PGM_P stringTable[STRINGNUM] PROGMEM = { stringVersion, stringSelfTestError, str
67 68
 								stringByte, stringWritten, stringCount, stringSelfTest,
68 69
 								stringKillCount, stringAccessError, stringAudioData,
69 70
 								stringSnakeControl, stringNoMoreHeap, stringKilledAnimation,
70
-								stringHelp9 };
71
+								stringHelp9, stringTimerOverflow };
71 72
 
72 73
 char stringNotFoundError[] PROGMEM = "String not found!\n";
73 74
 

Loading…
İptal
Kaydet