better EFI_ENGINE_CONTROL

This commit is contained in:
Andrey 2023-11-05 11:25:46 -05:00
parent da25b873ab
commit 3d3671e6d4
4 changed files with 20 additions and 5 deletions

View File

@ -888,7 +888,9 @@ void detectBoardType() {
void fuelBenchMode() {
engineConfiguration->cranking.rpm = 12000;
#if EFI_ENGINE_CONTROL
setFlatInjectorLag(0);
#endif // EFI_ENGINE_CONTROL
setTable(engineConfiguration->postCrankingFactor, 1.0f);
setArrayValues(config->crankingFuelCoef, 1.0f);
setArrayValues(config->crankingCycleCoef, 1.0f);

View File

@ -75,7 +75,7 @@ expected<float> BoostController::getSetpoint() {
efiAssert(ObdCode::OBD_PCM_Processor_Fault, m_closedLoopTargetMap != nullptr, "boost closed loop target", unexpected);
float target = m_closedLoopTargetMap->getValue(rpm, driverIntent.Value);
#if EFI_ENGINE_CONTROL
// Add any blends if configured
for (size_t i = 0; i < efi::size(config->boostClosedLoopBlends); i++) {
auto result = calculateBlend(config->boostClosedLoopBlends[i], rpm, driverIntent.Value);
@ -86,6 +86,7 @@ expected<float> BoostController::getSetpoint() {
target += result.Value;
}
#endif //EFI_ENGINE_CONTROL
return target * luaTargetMult + luaTargetAdd;
}
@ -107,6 +108,7 @@ expected<percent_t> BoostController::getOpenLoop(float target) {
float openLoop = luaOpenLoopAdd + m_openLoopMap->getValue(rpm, driverIntent.Value);
#if EFI_ENGINE_CONTROL
// Add any blends if configured
for (size_t i = 0; i < efi::size(config->boostOpenLoopBlends); i++) {
auto result = calculateBlend(config->boostOpenLoopBlends[i], rpm, driverIntent.Value);
@ -117,6 +119,7 @@ expected<percent_t> BoostController::getOpenLoop(float target) {
openLoop += result.Value;
}
#endif // EFI_ENGINE_CONTROL
// Add gear-based adder
auto gear = Sensor::getOrZero(SensorType::DetectedGear);
@ -181,9 +184,11 @@ void BoostController::setOutput(expected<float> output) {
m_pwm->setSimplePwmDutyCycle(duty);
}
#if EFI_ELECTRONIC_THROTTLE_BODY
// inject wastegate position into DC controllers, pretty weird workflow to be honest
// todo: should it be DC controller pulling?
setEtbWastegatePosition(boostOutput);
#endif // EFI_ELECTRONIC_THROTTLE_BODY
}
void BoostController::onFastCallback() {
@ -281,4 +286,4 @@ void initBoostCtrl() {
#endif
}
#endif
#endif // EFI_BOOST_CONTROL

View File

@ -368,6 +368,7 @@ static int lua_setDebug(lua_State* l) {
return 0;
}
#if EFI_ENGINE_CONTROL
static auto lua_getAirmassResolveMode(lua_State* l) {
if (lua_gettop(l) == 0) {
// zero args, return configured mode
@ -403,6 +404,7 @@ static int lua_setAirmass(lua_State* l) {
return 0;
}
#endif // EFI_ENGINE_CONTROL
#endif // EFI_UNIT_TEST
@ -756,14 +758,14 @@ void configureRusefiLuaHooks(lua_State* lState) {
return 0;
});
#if EFI_PROD_CODE
#if EFI_ELECTRONIC_THROTTLE_BODY && EFI_PROD_CODE
lua_register(lState, "restartEtb", [](lua_State* l) {
// this is about Lua sensor acting in place of real analog PPS sensor
// todo: smarter implementation
doInitElectronicThrottle();
return 0;
});
#endif // EFI_PROD_CODE
#endif // EFI_ELECTRONIC_THROTTLE_BODY
// checksum stuff
lua_register(lState, "crc8_j1850", [](lua_State* l) {
@ -812,7 +814,7 @@ void configureRusefiLuaHooks(lua_State* lState) {
engine->engineState.lua.fuelMult = luaL_checknumber(l, 1);
return 0;
});
#if EFI_PROD_CODE
#if EFI_ELECTRONIC_THROTTLE_BODY && EFI_PROD_CODE
lua_register(lState, "setEtbAdd", [](lua_State* l) {
auto luaAdjustment = luaL_checknumber(l, 1);
@ -820,6 +822,8 @@ void configureRusefiLuaHooks(lua_State* lState) {
return 0;
});
#endif // EFI_ELECTRONIC_THROTTLE_BODY
#if EFI_PROD_CODE
lua_register(lState, "setEtbDisabled", [](lua_State* l) {
engine->engineState.lua.luaDisableEtb = lua_toboolean(l, 1);
return 0;
@ -934,8 +938,10 @@ void configureRusefiLuaHooks(lua_State* lState) {
lua_register(lState, "getDigital", lua_getDigital);
lua_register(lState, "getAuxDigital", lua_getAuxDigital);
lua_register(lState, "setDebug", lua_setDebug);
#if EFI_ENGINE_CONTROL
lua_register(lState, "getAirmass", lua_getAirmass);
lua_register(lState, "setAirmass", lua_setAirmass);
#endif // EFI_ENGINE_CONTROL
lua_register(lState, "stopEngine", [](lua_State*) {
doScheduleStopEngine();

View File

@ -7,7 +7,9 @@
void doScheduleStopEngine() {
efiPrintf("Starting doScheduleStopEngine");
#if EFI_ENGINE_CONTROL
getLimpManager()->shutdownController.stopEngine();
#endif // EFI_ENGINE_CONTROL
// todo: initiate stepper motor parking
// make sure we have stored all the info
#if EFI_PROD_CODE