diff --git a/speeduino/decoders.ino b/speeduino/decoders.ino index b67a048f..93670e99 100644 --- a/speeduino/decoders.ino +++ b/speeduino/decoders.ino @@ -376,8 +376,6 @@ void triggerSec_DualWheel() if(currentStatus.hasSync == false) { toothLastToothTime = micros(); - //CONFIRM THE BELOW! IT DOESN'T LOOK RIGHT (toothOneTime??) - //toothLastMinusOneToothTime = (toothOneTime - 6000000) / configPage4.triggerTeeth; //Fixes RPM at 10rpm until a full revolution has taken place toothLastMinusOneToothTime = micros() - (6000000 / configPage4.triggerTeeth); //Fixes RPM at 10rpm until a full revolution has taken place toothCurrentCount = configPage4.triggerTeeth; @@ -1027,7 +1025,6 @@ void triggerSetup_24X() MAX_STALL_TIME = (3333UL * triggerToothAngle); //Minimum 50rpm. (3333uS is the time per degree at 50rpm) if(initialisationComplete == false) { toothCurrentCount = 25; toothLastToothTime = micros(); } //Set a startup value here to avoid filter errors when starting. This MUST have the initi check to prevent the fuel pump just staying on all the time - //We set the initial tooth value to be something that should never be reached. This indicates no sync secondDerivEnabled = false; decoderIsSequential = true; } @@ -1087,7 +1084,7 @@ int getCrankAngle_24X(int timePerDegree) interrupts(); int crankAngle; - if (toothCurrentCount == 0) { crankAngle = 0 + configPage4.triggerAngle; } //This is the special case to handle when the 'last tooth' seen was the cam tooth. 0 is the angle at which the crank tooth goes high (Within 360 degrees). + if (tempToothCurrentCount == 0) { crankAngle = 0 + configPage4.triggerAngle; } //This is the special case to handle when the 'last tooth' seen was the cam tooth. 0 is the angle at which the crank tooth goes high (Within 360 degrees). else { crankAngle = toothAngles[(tempToothCurrentCount - 1)] + configPage4.triggerAngle;} //Perform a lookup of the fixed toothAngles array to find what the angle of the last tooth passed was. //Estimate the number of degrees travelled since the last tooth} @@ -1096,7 +1093,7 @@ int getCrankAngle_24X(int timePerDegree) else { crankAngle += ldiv(elapsedTime, timePerDegree).quot; } //Sequential check (simply sets whether we're on the first or 2nd revoltuion of the cycle) - if (tempRevolutionOne) { crankAngle += 360; } + if (tempRevolutionOne == 1) { crankAngle += 360; } if (crankAngle >= 720) { crankAngle -= 720; } if (crankAngle > CRANK_ANGLE_MAX) { crankAngle -= CRANK_ANGLE_MAX; } @@ -1134,7 +1131,7 @@ void triggerSetup_Jeep2000() toothAngles[11] = 474; MAX_STALL_TIME = (3333UL * 60); //Minimum 50rpm. (3333uS is the time per degree at 50rpm). Largest gap between teeth is 60 degrees. - toothCurrentCount = 13; //We set the initial tooth value to be something that should never be reached. This indicates no sync + if(initialisationComplete == false) { toothCurrentCount = 13; toothLastToothTime = micros(); } //Set a startup value here to avoid filter errors when starting. This MUST have the initi check to prevent the fuel pump just staying on all the time secondDerivEnabled = false; decoderIsSequential = false; } diff --git a/speeduino/globals.h b/speeduino/globals.h index 42124ac4..271d8002 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -20,7 +20,6 @@ #define word(h, l) ((h << 8) | l) //word() function not defined for this platform in the main library #if defined (STM32F1) || defined(__STM32F1__) #define BOARD_DIGITAL_GPIO_PINS 34 - #undef BOARD_NR_GPIO_PINS //This is declared as 49 in .../framework-arduinoststm32/STM32F1/variants/generic_stm32f103r8/board/board.h #define BOARD_NR_GPIO_PINS 34 #define LED_BUILTIN 33 #elif defined(ARDUINO_BLACK_F407VE) || defined(STM32F4) @@ -41,8 +40,6 @@ #define portInputRegister(port) (volatile byte *)( &(port->IDR) ) #else //libmaple core aka STM32DUINO //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value - #undef portOutputRegister - #undef portInputRegister #define portOutputRegister(port) (volatile byte *)( &(port->regs->ODR) ) #define portInputRegister(port) (volatile byte *)( &(port->regs->IDR) ) #endif diff --git a/speeduino/table.ino b/speeduino/table.ino index ce6a5427..ba59a8c2 100644 --- a/speeduino/table.ino +++ b/speeduino/table.ino @@ -64,7 +64,7 @@ int table2D_getValue(struct table2D *fromTable, int X_in) int xMax = 0; //Check whether the X input is the same as last time this ran - if(X_in == fromTable->lastInput && fromTable->cacheTime == currentStatus.secl) + if( (X_in == fromTable->lastInput) && (fromTable->cacheTime == currentStatus.secl) ) { returnValue = fromTable->lastOutput; valueFound = true; diff --git a/speeduino/updates.ino b/speeduino/updates.ino index d8f5d73f..85d9dccd 100644 --- a/speeduino/updates.ino +++ b/speeduino/updates.ino @@ -102,7 +102,9 @@ void doUpdates() for (uint8_t x = 1; x < 6; x++) { uint8_t pct = x * 20; - configPage10.flexBoostBins[x] = configPage10.flexFuelBins[x] = configPage10.flexAdvBins[x] = pct; + configPage10.flexBoostBins[x] = pct; + configPage10.flexFuelBins[x] = pct; + configPage10.flexAdvBins[x] = pct; int16_t boostAdder = (((configPage2.unused2_2 - (int8_t)configPage2.unused2_1) * pct) / 100) + (int8_t)configPage2.unused2_1; configPage10.flexBoostAdj[x] = boostAdder;