fixing NOISY_RPM handling via Sensor framework
This commit is contained in:
parent
1bd71e4b2e
commit
33df88d3f7
|
@ -384,7 +384,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rpm = GET_RPM();
|
int rpm = engine->rpmCalculator.getRpm();
|
||||||
if (rpm == 0) {
|
if (rpm == 0) {
|
||||||
// this happens while we just start cranking
|
// this happens while we just start cranking
|
||||||
|
|
||||||
|
|
|
@ -111,12 +111,10 @@ void RpmCalculator::assignRpmValue(float floatRpmValue) {
|
||||||
// TODO: RPM should eventually switch to floating point across the ECU
|
// TODO: RPM should eventually switch to floating point across the ECU
|
||||||
rpmValue = efiRound(floatRpmValue, 1);
|
rpmValue = efiRound(floatRpmValue, 1);
|
||||||
|
|
||||||
|
setValidValue(floatRpmValue, 0); // 0 for current time since RPM sensor never times out
|
||||||
if (rpmValue <= 0) {
|
if (rpmValue <= 0) {
|
||||||
oneDegreeUs = NAN;
|
oneDegreeUs = NAN;
|
||||||
setValidValue(0, 0); // 0 for current time since RPM sensor never times out
|
|
||||||
} else {
|
} 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
|
// here it's really important to have more precise float RPM value, see #796
|
||||||
oneDegreeUs = getOneDegreeTimeUs(floatRpmValue);
|
oneDegreeUs = getOneDegreeTimeUs(floatRpmValue);
|
||||||
if (previousRpmValue == 0) {
|
if (previousRpmValue == 0) {
|
||||||
|
|
|
@ -153,9 +153,6 @@ private:
|
||||||
Timer engineStartTimer;
|
Timer engineStartTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Just a getter for rpmValue
|
|
||||||
#define GET_RPM() ( engine->rpmCalculator.getRpm() )
|
|
||||||
|
|
||||||
#define isValidRpm(rpm) ((rpm) > 0 && (rpm) < UNREALISTIC_RPM)
|
#define isValidRpm(rpm) ((rpm) > 0 && (rpm) < UNREALISTIC_RPM)
|
||||||
|
|
||||||
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp);
|
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp);
|
||||||
|
|
|
@ -72,7 +72,7 @@ TEST(trigger, testNoisyInput) {
|
||||||
eth.firePrimaryTriggerRise();
|
eth.firePrimaryTriggerRise();
|
||||||
eth.firePrimaryTriggerFall();
|
eth.firePrimaryTriggerFall();
|
||||||
// error condition since events happened too quick while time does not move
|
// 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( 2, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testNoisyInput";
|
||||||
ASSERT_EQ(CUSTOM_SYNC_COUNT_MISMATCH, unitTestWarningCodeState.recentWarnings.get(0)) << "@0";
|
ASSERT_EQ(CUSTOM_SYNC_COUNT_MISMATCH, unitTestWarningCodeState.recentWarnings.get(0)) << "@0";
|
||||||
|
|
Loading…
Reference in New Issue