diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 6b5fd4fdfc..e08325843c 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -951,23 +951,7 @@ static pid_s* getEtbPidForFunction(etb_function_e function) { } } -static void doInitElectronicThrottle() { - efiAssertVoid(OBD_PCM_Processor_Fault, engine->etbControllers != NULL, "etbControllers NULL"); -#if EFI_PROD_CODE - addConsoleAction("ethinfo", showEthInfo); - addConsoleAction("etbreset", etbReset); - addConsoleActionI("etb_freq", setEtbFrequency); - - // this command is useful for real hardware test with known cheap hardware - addConsoleAction("etb_test_hw", [](){ - set18919_AM810_pedal_position_sensor(); - }); - -#endif /* EFI_PROD_CODE */ - - pedal2tpsMap.init(config->pedalToTpsTable, config->pedalToTpsPedalBins, config->pedalToTpsRpmBins); - throttle2TrimTable.init(config->throttle2TrimTable, config->throttle2TrimTpsBins, config->throttle2TrimRpmBins); - +void doInitElectronicThrottle() { bool shouldInitThrottles = Sensor::hasSensor(SensorType::AcceleratorPedalPrimary); bool anyEtbConfigured = false; @@ -1034,6 +1018,22 @@ void initElectronicThrottle() { } #endif + efiAssertVoid(OBD_PCM_Processor_Fault, engine->etbControllers != NULL, "etbControllers NULL"); +#if EFI_PROD_CODE + addConsoleAction("ethinfo", showEthInfo); + addConsoleAction("etbreset", etbReset); + addConsoleActionI("etb_freq", setEtbFrequency); + + // this command is useful for real hardware test with known cheap hardware + addConsoleAction("etb_test_hw", [](){ + set18919_AM810_pedal_position_sensor(); + }); + +#endif /* EFI_PROD_CODE */ + + pedal2tpsMap.init(config->pedalToTpsTable, config->pedalToTpsPedalBins, config->pedalToTpsRpmBins); + throttle2TrimTable.init(config->throttle2TrimTable, config->throttle2TrimTpsBins, config->throttle2TrimRpmBins); + doInitElectronicThrottle(); } diff --git a/firmware/controllers/actuators/electronic_throttle.h b/firmware/controllers/actuators/electronic_throttle.h index 09eceb1c2a..de4818e813 100644 --- a/firmware/controllers/actuators/electronic_throttle.h +++ b/firmware/controllers/actuators/electronic_throttle.h @@ -12,6 +12,7 @@ #include "engine_configuration.h" void initElectronicThrottle(); +void doInitElectronicThrottle(); void setEtbIdlePosition(percent_t pos); void setEtbWastegatePosition(percent_t pos); diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index f9154b9272..ce98b272cd 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -725,7 +725,7 @@ void configureRusefiLuaHooks(lua_State* l) { lua_register(l, "restartEtb", [](lua_State* l) { // this is about Lua sensor acting in place of real analog PPS sensor // todo: smarter implementation - initElectronicThrottle(); + doInitElectronicThrottle(); return 0; }); #endif // EFI_PROD_CODE