fixing NOISY_RPM handling via Sensor framework

This commit is contained in:
Andrey 2022-01-21 00:21:45 -05:00
parent 1bd71e4b2e
commit 33df88d3f7
4 changed files with 3 additions and 8 deletions

View File

@ -384,7 +384,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
return;
}
int rpm = GET_RPM();
int rpm = engine->rpmCalculator.getRpm();
if (rpm == 0) {
// this happens while we just start cranking

View File

@ -111,12 +111,10 @@ void RpmCalculator::assignRpmValue(float floatRpmValue) {
// TODO: RPM should eventually switch to floating point across the ECU
rpmValue = efiRound(floatRpmValue, 1);
setValidValue(floatRpmValue, 0); // 0 for current time since RPM sensor never times out
if (rpmValue <= 0) {
oneDegreeUs = NAN;
setValidValue(0, 0); // 0 for current time since RPM sensor never times out
} else {
setValidValue(floatRpmValue, 0); // 0 for current time since RPM sensor never times out
// here it's really important to have more precise float RPM value, see #796
oneDegreeUs = getOneDegreeTimeUs(floatRpmValue);
if (previousRpmValue == 0) {

View File

@ -153,9 +153,6 @@ private:
Timer engineStartTimer;
};
// Just a getter for rpmValue
#define GET_RPM() ( engine->rpmCalculator.getRpm() )
#define isValidRpm(rpm) ((rpm) > 0 && (rpm) < UNREALISTIC_RPM)
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp);

View File

@ -72,7 +72,7 @@ TEST(trigger, testNoisyInput) {
eth.firePrimaryTriggerRise();
eth.firePrimaryTriggerFall();
// error condition since events happened too quick while time does not move
ASSERT_EQ(NOISY_RPM, GET_RPM()) << "testNoisyInput RPM should be noisy";
ASSERT_EQ(NOISY_RPM, Sensor::getOrZero(SensorType::Rpm)) << "testNoisyInput RPM should be noisy";
ASSERT_EQ( 2, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testNoisyInput";
ASSERT_EQ(CUSTOM_SYNC_COUNT_MISMATCH, unitTestWarningCodeState.recentWarnings.get(0)) << "@0";