RPM refactoring
This commit is contained in:
parent
d3c1710de3
commit
98a978c852
|
@ -103,7 +103,6 @@ bool RpmCalculator::checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// private method
|
||||
void RpmCalculator::assignRpmValue(int value) {
|
||||
previousRpmValue = rpmValue;
|
||||
rpmValue = value;
|
||||
|
@ -148,9 +147,10 @@ float RpmCalculator::getRpmAcceleration() {
|
|||
void RpmCalculator::setStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
revolutionCounterSinceStart = 0;
|
||||
if (rpmValue != 0) {
|
||||
rpmValue = 0;
|
||||
assignRpmValue(0);
|
||||
scheduleMsg(logger, "engine stopped");
|
||||
}
|
||||
state = STOPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef enum {
|
|||
* The engine is running (RPM >= cranking.rpm)
|
||||
*/
|
||||
RUNNING,
|
||||
} engine_state_e;
|
||||
} spinning_state_e;
|
||||
|
||||
class Engine;
|
||||
|
||||
|
@ -67,11 +67,6 @@ public:
|
|||
*/
|
||||
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);
|
||||
|
@ -95,6 +90,11 @@ public:
|
|||
volatile floatus_t oneDegreeUs;
|
||||
volatile efitime_t lastRpmEventTimeNt;
|
||||
private:
|
||||
/**
|
||||
* Should be called once we've realized engine is not spinning any more.
|
||||
*/
|
||||
void setStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
void assignRpmValue(int value);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
volatile uint32_t revolutionCounterSinceStart;
|
||||
|
||||
spinning_state_e state;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue