diff --git a/firmware/controllers/actuators/boost_control.txt b/firmware/controllers/actuators/boost_control.txt index be295398f0..d0ca919eb1 100644 --- a/firmware/controllers/actuators/boost_control.txt +++ b/firmware/controllers/actuators/boost_control.txt @@ -6,6 +6,9 @@ bit isBelowClosedLoopThreshold; bit isNotClosedLoop; bit isZeroRpm +float loadTargetAdd +float loadTargetMult + float openLoopPart; int8_t autoscale boostControllerClosedLoopPart;@@GAUGE_NAME_BOOST_CLOSED_LOOP@@;"%", 0.5, 0, -50, 50, 1 int16_t autoscale boostControlTarget;@@GAUGE_NAME_BOOST_TARGET@@;"kPa",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 0, 0 diff --git a/firmware/controllers/actuators/boost_control_generated.h b/firmware/controllers/actuators/boost_control_generated.h index b9bf0fdee9..711bd4fe4d 100644 --- a/firmware/controllers/actuators/boost_control_generated.h +++ b/firmware/controllers/actuators/boost_control_generated.h @@ -1,4 +1,4 @@ -// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/boost_control.txt Wed Jun 29 03:21:07 EDT 2022 +// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/boost_control.txt Wed Jun 29 22:23:02 EDT 2022 // by class com.rusefi.output.CHeaderConsumer // begin #pragma once @@ -104,27 +104,35 @@ struct boost_control_s { /** * offset 4 */ + float loadTargetAdd = (float)0; + /** + * offset 8 + */ + float loadTargetMult = (float)0; + /** + * offset 12 + */ float openLoopPart = (float)0; /** * @@GAUGE_NAME_BOOST_CLOSED_LOOP@@ % - * offset 8 + * offset 16 */ scaled_channel boostControllerClosedLoopPart = (int8_t)0; /** * need 4 byte alignment units - * offset 9 + * offset 17 */ - uint8_t alignmentFill_at_9[1]; + uint8_t alignmentFill_at_17[1]; /** * @@GAUGE_NAME_BOOST_TARGET@@ kPa - * offset 10 + * offset 18 */ scaled_channel boostControlTarget = (int16_t)0; }; -static_assert(sizeof(boost_control_s) == 12); +static_assert(sizeof(boost_control_s) == 20); // end -// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/boost_control.txt Wed Jun 29 03:21:07 EDT 2022 +// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/boost_control.txt Wed Jun 29 22:23:02 EDT 2022 diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index c1b4e0038b..0bc010371e 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -293,7 +293,7 @@ static bool getClutchUpState() { return engineConfiguration->clutchUpPinInverted ^ efiReadPin(engineConfiguration->clutchUpPin); } #endif // EFI_GPIO_HARDWARE - return engine->engineState.luaAdjustments.clutchUpState; + return engine->engineState.lua.clutchUpState; } static bool getBrakePedalState() { @@ -301,7 +301,7 @@ static bool getBrakePedalState() { if (isBrainPinValid(engineConfiguration->brakePedalPin)) { return efiReadPin(engineConfiguration->brakePedalPin); } - return engine->engineState.luaAdjustments.brakePedalState; + return engine->engineState.lua.brakePedalState; #endif // EFI_GPIO_HARDWARE } diff --git a/firmware/controllers/algo/engine_state.h b/firmware/controllers/algo/engine_state.h index 429228b1d8..ff2ce162ce 100644 --- a/firmware/controllers/algo/engine_state.h +++ b/firmware/controllers/algo/engine_state.h @@ -13,12 +13,8 @@ #include "efi_pid.h" #include "engine_state_generated.h" -struct LuaAdjustments { - float fuelAdd = 0; +struct LuaAdjustmentsLegacy { float fuelMult = 1; - - bool clutchUpState = false; - bool brakePedalState = false; }; class EngineState : public engine_state_s { @@ -80,5 +76,5 @@ public: float targetLambda = 0.0f; float stoichiometricRatio = 0.0f; - LuaAdjustments luaAdjustments; + LuaAdjustmentsLegacy luaAdjustments; }; diff --git a/firmware/controllers/algo/engine_state.txt b/firmware/controllers/algo/engine_state.txt index 637aeeea70..8b3e8edc2d 100644 --- a/firmware/controllers/algo/engine_state.txt +++ b/firmware/controllers/algo/engine_state.txt @@ -2,6 +2,17 @@ struct_no_prefix engine_state_s +struct LuaAdjustments + float fuelAdd + + bit clutchUpState + bit brakePedalState + +end_struct + +LuaAdjustments lua + + struct speed_density_s bit isTChargeAirModel diff --git a/firmware/controllers/algo/engine_state_generated.h b/firmware/controllers/algo/engine_state_generated.h index de38059994..95dddb706d 100644 --- a/firmware/controllers/algo/engine_state_generated.h +++ b/firmware/controllers/algo/engine_state_generated.h @@ -3,6 +3,111 @@ // begin #pragma once #include "rusefi_types.h" +// start of LuaAdjustments +struct LuaAdjustments { + /** + * offset 0 + */ + float fuelAdd = (float)0; + /** + offset 4 bit 0 */ + bool clutchUpState : 1 {}; + /** + offset 4 bit 1 */ + bool brakePedalState : 1 {}; + /** + offset 4 bit 2 */ + bool unusedBit_3_2 : 1 {}; + /** + offset 4 bit 3 */ + bool unusedBit_3_3 : 1 {}; + /** + offset 4 bit 4 */ + bool unusedBit_3_4 : 1 {}; + /** + offset 4 bit 5 */ + bool unusedBit_3_5 : 1 {}; + /** + offset 4 bit 6 */ + bool unusedBit_3_6 : 1 {}; + /** + offset 4 bit 7 */ + bool unusedBit_3_7 : 1 {}; + /** + offset 4 bit 8 */ + bool unusedBit_3_8 : 1 {}; + /** + offset 4 bit 9 */ + bool unusedBit_3_9 : 1 {}; + /** + offset 4 bit 10 */ + bool unusedBit_3_10 : 1 {}; + /** + offset 4 bit 11 */ + bool unusedBit_3_11 : 1 {}; + /** + offset 4 bit 12 */ + bool unusedBit_3_12 : 1 {}; + /** + offset 4 bit 13 */ + bool unusedBit_3_13 : 1 {}; + /** + offset 4 bit 14 */ + bool unusedBit_3_14 : 1 {}; + /** + offset 4 bit 15 */ + bool unusedBit_3_15 : 1 {}; + /** + offset 4 bit 16 */ + bool unusedBit_3_16 : 1 {}; + /** + offset 4 bit 17 */ + bool unusedBit_3_17 : 1 {}; + /** + offset 4 bit 18 */ + bool unusedBit_3_18 : 1 {}; + /** + offset 4 bit 19 */ + bool unusedBit_3_19 : 1 {}; + /** + offset 4 bit 20 */ + bool unusedBit_3_20 : 1 {}; + /** + offset 4 bit 21 */ + bool unusedBit_3_21 : 1 {}; + /** + offset 4 bit 22 */ + bool unusedBit_3_22 : 1 {}; + /** + offset 4 bit 23 */ + bool unusedBit_3_23 : 1 {}; + /** + offset 4 bit 24 */ + bool unusedBit_3_24 : 1 {}; + /** + offset 4 bit 25 */ + bool unusedBit_3_25 : 1 {}; + /** + offset 4 bit 26 */ + bool unusedBit_3_26 : 1 {}; + /** + offset 4 bit 27 */ + bool unusedBit_3_27 : 1 {}; + /** + offset 4 bit 28 */ + bool unusedBit_3_28 : 1 {}; + /** + offset 4 bit 29 */ + bool unusedBit_3_29 : 1 {}; + /** + offset 4 bit 30 */ + bool unusedBit_3_30 : 1 {}; + /** + offset 4 bit 31 */ + bool unusedBit_3_31 : 1 {}; +}; +static_assert(sizeof(LuaAdjustments) == 8); + // start of speed_density_s struct speed_density_s { /** @@ -201,186 +306,191 @@ struct engine_state_s { /** * offset 0 */ + LuaAdjustments lua; + /** + * offset 8 + */ speed_density_s sd; - /** - * offset 24 - */ - float targetAFR = (float)0; - /** - * offset 28 - */ - float engineCycleDurationMs = (float)0; /** * offset 32 */ - float minRpmKcurrentTPS = (float)0; + float targetAFR = (float)0; /** * offset 36 */ - int currentTpsAdc = (int)0; + float engineCycleDurationMs = (float)0; /** * offset 40 */ - float tpsVoltageMCU = (float)0; + float minRpmKcurrentTPS = (float)0; /** * offset 44 */ - float tpsVoltageBoard = (float)0; + int currentTpsAdc = (int)0; /** * offset 48 */ - float currentBaroCorrectedVE = (float)0; + float tpsVoltageMCU = (float)0; /** * offset 52 */ - float injectorFlowCorrection = (float)0; + float tpsVoltageBoard = (float)0; /** * offset 56 */ - float baroCorrection = (float)0; + float currentBaroCorrectedVE = (float)0; /** * offset 60 */ + float injectorFlowCorrection = (float)0; + /** + * offset 64 + */ + float baroCorrection = (float)0; + /** + * offset 68 + */ cranking_fuel_s cranking; /** - * offset 80 + * offset 88 */ running_fuel_s running; /** * ignition dwell duration in ms * See also dwellAngle - * offset 108 + * offset 116 */ floatms_t sparkDwell = (floatms_t)0; /** * ignition dwell duration as crankshaft angle * NAN if engine is stopped * See also sparkDwell - * offset 112 + * offset 120 */ angle_t dwellAngle = (angle_t)0; /** deg - * offset 116 + * offset 124 */ scaled_channel cltTimingCorrection = (int16_t)0; /** deg - * offset 118 + * offset 126 */ scaled_channel timingIatCorrection = (int16_t)0; /** deg - * offset 120 + * offset 128 */ scaled_channel timingPidCorrection = (int16_t)0; /** * Detected Board ID id - * offset 122 + * offset 130 */ int16_t hellenBoardId = (int16_t)0; /** * @@INDICATOR_NAME_CLUTCH_UP@@ - offset 124 bit 0 */ + offset 132 bit 0 */ bool clutchUpState : 1 {}; /** * @@INDICATOR_NAME_CLUTCH_DOWN@@ - offset 124 bit 1 */ + offset 132 bit 1 */ bool clutchDownState : 1 {}; /** * @@INDICATOR_NAME_BRAKE_DOWN@@ - offset 124 bit 2 */ + offset 132 bit 2 */ bool brakePedalState : 1 {}; /** - offset 124 bit 3 */ - bool unusedBit_21_3 : 1 {}; + offset 132 bit 3 */ + bool unusedBit_22_3 : 1 {}; /** - offset 124 bit 4 */ - bool unusedBit_21_4 : 1 {}; + offset 132 bit 4 */ + bool unusedBit_22_4 : 1 {}; /** - offset 124 bit 5 */ - bool unusedBit_21_5 : 1 {}; + offset 132 bit 5 */ + bool unusedBit_22_5 : 1 {}; /** - offset 124 bit 6 */ - bool unusedBit_21_6 : 1 {}; + offset 132 bit 6 */ + bool unusedBit_22_6 : 1 {}; /** - offset 124 bit 7 */ - bool unusedBit_21_7 : 1 {}; + offset 132 bit 7 */ + bool unusedBit_22_7 : 1 {}; /** - offset 124 bit 8 */ - bool unusedBit_21_8 : 1 {}; + offset 132 bit 8 */ + bool unusedBit_22_8 : 1 {}; /** - offset 124 bit 9 */ - bool unusedBit_21_9 : 1 {}; + offset 132 bit 9 */ + bool unusedBit_22_9 : 1 {}; /** - offset 124 bit 10 */ - bool unusedBit_21_10 : 1 {}; + offset 132 bit 10 */ + bool unusedBit_22_10 : 1 {}; /** - offset 124 bit 11 */ - bool unusedBit_21_11 : 1 {}; + offset 132 bit 11 */ + bool unusedBit_22_11 : 1 {}; /** - offset 124 bit 12 */ - bool unusedBit_21_12 : 1 {}; + offset 132 bit 12 */ + bool unusedBit_22_12 : 1 {}; /** - offset 124 bit 13 */ - bool unusedBit_21_13 : 1 {}; + offset 132 bit 13 */ + bool unusedBit_22_13 : 1 {}; /** - offset 124 bit 14 */ - bool unusedBit_21_14 : 1 {}; + offset 132 bit 14 */ + bool unusedBit_22_14 : 1 {}; /** - offset 124 bit 15 */ - bool unusedBit_21_15 : 1 {}; + offset 132 bit 15 */ + bool unusedBit_22_15 : 1 {}; /** - offset 124 bit 16 */ - bool unusedBit_21_16 : 1 {}; + offset 132 bit 16 */ + bool unusedBit_22_16 : 1 {}; /** - offset 124 bit 17 */ - bool unusedBit_21_17 : 1 {}; + offset 132 bit 17 */ + bool unusedBit_22_17 : 1 {}; /** - offset 124 bit 18 */ - bool unusedBit_21_18 : 1 {}; + offset 132 bit 18 */ + bool unusedBit_22_18 : 1 {}; /** - offset 124 bit 19 */ - bool unusedBit_21_19 : 1 {}; + offset 132 bit 19 */ + bool unusedBit_22_19 : 1 {}; /** - offset 124 bit 20 */ - bool unusedBit_21_20 : 1 {}; + offset 132 bit 20 */ + bool unusedBit_22_20 : 1 {}; /** - offset 124 bit 21 */ - bool unusedBit_21_21 : 1 {}; + offset 132 bit 21 */ + bool unusedBit_22_21 : 1 {}; /** - offset 124 bit 22 */ - bool unusedBit_21_22 : 1 {}; + offset 132 bit 22 */ + bool unusedBit_22_22 : 1 {}; /** - offset 124 bit 23 */ - bool unusedBit_21_23 : 1 {}; + offset 132 bit 23 */ + bool unusedBit_22_23 : 1 {}; /** - offset 124 bit 24 */ - bool unusedBit_21_24 : 1 {}; + offset 132 bit 24 */ + bool unusedBit_22_24 : 1 {}; /** - offset 124 bit 25 */ - bool unusedBit_21_25 : 1 {}; + offset 132 bit 25 */ + bool unusedBit_22_25 : 1 {}; /** - offset 124 bit 26 */ - bool unusedBit_21_26 : 1 {}; + offset 132 bit 26 */ + bool unusedBit_22_26 : 1 {}; /** - offset 124 bit 27 */ - bool unusedBit_21_27 : 1 {}; + offset 132 bit 27 */ + bool unusedBit_22_27 : 1 {}; /** - offset 124 bit 28 */ - bool unusedBit_21_28 : 1 {}; + offset 132 bit 28 */ + bool unusedBit_22_28 : 1 {}; /** - offset 124 bit 29 */ - bool unusedBit_21_29 : 1 {}; + offset 132 bit 29 */ + bool unusedBit_22_29 : 1 {}; /** - offset 124 bit 30 */ - bool unusedBit_21_30 : 1 {}; + offset 132 bit 30 */ + bool unusedBit_22_30 : 1 {}; /** - offset 124 bit 31 */ - bool unusedBit_21_31 : 1 {}; + offset 132 bit 31 */ + bool unusedBit_22_31 : 1 {}; }; -static_assert(sizeof(engine_state_s) == 128); +static_assert(sizeof(engine_state_s) == 136); // end // this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/algo/engine_state.txt Wed Jun 29 22:14:57 UTC 2022 +// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/algo/engine_state.txt Wed Jun 29 22:24:49 EDT 2022 diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index 5ffb716a3e..703fffe8b7 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -530,7 +530,7 @@ void configureRusefiLuaHooks(lua_State* l) { return 0; }); lua_register(l, "setFuelAdd", [](lua_State* l) { - engine->engineState.luaAdjustments.fuelAdd = luaL_checknumber(l, 1); + engine->engineState.lua.fuelAdd = luaL_checknumber(l, 1); return 0; }); lua_register(l, "setFuelMult", [](lua_State* l) { @@ -549,12 +549,12 @@ void configureRusefiLuaHooks(lua_State* l) { #endif // EFI_PROD_CODE lua_register(l, "setClutchUpState", [](lua_State* l) { - engine->engineState.luaAdjustments.clutchUpState = lua_toboolean(l, 1); + engine->engineState.lua.clutchUpState = lua_toboolean(l, 1); return 0; }); lua_register(l, "setBrakePedalState", [](lua_State* l) { - engine->engineState.luaAdjustments.brakePedalState = lua_toboolean(l, 1); + engine->engineState.lua.brakePedalState = lua_toboolean(l, 1); return 0; });