RPM refactoring

This commit is contained in:
rusefi 2017-07-07 07:20:04 -04:00
parent d20803e942
commit 4ac4d8b8a1
2 changed files with 10 additions and 8 deletions

View File

@ -103,7 +103,6 @@ bool RpmCalculator::checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return true; return true;
} }
// private method
void RpmCalculator::assignRpmValue(int value) { void RpmCalculator::assignRpmValue(int value) {
previousRpmValue = rpmValue; previousRpmValue = rpmValue;
rpmValue = value; rpmValue = value;
@ -148,9 +147,10 @@ float RpmCalculator::getRpmAcceleration() {
void RpmCalculator::setStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void RpmCalculator::setStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
revolutionCounterSinceStart = 0; revolutionCounterSinceStart = 0;
if (rpmValue != 0) { if (rpmValue != 0) {
rpmValue = 0; assignRpmValue(0);
scheduleMsg(logger, "engine stopped"); scheduleMsg(logger, "engine stopped");
} }
state = STOPPED;
} }
/** /**

View File

@ -44,7 +44,7 @@ typedef enum {
* The engine is running (RPM >= cranking.rpm) * The engine is running (RPM >= cranking.rpm)
*/ */
RUNNING, RUNNING,
} engine_state_e; } spinning_state_e;
class Engine; class Engine;
@ -67,11 +67,6 @@ public:
*/ */
bool isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE); 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); bool checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE);
int getRpm(DECLARE_ENGINE_PARAMETER_SIGNATURE); int getRpm(DECLARE_ENGINE_PARAMETER_SIGNATURE);
@ -95,6 +90,11 @@ public:
volatile floatus_t oneDegreeUs; volatile floatus_t oneDegreeUs;
volatile efitime_t lastRpmEventTimeNt; volatile efitime_t lastRpmEventTimeNt;
private: private:
/**
* Should be called once we've realized engine is not spinning any more.
*/
void setStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void assignRpmValue(int value); void assignRpmValue(int value);
/** /**
* This counter is incremented with each revolution of one of the shafts. Could be * This counter is incremented with each revolution of one of the shafts. Could be
@ -105,6 +105,8 @@ private:
* Same as the above, but since the engine started spinning * Same as the above, but since the engine started spinning
*/ */
volatile uint32_t revolutionCounterSinceStart; volatile uint32_t revolutionCounterSinceStart;
spinning_state_e state;
}; };
/** /**