RPM refactoring

This commit is contained in:
rusefi 2017-07-07 08:10:06 -04:00
parent 4ac4d8b8a1
commit 13a2126240
1 changed files with 9 additions and 2 deletions

View File

@ -61,7 +61,7 @@ RpmCalculator::RpmCalculator() {
}
bool RpmCalculator::isStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return rpmValue == 0;
return state == STOPPED;
}
bool RpmCalculator::isCranking(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
@ -72,7 +72,7 @@ bool RpmCalculator::isCranking(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
* @return true if there was a full shaft revolution within the last second
*/
bool RpmCalculator::isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return rpmValue >= CONFIG(cranking.rpm);
return state == RUNNING;
}
bool RpmCalculator::checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
@ -122,6 +122,13 @@ void RpmCalculator::setRpmValue(int value DECLARE_ENGINE_PARAMETER_SUFFIX) {
*/
ENGINE(periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE));
}
if (rpmValue == 0) {
state = STOPPED;
} else if (rpmValue < CONFIG(cranking.rpm)) {
state = CRANKING;
} else {
state = RUNNING;
}
}
void RpmCalculator::onNewEngineCycle() {