diff --git a/comms.ino b/comms.ino index 1ef21064..0a28cc7d 100644 --- a/comms.ino +++ b/comms.ino @@ -822,8 +822,8 @@ void sendToothLog(bool useChar) { //We need 256 records to send to TunerStudio. If there aren't that many in the buffer (Buffer is 512 long) then we just return and wait for the next call - if (toothHistoryIndex < 256) { - return; //Don't believe this is the best way to go. Just display whatever is in the buffer + if (toothHistoryIndex < 255) { + return; //This should no longer ever occur } unsigned int tempToothHistory[512]; //Create a temporary array that will contain a copy of what is in the main toothHistory array @@ -846,6 +846,7 @@ void sendToothLog(bool useChar) Serial.write(highByte(tempToothHistory[x])); Serial.write(lowByte(tempToothHistory[x])); } + BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //Serial.flush(); } diff --git a/decoders.ino b/decoders.ino index f8d8b52a..6581c827 100644 --- a/decoders.ino +++ b/decoders.ino @@ -131,7 +131,7 @@ void triggerPri_DualWheel() //High speed tooth logging history toothHistory[toothHistoryIndex] = curGap; if(toothHistoryIndex == 511) - { toothHistoryIndex = 0; } + { toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent. else { toothHistoryIndex++; } @@ -215,7 +215,7 @@ void triggerPri_BasicDistributor() //High speed tooth logging history toothHistory[toothHistoryIndex] = curGap; if(toothHistoryIndex == 511) - { toothHistoryIndex = 0; } + { toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent. else { toothHistoryIndex++; } @@ -268,7 +268,7 @@ void triggerPri_GM7X() //High speed tooth logging history toothHistory[toothHistoryIndex] = curGap; if(toothHistoryIndex == 511) - { toothHistoryIndex = 0; } + { toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent. else { toothHistoryIndex++; } @@ -385,7 +385,7 @@ void triggerPri_4G63() //High speed tooth logging history toothHistory[toothHistoryIndex] = curGap; if(toothHistoryIndex == 511) - { toothHistoryIndex = 0; } + { toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent. else { toothHistoryIndex++; } @@ -497,7 +497,7 @@ void triggerPri_24X() //High speed tooth logging history toothHistory[toothHistoryIndex] = curGap; if(toothHistoryIndex == 511) - { toothHistoryIndex = 0; } + { toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent. else { toothHistoryIndex++; } @@ -584,7 +584,7 @@ void triggerPri_Jeep2000() //High speed tooth logging history toothHistory[toothHistoryIndex] = curGap; if(toothHistoryIndex == 511) - { toothHistoryIndex = 0; } + { toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent. else { toothHistoryIndex++; } diff --git a/globals.h b/globals.h index add72397..9032691f 100644 --- a/globals.h +++ b/globals.h @@ -24,13 +24,14 @@ const int map_page_size = 288; #define BIT_ENGINE_IDLE 7 // idle on //Define masks for Squirt -#define BIT_SQUIRT_INJ1 0 //inj1 Squirt -#define BIT_SQUIRT_INJ2 1 //inj2 Squirt -#define BIT_SQUIRT_SCHSQRT 2 //Scheduled to squirt -#define BIT_SQUIRT_SQRTING 3 //Squirting +#define BIT_SQUIRT_INJ1 0 //inj1 Squirt +#define BIT_SQUIRT_INJ2 1 //inj2 Squirt +#define BIT_SQUIRT_INJ3 2 //inj3 Squirt +#define BIT_SQUIRT_INJ4 3 //inj4 Squirt #define BIT_SQUIRT_INJ2SCHED 4 #define BIT_SQUIRT_INJ2SQRT 5 //Injector2 (Schedule2) -#define BIT_SQUIRT_BOOSTCTRLOFF 6 //Squirting Injector 2 +#define BIT_SQUIRT_TOOTHLOG1READY 6 //Used to flag if tooth log 1 is ready +#define BIT_SQUIRT_TOOTHLOG2READY 7 //Used to flag if tooth log 2 is ready (Log is not currently used) #define SIZE_BYTE 8 #define SIZE_INT 16 diff --git a/speeduino.ino b/speeduino.ino index 75d665d5..6bbbe24e 100644 --- a/speeduino.ino +++ b/speeduino.ino @@ -560,7 +560,9 @@ void loop() currentStatus.TPS_time = currentLoopTime; //Check for launch in (clutch) can be done around here too - currentStatus.launching = !digitalRead(pinLaunch); + currentStatus.launching = !digitalRead(pinLaunch); + //And check whether the tooth log buffer is ready + if(toothHistoryIndex > 255) { BIT_SET(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } } //The IAT and CLT readings can be done less frequently. This still runs about 4 times per second @@ -923,27 +925,27 @@ void loop() //These functions simply trigger the injector/coil driver off or on. //NOTE: squirt status is changed as per http://www.msextra.com/doc/ms1extra/COM_RS232.htm#Acmd -void openInjector1() { digitalWrite(pinInjector1, HIGH); BIT_SET(currentStatus.squirt, 0); } -void closeInjector1() { digitalWrite(pinInjector1, LOW); BIT_CLEAR(currentStatus.squirt, 0); } +void openInjector1() { digitalWrite(pinInjector1, HIGH); BIT_SET(currentStatus.squirt, BIT_SQUIRT_INJ1); } +void closeInjector1() { digitalWrite(pinInjector1, LOW); BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_INJ1); } //void openInjector1() { *inj1_pin_port |= (inj1_pin_mask); ; BIT_SET(currentStatus.squirt, 0); } //void closeInjector1() { *inj1_pin_port &= ~(inj1_pin_mask); BIT_CLEAR(currentStatus.squirt, 0); } void beginCoil1Charge() { digitalWrite(pinCoil1, coilHIGH); BIT_SET(currentStatus.spark, 0); digitalWrite(pinTachOut, LOW); } void endCoil1Charge() { digitalWrite(pinCoil1, coilLOW); BIT_CLEAR(currentStatus.spark, 0); } -void openInjector2() { digitalWrite(pinInjector2, HIGH); BIT_SET(currentStatus.squirt, 1); } //Sets the relevant pin HIGH and changes the current status bit for injector 2 (2nd bit of currentStatus.squirt) -void closeInjector2() { digitalWrite(pinInjector2, LOW); BIT_CLEAR(currentStatus.squirt, 1); } +void openInjector2() { digitalWrite(pinInjector2, HIGH); BIT_SET(currentStatus.squirt, BIT_SQUIRT_INJ2); } //Sets the relevant pin HIGH and changes the current status bit for injector 2 (2nd bit of currentStatus.squirt) +void closeInjector2() { digitalWrite(pinInjector2, LOW); BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_INJ2); } //void openInjector2() { *inj2_pin_port |= (inj2_pin_mask); ; BIT_SET(currentStatus.squirt, 0); } //void closeInjector2() { *inj2_pin_port &= ~(inj2_pin_mask); BIT_CLEAR(currentStatus.squirt, 0); } void beginCoil2Charge() { digitalWrite(pinCoil2, coilHIGH); BIT_SET(currentStatus.spark, 1); digitalWrite(pinTachOut, LOW); } void endCoil2Charge() { digitalWrite(pinCoil2, coilLOW); BIT_CLEAR(currentStatus.spark, 1);} -void openInjector3() { digitalWrite(pinInjector3, HIGH); BIT_SET(currentStatus.squirt, 2); } //Sets the relevant pin HIGH and changes the current status bit for injector 3 (3rd bit of currentStatus.squirt) -void closeInjector3() { digitalWrite(pinInjector3, LOW); BIT_CLEAR(currentStatus.squirt, 2); } +void openInjector3() { digitalWrite(pinInjector3, HIGH); BIT_SET(currentStatus.squirt, BIT_SQUIRT_INJ3); } //Sets the relevant pin HIGH and changes the current status bit for injector 3 (3rd bit of currentStatus.squirt) +void closeInjector3() { digitalWrite(pinInjector3, LOW); BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_INJ3); } void beginCoil3Charge() { digitalWrite(pinCoil3, coilHIGH); BIT_SET(currentStatus.spark, 2); digitalWrite(pinTachOut, LOW); } void endCoil3Charge() { digitalWrite(pinCoil3, coilLOW); BIT_CLEAR(currentStatus.spark, 2); } -void openInjector4() { digitalWrite(pinInjector4, HIGH); BIT_SET(currentStatus.squirt, 3); } //Sets the relevant pin HIGH and changes the current status bit for injector 4 (4th bit of currentStatus.squirt) -void closeInjector4() { digitalWrite(pinInjector4, LOW); BIT_CLEAR(currentStatus.squirt, 3); } +void openInjector4() { digitalWrite(pinInjector4, HIGH); BIT_SET(currentStatus.squirt, BIT_SQUIRT_INJ4); } //Sets the relevant pin HIGH and changes the current status bit for injector 4 (4th bit of currentStatus.squirt) +void closeInjector4() { digitalWrite(pinInjector4, LOW); BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_INJ4); } void beginCoil4Charge() { digitalWrite(pinCoil4, coilHIGH); BIT_SET(currentStatus.spark, 3); digitalWrite(pinTachOut, LOW); } void endCoil4Charge() { digitalWrite(pinCoil4, coilLOW); BIT_CLEAR(currentStatus.spark, 3); }