RPM refactoring
This commit is contained in:
parent
dac3cad9da
commit
a98b5d87cd
|
@ -259,6 +259,11 @@ static void periodicSlowCallback(Engine *engine) {
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Update engine RPM state if needed (check timeouts).
|
||||
*/
|
||||
engine->rpmCalculator.checkIfSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
if (engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||
#if (EFI_PROD_CODE && EFI_ENGINE_CONTROL && EFI_INTERNAL_FLASH) || defined(__DOXYGEN__)
|
||||
writeToFlashIfPending();
|
||||
|
|
|
@ -100,6 +100,9 @@ bool RpmCalculator::isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool RpmCalculator::checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// private method
|
||||
void RpmCalculator::assignRpmValue(int value) {
|
||||
|
@ -143,6 +146,17 @@ float RpmCalculator::getRpmAcceleration() {
|
|||
return 1.0 * previousRpmValue / rpmValue;
|
||||
}
|
||||
|
||||
void RpmCalculator::setStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
revolutionCounterSinceStart = 0;
|
||||
if (rpmValue != 0) {
|
||||
rpmValue = 0;
|
||||
scheduleMsg(logger,
|
||||
"templog rpm=0 since not running [%x][%x] [%x][%x]",
|
||||
(int) (notRunnintNow >> 32), (int) notRunnintNow,
|
||||
(int) (notRunningPrev >> 32), (int) notRunningPrev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: this is a heavy method because 'getRpm()' is relatively heavy
|
||||
*
|
||||
|
@ -156,14 +170,7 @@ int RpmCalculator::getRpm(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
return mockRpm;
|
||||
#endif
|
||||
if (!isRunning(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||
revolutionCounterSinceStart = 0;
|
||||
if (rpmValue != 0) {
|
||||
rpmValue = 0;
|
||||
scheduleMsg(logger,
|
||||
"templog rpm=0 since not running [%x][%x] [%x][%x]",
|
||||
(int) (notRunnintNow >> 32), (int) notRunnintNow,
|
||||
(int) (notRunningPrev >> 32), (int) notRunningPrev);
|
||||
}
|
||||
setStopped(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
}
|
||||
return rpmValue;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,14 @@ public:
|
|||
* Please note that this is a relatively heavy method due to getTimeNowNt() usage
|
||||
*/
|
||||
bool isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
/**
|
||||
* Should be called once we've realized engine is not spinning any more.
|
||||
*/
|
||||
void setStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
bool checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
int getRpm(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
/**
|
||||
* This method is invoked once per engine cycle right after we calculate new RPM value
|
||||
|
|
Loading…
Reference in New Issue