From fbdbc0656ae0646c6c3efc3c9c93f35c00290198 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 6 Nov 2019 00:10:44 -0500 Subject: [PATCH] Missing dwell altogether in some corner cases #796 flirting with the fix but not yet the fix --- firmware/controllers/trigger/rpm_calculator.cpp | 8 ++++---- firmware/controllers/trigger/rpm_calculator.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/trigger/rpm_calculator.cpp b/firmware/controllers/trigger/rpm_calculator.cpp index 812c74e6d2..d979f3995f 100644 --- a/firmware/controllers/trigger/rpm_calculator.cpp +++ b/firmware/controllers/trigger/rpm_calculator.cpp @@ -129,7 +129,7 @@ bool RpmCalculator::checkIfSpinning(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUF return true; } -void RpmCalculator::assignRpmValue(int value DECLARE_ENGINE_PARAMETER_SUFFIX) { +void RpmCalculator::assignRpmValue(float value DECLARE_ENGINE_PARAMETER_SUFFIX) { previousRpmValue = rpmValue; rpmValue = value; if (rpmValue <= 0) { @@ -146,7 +146,7 @@ void RpmCalculator::assignRpmValue(int value DECLARE_ENGINE_PARAMETER_SUFFIX) { } } -void RpmCalculator::setRpmValue(int value DECLARE_ENGINE_PARAMETER_SUFFIX) { +void RpmCalculator::setRpmValue(float value DECLARE_ENGINE_PARAMETER_SUFFIX) { assignRpmValue(value PASS_ENGINE_PARAMETER_SUFFIX); spinning_state_e oldState = state; // Change state @@ -248,7 +248,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, rpmState->setRpmValue(NOISY_RPM PASS_ENGINE_PARAMETER_SUFFIX); } else { int mult = (int)getEngineCycle(engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE)) / 360; - int rpm = (int) (60 * US2NT(US_PER_SECOND_LL) * mult / diffNt); + float rpm = (int) (60 * US2NT(US_PER_SECOND_LL) * mult / diffNt); rpmState->setRpmValue(rpm > UNREALISTIC_RPM ? NOISY_RPM : rpm PASS_ENGINE_PARAMETER_SUFFIX); } } @@ -354,7 +354,7 @@ void initRpmCalculator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { * The callback would be executed once after the duration of time which * it takes the crankshaft to rotate to the specified angle. */ -void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle, +void scheduleByAngle(float rpm, scheduling_s *timer, angle_t angle, schfunc_t callback, void *param DECLARE_ENGINE_PARAMETER_SUFFIX) { efiAssertVoid(CUSTOM_ANGLE_NAN, !cisnan(angle), "NaN angle?"); efiAssertVoid(CUSTOM_ERR_6634, isValidRpm(rpm), "RPM check expected"); diff --git a/firmware/controllers/trigger/rpm_calculator.h b/firmware/controllers/trigger/rpm_calculator.h index b5d80442a7..e539fdc95f 100644 --- a/firmware/controllers/trigger/rpm_calculator.h +++ b/firmware/controllers/trigger/rpm_calculator.h @@ -90,12 +90,12 @@ public: */ void onNewEngineCycle(); uint32_t getRevolutionCounterM(void) const; - void setRpmValue(int value DECLARE_ENGINE_PARAMETER_SUFFIX); + void setRpmValue(float value DECLARE_ENGINE_PARAMETER_SUFFIX); /** * The same as setRpmValue() but without state change. * We need this to be public because of calling rpmState->assignRpmValue() from rpmShaftPositionCallback() */ - void assignRpmValue(int value DECLARE_ENGINE_PARAMETER_SUFFIX); + void assignRpmValue(float value DECLARE_ENGINE_PARAMETER_SUFFIX); uint32_t getRevolutionCounterSinceStart(void) const; /** * RPM rate of change between current RPM and RPM measured during previous engine cycle @@ -166,6 +166,6 @@ float getCrankshaftAngleNt(efitime_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX); #define addEngineSnifferEvent(n, msg) {} #endif /* EFI_ENGINE_SNIFFER */ -void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle, schfunc_t callback, void *param DECLARE_ENGINE_PARAMETER_SUFFIX); +void scheduleByAngle(float rpm, scheduling_s *timer, angle_t angle, schfunc_t callback, void *param DECLARE_ENGINE_PARAMETER_SUFFIX); #endif /* RPM_REPORTER_H_ */