Auto switching of TPS reverse calibration. Closes #131
This commit is contained in:
parent
d291d6433f
commit
600fa72f7f
|
@ -200,11 +200,28 @@ void readTPS()
|
|||
byte tempTPS = fastMap1023toX(analogRead(pinTPS), 255); //Get the current raw TPS ADC value and map it into a byte
|
||||
#endif
|
||||
currentStatus.tpsADC = ADC_FILTER(tempTPS, ADCFILTER_TPS, currentStatus.tpsADC);
|
||||
//Check that the ADC values fall within the min and max ranges (Should always be the case, but noise can cause these to fluctuate outside the defined range).
|
||||
byte tempADC = currentStatus.tpsADC; //The tempADC value is used in order to allow TunerStudio to recover and redo the TPS calibration if this somehow gets corrupted
|
||||
|
||||
if(configPage2.tpsMax > configPage2.tpsMin)
|
||||
{
|
||||
//Check that the ADC values fall within the min and max ranges (Should always be the case, but noise can cause these to fluctuate outside the defined range).
|
||||
if (currentStatus.tpsADC < configPage2.tpsMin) { tempADC = configPage2.tpsMin; }
|
||||
else if(currentStatus.tpsADC > configPage2.tpsMax) { tempADC = configPage2.tpsMax; }
|
||||
currentStatus.TPS = map(tempADC, configPage2.tpsMin, configPage2.tpsMax, 0, 100); //Take the raw TPS ADC value and convert it into a TPS% based on the calibrated values
|
||||
}
|
||||
else
|
||||
{
|
||||
//This case occurs when the TPS +5v and gnd are wired backwards, but the user wishes to retain this configuration.
|
||||
//In such a case, tpsMin will be greater then tpsMax and hence checks and mapping needs to be reversed
|
||||
|
||||
tempADC = 255 - currentStatus.tpsADC; //Reverse the ADC values
|
||||
|
||||
//All checks below are reversed from the standard case above
|
||||
if (tempADC > configPage2.tpsMin) { tempADC = configPage2.tpsMin; }
|
||||
else if(tempADC < configPage2.tpsMax) { tempADC = configPage2.tpsMax; }
|
||||
currentStatus.TPS = map(tempADC, configPage2.tpsMax, configPage2.tpsMin, 0, 100);
|
||||
}
|
||||
|
||||
currentStatus.TPS_time = currentLoopTime;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue