Air Conditioning Improvements #4054

This commit is contained in:
rusefillc 2022-04-08 21:28:38 -04:00
parent 49d6e5efb7
commit ed6ed0d93e
4 changed files with 23 additions and 7 deletions

View File

@ -45,6 +45,9 @@ bool AcController::getAcState() {
if (tpsTooHigh) {
return false;
}
if (isDisabledByLua) {
return false;
}
acButtonState = engine->acSwitchState;
// All conditions allow AC, simply pass thru switch

View File

@ -7,8 +7,9 @@ bit engineTooHot
bit tpsTooHigh
bit acButtonState
bit isDisabledByLua
bit isDisabledByLua;For setAcDisabled Lua method
int latest_usage_ac_control;
int acSwitchLastChangeTimeMs;
end_struct

View File

@ -292,6 +292,17 @@ struct LuaThread : ThreadController<4096> {
void ThreadTask() override;
};
static void resetLua() {
engine->module<AcController>().unmock().isDisabledByLua = false;
#if EFI_CAN_SUPPORT
resetLuaCanRx();
#endif // EFI_CAN_SUPPORT
// De-init pins, they will reinit next start of the script.
luaDeInitPins();
}
static bool needsReset = false;
// Each invocation of runOneLua will:
@ -335,12 +346,7 @@ static bool runOneLua(lua_Alloc alloc, const char* script) {
engine->outputChannels.luaInvocationCounter++;
}
#if EFI_CAN_SUPPORT
resetLuaCanRx();
#endif // EFI_CAN_SUPPORT
// De-init pins, they will reinit next start of the script.
luaDeInitPins();
resetLua();
return true;
}

View File

@ -588,6 +588,12 @@ void configureRusefiLuaHooks(lua_State* l) {
return 0;
});
lua_register(l, "setAcDisabled", [](lua_State* l) {
auto value = lua_toboolean(l, 1);
engine->module<AcController>().unmock().isDisabledByLua = value;
return 0;
});
lua_register(l, "setTimingAdd", [](lua_State* l) {
engine->engineState.luaAdjustments.ignitionTimingAdd = luaL_checknumber(l, 1);
return 0;