Fix VSS not resetting to zero (#787)

Reinstated car stop check to avoid  speed not going back to zero.
This commit is contained in:
rafolg 2022-02-05 08:26:40 +10:00 committed by GitHub
parent fb0a52bf6f
commit aea6a6bed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -645,8 +645,12 @@ uint16_t getSpeed()
} }
pulseTime = vssTotalTime / (VSS_SAMPLES - 1); pulseTime = vssTotalTime / (VSS_SAMPLES - 1);
if ( (micros() - vssTimes[0]) > 1000000UL ) { tempSpeed = 0; } // Check that the car hasn't come to a stop
else
{
tempSpeed = 3600000000UL / (pulseTime * configPage2.vssPulsesPerKm); //Convert the pulse gap into km/h tempSpeed = 3600000000UL / (pulseTime * configPage2.vssPulsesPerKm); //Convert the pulse gap into km/h
tempSpeed = ADC_FILTER(tempSpeed, configPage2.vssSmoothing, currentStatus.vss); //Apply speed smoothing factor tempSpeed = ADC_FILTER(tempSpeed, configPage2.vssSmoothing, currentStatus.vss); //Apply speed smoothing factor
}
if(tempSpeed > 1000) { tempSpeed = currentStatus.vss; } //Safety check. This usually occurs when there is a hardware issue if(tempSpeed > 1000) { tempSpeed = currentStatus.vss; } //Safety check. This usually occurs when there is a hardware issue
} }