only: tcharge uses a timer instead of hand spun

This commit is contained in:
Matthew Kennedy 2024-04-25 16:26:37 -07:00 committed by rusEFI LLC
parent 27114da4d0
commit b8e9c2832f
2 changed files with 5 additions and 6 deletions

View File

@ -82,7 +82,7 @@ bool WarningCodeState::isWarningNow(ObdCode code) const {
}
EngineState::EngineState() {
timeSinceLastTChargeK = getTimeNowNt();
timeSinceLastTChargeK.reset(getTimeNowNt());
}
void EngineState::updateSlowSensors() {
@ -215,14 +215,13 @@ void EngineState::periodicFastCallback() {
#if EFI_ENGINE_CONTROL
void EngineState::updateTChargeK(int rpm, float tps) {
float newTCharge = engine->fuelComputer.getTCharge(rpm, tps);
// convert to microsecs and then to seconds
efitick_t curTime = getTimeNowNt();
float secsPassed = (float)NT2US(curTime - timeSinceLastTChargeK) / US_PER_SECOND_F;
if (!cisnan(newTCharge)) {
// control the rate of change or just fill with the initial value
efitick_t nowNt = getTimeNowNt();
float secsPassed = timeSinceLastTChargeK.getElapsedSeconds(nowNt);
sd.tCharge = (sd.tChargeK == 0) ? newTCharge : limitRateOfChange(newTCharge, sd.tCharge, engineConfiguration->tChargeAirIncrLimit, engineConfiguration->tChargeAirDecrLimit, secsPassed);
sd.tChargeK = convertCelsiusToKelvin(sd.tCharge);
timeSinceLastTChargeK = curTime;
timeSinceLastTChargeK.reset(nowNt);
}
}
#endif

View File

@ -60,7 +60,7 @@ public:
// Angle between firing the main (primary) spark and the secondary (trailing) spark
angle_t trailingSparkAngle = 0;
efitick_t timeSinceLastTChargeK;
Timer timeSinceLastTChargeK;
float currentVe = 0;