Lua A/C Input #4333

This commit is contained in:
rusefillc 2022-07-08 00:51:53 -04:00
parent e45990462c
commit 67ec949eb6
3 changed files with 15 additions and 5 deletions

View File

@ -311,11 +311,16 @@ void Engine::updateSwitchInputs() {
if (isBrainPinValid(engineConfiguration->clutchDownPin)) {
engine->engineState.clutchDownState = engineConfiguration->clutchDownPinInverted ^ efiReadPin(engineConfiguration->clutchDownPin);
}
if (hasAcToggle()) {
bool result = getAcToggle();
{
bool currentState;
if (hasAcToggle()) {
currentState = getAcToggle();
} else {
currentState = engine->engineState.lua.acRequestState;
}
AcController & acController = engine->module<AcController>().unmock();
if (acController.acButtonState != result) {
acController.acButtonState = result;
if (acController.acButtonState != currentState) {
acController.acButtonState = currentState;
acController.acSwitchLastChangeTimeMs = US2MS(getTimeNowUs());
}
}

View File

@ -558,6 +558,11 @@ void configureRusefiLuaHooks(lua_State* l) {
return 0;
});
lua_register(l, "setAcRequestState", [](lua_State* l) {
engine->engineState.lua.acRequestState = lua_toboolean(l, 1);
return 0;
});
lua_register(l, "getCalibration", [](lua_State* l) {
auto propertyName = luaL_checklstring(l, 1, nullptr);
auto result = getConfigValueByName(propertyName);

View File

@ -21,5 +21,5 @@ bool getAcToggle() {
}
bool hasAcToggle() {
return (isBrainPinValid(engineConfiguration->acSwitch));
return isBrainPinValid(engineConfiguration->acSwitch);
}