From 748f97afeb2a863fc1f56803beea70593ca51799 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 17 Dec 2022 18:04:54 -0500 Subject: [PATCH] kinetis asking for guard, also I've must have messed up something --- firmware/console/binary/live_data.cpp | 4 ++++ firmware/controllers/actuators/idle_thread_io.cpp | 8 ++++++++ firmware/controllers/algo/advance_map.cpp | 6 ++++-- firmware/controllers/algo/airmass/airmass.cpp | 2 ++ firmware/controllers/algo/engine.cpp | 4 ++++ firmware/controllers/lua/lua_hooks.cpp | 2 ++ 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/firmware/console/binary/live_data.cpp b/firmware/console/binary/live_data.cpp index 1fb0e5eddb..45d3d44d78 100644 --- a/firmware/console/binary/live_data.cpp +++ b/firmware/console/binary/live_data.cpp @@ -140,7 +140,11 @@ const wall_fuel_state_s* getLiveData(size_t) { template<> const idle_state_s* getLiveData(size_t) { +#if EFI_IDLE_CONTROL return &engine->module().unmock(); +#else + return nullptr; +#endif } template<> diff --git a/firmware/controllers/actuators/idle_thread_io.cpp b/firmware/controllers/actuators/idle_thread_io.cpp index 817452a840..5faab8d22a 100644 --- a/firmware/controllers/actuators/idle_thread_io.cpp +++ b/firmware/controllers/actuators/idle_thread_io.cpp @@ -71,9 +71,11 @@ static void showIdleInfo() { } } +#if EFI_IDLE_CONTROL if (engineConfiguration->idleMode == IM_AUTO) { engine->module().unmock().getIdlePid()->showPidStatus("idle"); } +#endif // EFI_IDLE_CONTROL } void setIdleMode(idle_mode_e value) { @@ -101,7 +103,11 @@ static void startInputPinIfValid(const char *msg, brain_pin_e pin, pin_input_mod #endif // EFI_PROD_CODE percent_t getIdlePosition() { +#if EFI_IDLE_CONTROL return engine->module().unmock().currentIdlePosition; +#else + return 0; +#endif } void startPedalPins() { @@ -130,7 +136,9 @@ void stopPedalPins() { #if ! EFI_UNIT_TEST static void applyPidSettings() { +#if EFI_IDLE_CONTROL engine->module().unmock().getIdlePid()->updateFactors(engineConfiguration->idleRpmPid.pFactor, engineConfiguration->idleRpmPid.iFactor, engineConfiguration->idleRpmPid.dFactor); +#endif // EFI_IDLE_CONTROL } void setTargetIdleRpm(int value) { diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index 557825cad6..00c6dbda2a 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -63,6 +63,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad) { } // get advance from the separate table for Idle +#if EFI_IDLE_CONTROL if (engineConfiguration->useSeparateAdvanceForIdle && engine->module()->isIdlingOrTaper()) { float idleAdvance = interpolate2d(rpm, config->idleAdvanceBins, config->idleAdvance); @@ -73,6 +74,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad) { advanceAngle = interpolateClamped(0.0f, idleAdvance, engineConfiguration->idlePidDeactivationTpsThreshold, advanceAngle, tps.Value); } } +#endif #if EFI_LAUNCH_CONTROL if (engine->launchController.isLaunchCondition && engineConfiguration->enableLaunchRetard) { @@ -104,11 +106,11 @@ angle_t getAdvanceCorrections(int rpm) { ); } -#if EFI_SHAFT_POSITION_INPUT +#if EFI_SHAFT_POSITION_INPUT && EFI_IDLE_CONTROL float instantRpm = engine->triggerCentral.instantRpm.getInstantRpm(); engine->engineState.timingPidCorrection = engine->module()->getIdleTimingAdjustment(instantRpm); -#endif // EFI_SHAFT_POSITION_INPUT +#endif // EFI_SHAFT_POSITION_INPUT && EFI_IDLE_CONTROL #if EFI_TUNER_STUDIO engine->outputChannels.multiSparkCounter = engine->engineState.multispark.count; diff --git a/firmware/controllers/algo/airmass/airmass.cpp b/firmware/controllers/algo/airmass/airmass.cpp index 84c4028364..2de12a1bd2 100644 --- a/firmware/controllers/algo/airmass/airmass.cpp +++ b/firmware/controllers/algo/airmass/airmass.cpp @@ -22,6 +22,7 @@ float AirmassVeModelBase::getVe(int rpm, float load) const { percent_t ve = m_veTable->getValue(rpm, load); +#if EFI_IDLE_CONTROL auto tps = Sensor::get(SensorType::Tps1); // get VE from the separate table for Idle if idling if (engine->module()->isIdlingOrTaper() && @@ -34,6 +35,7 @@ float AirmassVeModelBase::getVe(int rpm, float load) const { // interpolate between idle table and normal (running) table using TPS threshold ve = interpolateClamped(0.0f, idleVe, engineConfiguration->idlePidDeactivationTpsThreshold, ve, tps.Value); } +#endif // EFI_IDLE_CONTROL // Add any adjustments if configured for (size_t i = 0; i < efi::size(config->veBlends); i++) { diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 9fddb772ad..ddebf35cfe 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -253,9 +253,11 @@ void Engine::updateSwitchInputs() { } engine->engineState.clutchUpState = getClutchUpState(); +#if EFI_IDLE_CONTROL if (isBrainPinValid(engineConfiguration->throttlePedalUpPin)) { engine->module().unmock().throttlePedalUpState = efiReadPin(engineConfiguration->throttlePedalUpPin); } +#endif // EFI_IDLE_CONTROL engine->engineState.brakePedalState = getBrakePedalState(); @@ -288,7 +290,9 @@ void Engine::resetLua() { #endif // EFI_BOOST_CONTROL ignitionState.luaTimingAdd = 0; ignitionState.luaTimingMult = 1; +#if EFI_IDLE_CONTROL module().unmock().luaAdd = 0; +#endif // EFI_IDLE_CONTROL } /** diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index ba350135d3..4bce3761b9 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -742,10 +742,12 @@ void configureRusefiLuaHooks(lua_State* l) { return 0; }); #endif // EFI_BOOST_CONTROL +#if EFI_IDLE_CONTROL lua_register(l, "setIdleAdd", [](lua_State* l) { engine->module().unmock().luaAdd = luaL_checknumber(l, 1); return 0; }); +#endif lua_register(l, "setTimingAdd", [](lua_State* l) { engine->ignitionState.luaTimingAdd = luaL_checknumber(l, 1); return 0;