2020-07-05 23:07:22 -07:00
|
|
|
#pragma once
|
2019-06-17 09:18:55 -07:00
|
|
|
#include "rusefi_types.h"
|
2022-06-29 20:34:00 -07:00
|
|
|
struct LuaAdjustments {
|
2023-05-04 13:37:23 -07:00
|
|
|
// Lua: Fuel add
|
|
|
|
// g
|
2023-03-27 01:38:48 -07:00
|
|
|
// offset 0
|
2022-06-29 20:34:00 -07:00
|
|
|
float fuelAdd = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
2023-05-04 13:37:23 -07:00
|
|
|
// Lua: Fuel mult
|
2023-03-27 01:38:48 -07:00
|
|
|
// offset 4
|
2022-06-30 10:53:57 -07:00
|
|
|
float fuelMult = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 0
|
2022-06-29 20:34:00 -07:00
|
|
|
bool clutchUpState : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 1
|
2022-06-29 20:34:00 -07:00
|
|
|
bool brakePedalState : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 2
|
2022-07-07 21:45:52 -07:00
|
|
|
bool acRequestState : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 3
|
2022-11-15 06:34:13 -08:00
|
|
|
bool luaDisableEtb : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 4
|
2023-01-02 14:53:56 -08:00
|
|
|
bool luaIgnCut : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 5
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_5 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 6
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_6 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 7
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_7 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 8
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_8 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 9
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_9 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 10
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_10 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 11
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_11 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 12
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_12 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 13
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_13 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 14
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_14 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 15
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_15 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 16
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_16 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 17
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_17 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 18
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_18 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 19
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_19 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 20
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_20 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 21
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_21 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 22
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_22 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 23
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_23 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 24
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_24 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 25
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_25 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 26
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_26 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 27
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_27 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 28
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_28 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 29
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_29 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 30
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_30 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8 bit 31
|
2023-01-02 14:53:56 -08:00
|
|
|
bool unusedBit_7_31 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
2022-06-29 20:34:00 -07:00
|
|
|
};
|
2022-06-30 10:53:57 -07:00
|
|
|
static_assert(sizeof(LuaAdjustments) == 12);
|
2022-06-29 20:34:00 -07:00
|
|
|
|
2019-06-19 19:34:11 -07:00
|
|
|
struct speed_density_s {
|
2023-03-27 01:38:48 -07:00
|
|
|
// speed density
|
|
|
|
// Rate-of-change limiter is applied to degrees, so we store both Kelvin and degrees.
|
|
|
|
// offset 0
|
2019-07-21 14:06:16 -07:00
|
|
|
float tCharge = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 4
|
2019-07-21 14:06:16 -07:00
|
|
|
float tChargeK = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8
|
2019-07-21 14:06:16 -07:00
|
|
|
floatms_t airFlow = (floatms_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
2019-06-19 19:34:11 -07:00
|
|
|
};
|
2022-09-03 04:44:24 -07:00
|
|
|
static_assert(sizeof(speed_density_s) == 12);
|
2019-06-19 19:34:11 -07:00
|
|
|
|
2019-08-26 20:41:04 -07:00
|
|
|
struct cranking_fuel_s {
|
2023-03-27 01:38:48 -07:00
|
|
|
// Fuel: base duration
|
|
|
|
// Duration of injection, in ms. During cranking we do not account for injector flow, so if you change injectors you would need to change settings.
|
|
|
|
// Deprecated. Please use '1'.
|
|
|
|
// TODO: maybe account for injector flow?
|
|
|
|
// offset 0
|
2019-08-26 20:41:04 -07:00
|
|
|
floatms_t baseFuel = (floatms_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// Cranking: CLT coefficient
|
|
|
|
// offset 4
|
2019-08-26 20:41:04 -07:00
|
|
|
float coolantTemperatureCoefficient = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 8
|
2019-08-26 20:41:04 -07:00
|
|
|
float tpsCoefficient = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 12
|
2019-08-26 20:41:04 -07:00
|
|
|
float durationCoefficient = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// Fuel: Actual injection
|
|
|
|
// duration based on all coefficients.
|
|
|
|
// offset 16
|
2019-08-26 20:41:04 -07:00
|
|
|
floatms_t fuel = (floatms_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
2019-08-26 20:41:04 -07:00
|
|
|
};
|
2022-04-17 13:30:07 -07:00
|
|
|
static_assert(sizeof(cranking_fuel_s) == 20);
|
2019-08-26 20:41:04 -07:00
|
|
|
|
2022-04-13 17:45:52 -07:00
|
|
|
struct engine_state_s {
|
2023-03-27 01:38:48 -07:00
|
|
|
// offset 0
|
2022-06-29 20:34:00 -07:00
|
|
|
LuaAdjustments lua;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 12
|
2019-06-19 19:34:11 -07:00
|
|
|
speed_density_s sd;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 24
|
2019-07-21 14:06:16 -07:00
|
|
|
float engineCycleDurationMs = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 28
|
2019-07-21 14:06:16 -07:00
|
|
|
float minRpmKcurrentTPS = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 32
|
2022-10-28 01:36:50 -07:00
|
|
|
uint32_t currentTpsAdc = (uint32_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 36
|
2019-07-21 14:06:16 -07:00
|
|
|
float tpsVoltageMCU = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 40
|
2019-07-21 14:06:16 -07:00
|
|
|
float tpsVoltageBoard = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 44
|
2019-07-21 14:06:16 -07:00
|
|
|
float currentBaroCorrectedVE = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 48
|
2019-09-24 15:39:26 -07:00
|
|
|
float injectorFlowCorrection = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// @@GAUGE_NAME_FUEL_BARO_CORR@@
|
|
|
|
// offset 52
|
2019-08-26 20:41:04 -07:00
|
|
|
float baroCorrection = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 56
|
2022-11-02 19:21:44 -07:00
|
|
|
cranking_fuel_s crankingFuel;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// Detected Board ID
|
|
|
|
// id
|
|
|
|
// offset 76
|
2022-06-28 23:06:27 -07:00
|
|
|
int16_t hellenBoardId = (int16_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// need 4 byte alignment
|
|
|
|
// units
|
|
|
|
// offset 78
|
2023-01-14 20:28:54 -08:00
|
|
|
uint8_t alignmentFill_at_78[2];
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// @@INDICATOR_NAME_CLUTCH_UP@@
|
|
|
|
// offset 80 bit 0
|
2022-06-29 00:27:51 -07:00
|
|
|
bool clutchUpState : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// @@INDICATOR_NAME_CLUTCH_DOWN@@
|
|
|
|
// offset 80 bit 1
|
2022-06-29 00:27:51 -07:00
|
|
|
bool clutchDownState : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// @@INDICATOR_NAME_BRAKE_DOWN@@
|
|
|
|
// offset 80 bit 2
|
2022-06-29 00:27:51 -07:00
|
|
|
bool brakePedalState : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 3
|
2022-10-06 16:24:19 -07:00
|
|
|
bool startStopState : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 4
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_4 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 5
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_5 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 6
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_6 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 7
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_7 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 8
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_8 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 9
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_9 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 10
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_10 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 11
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_11 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 12
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_12 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 13
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_13 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 14
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_14 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 15
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_15 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 16
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_16 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 17
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_17 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 18
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_18 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 19
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_19 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 20
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_20 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 21
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_21 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 22
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_22 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 23
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_23 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 24
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_24 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 25
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_25 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 26
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_26 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 27
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_27 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 28
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_28 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 29
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_29 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 30
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_30 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 80 bit 31
|
2023-01-14 20:28:54 -08:00
|
|
|
bool unusedBit_17_31 : 1 {};
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 84
|
2022-10-28 01:36:50 -07:00
|
|
|
uint32_t startStopStateToggleCounter = (uint32_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 88
|
2022-11-02 19:21:44 -07:00
|
|
|
float egtValue1 = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 92
|
2022-11-02 19:21:44 -07:00
|
|
|
float egtValue2 = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// User-defined RPM hard limit
|
|
|
|
// rpm
|
|
|
|
// offset 96
|
2022-08-22 15:32:47 -07:00
|
|
|
int16_t desiredRpmLimit = (int16_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// need 4 byte alignment
|
|
|
|
// units
|
|
|
|
// offset 98
|
2023-01-14 20:28:54 -08:00
|
|
|
uint8_t alignmentFill_at_98[2];
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 100
|
2022-10-28 01:36:50 -07:00
|
|
|
uint32_t fuelInjectionCounter = (uint32_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// offset 104
|
2022-10-28 01:36:50 -07:00
|
|
|
uint32_t sparkCounter = (uint32_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// @@GAUGE_NAME_FUEL_LOAD@@
|
|
|
|
// offset 108
|
2022-09-04 19:44:56 -07:00
|
|
|
float fuelingLoad = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// @@GAUGE_NAME_IGNITION_LOAD@@
|
|
|
|
// offset 112
|
2022-09-04 19:44:56 -07:00
|
|
|
float ignitionLoad = (float)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// %
|
|
|
|
// offset 116
|
2022-11-05 17:28:03 -07:00
|
|
|
scaled_channel<uint16_t, 100, 1> veTableYAxis = (uint16_t)0;
|
2023-03-27 01:38:48 -07:00
|
|
|
|
|
|
|
// need 4 byte alignment
|
|
|
|
// units
|
|
|
|
// offset 118
|
2023-01-14 20:28:54 -08:00
|
|
|
uint8_t alignmentFill_at_118[2];
|
2023-03-27 01:38:48 -07:00
|
|
|
|
2019-06-17 09:18:55 -07:00
|
|
|
};
|
2023-01-14 20:28:54 -08:00
|
|
|
static_assert(sizeof(engine_state_s) == 120);
|
2019-06-17 09:18:55 -07:00
|
|
|
|