AC state change uses a timer
This commit is contained in:
parent
f828a755bb
commit
a58ce66581
|
@ -13,6 +13,8 @@ public:
|
|||
|
||||
virtual bool isAcEnabled() const;
|
||||
|
||||
Timer timeSinceStateChange;
|
||||
|
||||
private:
|
||||
bool getAcState();
|
||||
|
||||
|
|
|
@ -15,7 +15,4 @@ bit acCompressorState;AC compressor on
|
|||
bit acPressureTooLow;AC pressure too low
|
||||
bit acPressureTooHigh;AC pressure too high
|
||||
|
||||
! todo: extract some helper which would contain boolean state and most recent toggle time?
|
||||
int acSwitchLastChangeTimeMs;
|
||||
|
||||
end_struct
|
||||
|
|
|
@ -254,7 +254,7 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos,
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool acToggleJustTouched = (US2MS(nowUs) - engine->module<AcController>().unmock().acSwitchLastChangeTimeMs) < 500/*ms*/;
|
||||
bool acToggleJustTouched = engine->module<AcController>().unmock().timeSinceStateChange.getElapsedSeconds() < 0.5f /*second*/;
|
||||
// check if within the dead zone
|
||||
isInDeadZone = !acToggleJustTouched && absI(rpm - targetRpm) <= engineConfiguration->idlePidRpmDeadZone;
|
||||
if (isInDeadZone) {
|
||||
|
|
|
@ -281,7 +281,7 @@ extern bool kAcRequestState;
|
|||
}
|
||||
AcController & acController = engine->module<AcController>().unmock();
|
||||
if (engine->acButtonSwitchedState.update(currentState)) {
|
||||
acController.acSwitchLastChangeTimeMs = US2MS(getTimeNowUs());
|
||||
acController.timeSinceStateChange.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -963,7 +963,7 @@ void configureRusefiLuaHooks(lua_State* lState) {
|
|||
return 0;
|
||||
});
|
||||
lua_register(lState, "getTimeSinceAcToggleMs", [](lua_State* l) {
|
||||
int result = US2MS(getTimeNowUs()) - engine->module<AcController>().unmock().acSwitchLastChangeTimeMs;
|
||||
float result = engine->module<AcController>().unmock().timeSinceStateChange.getElapsedSeconds() * 1000;
|
||||
lua_pushnumber(l, result);
|
||||
return 1;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue