Better handling of RPM during stop of cranking #3803

This commit is contained in:
Andrey 2022-01-17 21:27:10 -05:00
parent a1374062f0
commit 9f5188bf30
2 changed files with 4 additions and 6 deletions

View File

@ -608,7 +608,7 @@ void configureRusefiLuaHooks(lua_State* l) {
});
lua_register(l, "getTimeSinceTriggerEventMs", [](lua_State* l) {
int result = engine->triggerCentral.m_lastEventTimer.getElapsedUs() / 1000;
int result = engine->triggerCentral.getSecondsSinceTriggerEvent() * 1000;
lua_pushnumber(l, result);
return 1;
});

View File

@ -71,15 +71,13 @@ public:
expected<float> getCurrentEnginePhase(efitick_t nowNt) const;
float getTimeSinceTriggerEvent(efitick_t nowNt) const {
float getSecondsSinceTriggerEvent(efitick_t nowNt) const {
return m_lastEventTimer.getElapsedSeconds(nowNt);
}
bool engineMovedRecently(efitick_t nowNt) const {
// Trigger event some time in the past second = engine moving
// distributor single tooth, large engines crank at close to 120 RPM
// todo: make this logic account current trigger to stop idle much faster if we have more teeth on trigger wheels?
return getTimeSinceTriggerEvent(nowNt) < 60.0 / RPM_LOW_THRESHOLD / 2;
constexpr float oneRevolutionLimitInSeconds = 60.0 / RPM_LOW_THRESHOLD;
return getSecondsSinceTriggerEvent(nowNt) < oneRevolutionLimitInSeconds / triggerShape.getSize();
}
bool engineMovedRecently() const {