diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index 4ccaec8317..e1e33b50e3 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -902,11 +902,11 @@ void proteusLuaDemo() { engineConfiguration->luaOutputPins[1] = Gpio::D10; engineConfiguration->luaOutputPins[2] = Gpio::D11; - setLinearCurve(engineConfiguration->scriptCurve2Bins, 0, 8000, 1); - setLinearCurve(engineConfiguration->scriptCurve2, 0, 100, 1); + setLinearCurve(config->scriptCurve2Bins, 0, 8000, 1); + setLinearCurve(config->scriptCurve2, 0, 100, 1); - copyArray(engineConfiguration->scriptCurve3Bins, defaultBiasBins); - copyArray(engineConfiguration->scriptCurve3, defaultBiasValues); + copyArray(config->scriptCurve3Bins, defaultBiasBins); + copyArray(config->scriptCurve3, defaultBiasValues); engineConfiguration->auxAnalogInputs[0] = PROTEUS_IN_ANALOG_VOLT_10; engineConfiguration->afr.hwChannel = EFI_ADC_NONE; diff --git a/firmware/config/engines/mazda_miata_base_maps.cpp b/firmware/config/engines/mazda_miata_base_maps.cpp index d35929f0ca..3ecff49845 100644 --- a/firmware/config/engines/mazda_miata_base_maps.cpp +++ b/firmware/config/engines/mazda_miata_base_maps.cpp @@ -23,8 +23,8 @@ static const float hardCodediacCoasting[16] = {40.0, 40.0, 40.0, 40.0, 40.0, 40. /* Generated by TS2C on Fri Jul 31 14:02:18 EDT 2020*/ void miataNA_setIacCoastingBins() { - copyArray(engineConfiguration->iacCoastingBins, hardCodediacCoastingBins); - copyArray(engineConfiguration->iacCoasting, hardCodediacCoasting); + copyArray(config->iacCoastingBins, hardCodediacCoastingBins); + copyArray(config->iacCoasting, hardCodediacCoasting); } static const float hardCodedcltIdleCorrBins[16] = {-40.0, -30.0, -20.0, -10.0, 0.0, 9.439941, 19.120117, 30.810059, 42.509766, 54.529785, 64.21973, 71.90039, 80.0, 90.0, 100.0, 110.0}; @@ -43,8 +43,8 @@ static const float hardCodedcltIdleRpm[16] = {1180.0, 1150.0, 1130.0, 1110.0, 10 /* Generated by TS2C on Fri Jul 31 14:02:18 EDT 2020*/ void miataNA_setCltIdleRpmBins() { - copyArray(engineConfiguration->cltIdleRpmBins, hardCodedcltIdleRpmBins); - copyArray(engineConfiguration->cltIdleRpm, hardCodedcltIdleRpm); + copyArray(config->cltIdleRpmBins, hardCodedcltIdleRpmBins); + copyArray(config->cltIdleRpm, hardCodedcltIdleRpm); } static const float hardCodedignitionLoadBins[16] = {10.0, 24.0, 35.0, 55.0, 65.0, 75.0, 84.0, 99.0, 110.0, 125.0, 140.0, 160.0, 180.0, 200.0, 220.0, 250.0}; diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 8b1139867c..dfbea03b33 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -24,7 +24,7 @@ #endif int IdleController::getTargetRpm(float clt) { - targetRpmByClt = interpolate2d(clt, engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm); + targetRpmByClt = interpolate2d(clt, config->cltIdleRpmBins, config->cltIdleRpm); // Bump for AC targetRpmAcBump = engine->acSwitchState ? engineConfiguration->acIdleRpmBump : 0; @@ -124,7 +124,7 @@ percent_t IdleController::getOpenLoop(Phase phase, float clt, SensorResult tps, // TODO: this should be a table of open loop mult vs. RPM, not vs. clt useIacTableForCoasting = engineConfiguration->useIacTableForCoasting && phase == Phase::Coasting; if (useIacTableForCoasting) { - return interpolate2d(clt, engineConfiguration->iacCoastingBins, engineConfiguration->iacCoasting); + return interpolate2d(clt, config->iacCoastingBins, config->iacCoasting); } percent_t running = getRunningOpenLoop(clt, tps); @@ -255,9 +255,9 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos, if (engineConfiguration->useIacPidMultTable) { float engineLoad = getFuelingLoad(); float multCoef = interpolate3d( - engineConfiguration->iacPidMultTable, - engineConfiguration->iacPidMultLoadBins, engineLoad, - engineConfiguration->iacPidMultRpmBins, rpm + config->iacPidMultTable, + config->iacPidMultLoadBins, engineLoad, + config->iacPidMultRpmBins, rpm ); // PID can be completely disabled of multCoef==0, or it just works as usual if multCoef==1 newValue = interpolateClamped(0, 0, 1, newValue, multCoef); diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index f10c75fbc3..6d78c23213 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -114,7 +114,7 @@ angle_t getAdvanceCorrections(int rpm) { static angle_t getCrankingAdvance(int rpm, float engineLoad) { // get advance from the separate table for Cranking if (engineConfiguration->useSeparateAdvanceForCranking) { - return interpolate2d(rpm, engineConfiguration->crankingAdvanceBins, engineConfiguration->crankingAdvance); + return interpolate2d(rpm, config->crankingAdvanceBins, config->crankingAdvance); } // Interpolate the cranking timing angle to the earlier running angle for faster engine start diff --git a/firmware/controllers/algo/defaults/default_cranking.cpp b/firmware/controllers/algo/defaults/default_cranking.cpp index fdceed14dc..736e84f280 100644 --- a/firmware/controllers/algo/defaults/default_cranking.cpp +++ b/firmware/controllers/algo/defaults/default_cranking.cpp @@ -28,8 +28,8 @@ void setDefaultCranking() { engineConfiguration->postCrankingDurationSec = 10; - setLinearCurve(engineConfiguration->crankingTpsCoef, /*from*/1, /*to*/1, 1); - setLinearCurve(engineConfiguration->crankingTpsBins, 0, 100, 1); + setLinearCurve(config->crankingTpsCoef, /*from*/1, /*to*/1, 1); + setLinearCurve(config->crankingTpsBins, 0, 100, 1); setLinearCurve(config->cltCrankingCorrBins, CLT_CURVE_RANGE_FROM, 100, 1); setLinearCurve(config->cltCrankingCorr, 1.0, 1.0, 1); @@ -75,10 +75,10 @@ void setDefaultCranking() { // Cranking ignition timing static const float advanceValues[] = { 0, 0, 0, 0 }; - copyArray(engineConfiguration->crankingAdvance, advanceValues); + copyArray(config->crankingAdvance, advanceValues); static const float advanceBins[] = { 0, 200, 400, 1000 }; - copyArray(engineConfiguration->crankingAdvanceBins, advanceBins); + copyArray(config->crankingAdvanceBins, advanceBins); engineConfiguration->useTLE8888_cranking_hack = true; } diff --git a/firmware/controllers/algo/defaults/default_fuel.cpp b/firmware/controllers/algo/defaults/default_fuel.cpp index f69a8b3dcc..856f2a84e9 100644 --- a/firmware/controllers/algo/defaults/default_fuel.cpp +++ b/firmware/controllers/algo/defaults/default_fuel.cpp @@ -87,12 +87,12 @@ static void setDefaultVETable() { setRpmTableBin(config->lambdaRpmBins, FUEL_RPM_COUNT); - setRpmTableBin(engineConfiguration->baroCorrRpmBins, BARO_CORR_SIZE); - setLinearCurve(engineConfiguration->baroCorrPressureBins, 75, 105, 1); + setRpmTableBin(config->baroCorrRpmBins, BARO_CORR_SIZE); + setLinearCurve(config->baroCorrPressureBins, 75, 105, 1); for (int i = 0; i < BARO_CORR_SIZE;i++) { for (int j = 0; j < BARO_CORR_SIZE;j++) { // Default baro table is all 1.0, we can't recommend a reasonable default here - engineConfiguration->baroCorrTable[i][j] = 1; + config->baroCorrTable[i][j] = 1; } } } diff --git a/firmware/controllers/algo/defaults/default_ignition.cpp b/firmware/controllers/algo/defaults/default_ignition.cpp index ad89c6eac2..f9e7fe1563 100644 --- a/firmware/controllers/algo/defaults/default_ignition.cpp +++ b/firmware/controllers/algo/defaults/default_ignition.cpp @@ -112,8 +112,8 @@ void setDefaultIgnition() { engineConfiguration->trailingSparkAngle = 10; // CLT correction - setLinearCurve(engineConfiguration->cltTimingBins, CLT_CURVE_RANGE_FROM, 120, 1); - setArrayValues(engineConfiguration->cltTimingExtra, 0.0f); + setLinearCurve(config->cltTimingBins, CLT_CURVE_RANGE_FROM, 120, 1); + setArrayValues(config->cltTimingExtra, 0.0f); // IAT correction setDefaultIatTimingCorrection(); diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index c3fc6455aa..bb48b207be 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -213,9 +213,9 @@ void incrementGlobalConfigurationVersion() { */ void setConstantDwell(floatms_t dwellMs) { for (int i = 0; i < DWELL_CURVE_SIZE; i++) { - engineConfiguration->sparkDwellRpmBins[i] = 1000 * i; + config->sparkDwellRpmBins[i] = 1000 * i; } - setArrayValues(engineConfiguration->sparkDwellValues, dwellMs); + setArrayValues(config->sparkDwellValues, dwellMs); } void setWholeIgnitionIatCorr(float value) { @@ -331,23 +331,23 @@ static void setDefaultWarmupIdleCorrection() { * see also setTargetRpmCurve() */ static void setDefaultIdleSpeedTarget() { - setLinearCurve(engineConfiguration->cltIdleRpmBins, CLT_CURVE_RANGE_FROM, 140, 10); + setLinearCurve(config->cltIdleRpmBins, CLT_CURVE_RANGE_FROM, 140, 10); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, -30, 1350); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, -20, 1300); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, -10, 1200); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 0, 1150); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 10, 1100); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 20, 1050); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 30, 1000); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 40, 1000); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 50, 950); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 60, 950); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 70, 930); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 80, 900); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 90, 900); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 100, 1000); - setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 110, 1100); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, -30, 1350); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, -20, 1300); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, -10, 1200); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 0, 1150); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 10, 1100); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 20, 1050); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 30, 1000); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 40, 1000); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 50, 950); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 60, 950); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 70, 930); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 80, 900); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 90, 900); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 100, 1000); + setCurveValue(config->cltIdleRpmBins, config->cltIdleRpm, CLT_CURVE_SIZE, 110, 1100); } static void setDefaultFrankensoStepperIdleParameters() { @@ -367,8 +367,8 @@ static void setCanFrankensoDefaults() { * see also setDefaultIdleSpeedTarget() */ void setTargetRpmCurve(int rpm) { - setLinearCurve(engineConfiguration->cltIdleRpmBins, CLT_CURVE_RANGE_FROM, 140, 10); - setLinearCurve(engineConfiguration->cltIdleRpm, rpm, rpm, 10); + setLinearCurve(config->cltIdleRpmBins, CLT_CURVE_RANGE_FROM, 140, 10); + setLinearCurve(config->cltIdleRpm, rpm, rpm, 10); } void setDefaultGppwmParameters() { @@ -529,16 +529,16 @@ static void setDefaultEngineConfiguration() { engineConfiguration->alternatorControl.minValue = 0; engineConfiguration->alternatorControl.maxValue = 90; - setLinearCurve(engineConfiguration->scriptCurve1Bins, 0, 100, 1); - setLinearCurve(engineConfiguration->scriptCurve1, 0, 100, 1); + setLinearCurve(config->scriptCurve1Bins, 0, 100, 1); + setLinearCurve(config->scriptCurve1, 0, 100, 1); - setLinearCurve(engineConfiguration->scriptCurve2Bins, 0, 100, 1); - setLinearCurve(engineConfiguration->scriptCurve2, 30, 170, 1); + setLinearCurve(config->scriptCurve2Bins, 0, 100, 1); + setLinearCurve(config->scriptCurve2, 30, 170, 1); - setLinearCurve(engineConfiguration->scriptCurve3Bins, 0, 100, 1); - setLinearCurve(engineConfiguration->scriptCurve4Bins, 0, 100, 1); - setLinearCurve(engineConfiguration->scriptCurve5Bins, 0, 100, 1); - setLinearCurve(engineConfiguration->scriptCurve6Bins, 0, 100, 1); + setLinearCurve(config->scriptCurve3Bins, 0, 100, 1); + setLinearCurve(config->scriptCurve4Bins, 0, 100, 1); + setLinearCurve(config->scriptCurve5Bins, 0, 100, 1); + setLinearCurve(config->scriptCurve6Bins, 0, 100, 1); #if EFI_ENGINE_CONTROL setDefaultWarmupIdleCorrection(); @@ -1143,7 +1143,7 @@ void validateConfiguration() { * negative zeros altogether. Unfortunately default configuration had one and here we are mitigating that. */ for (int i = 0;i < CLT_CURVE_SIZE;i++) { - engineConfiguration->cltIdleRpmBins[i] = fixNegativeZero(engineConfiguration->cltIdleRpmBins[i]); + config->cltIdleRpmBins[i] = fixNegativeZero(config->cltIdleRpmBins[i]); } } diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 9f19b39f89..39c3d66ce6 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -94,7 +94,7 @@ float getCrankingFuel3( auto tps = Sensor::get(SensorType::DriverThrottleIntent); engine->engineState.cranking.tpsCoefficient = tps.Valid - ? interpolate2d(tps.Value, engineConfiguration->crankingTpsBins, engineConfiguration->crankingTpsCoef) + ? interpolate2d(tps.Value, config->crankingTpsBins, config->crankingTpsCoef) : 1; // in case of failed TPS, don't correct. floatms_t crankingFuel = baseCrankingFuel @@ -358,7 +358,7 @@ angle_t getCltTimingCorrection() { if (!valid) return 0; // this error should be already reported somewhere else, let's just handle it - return interpolate2d(clt, engineConfiguration->cltTimingBins, engineConfiguration->cltTimingExtra); + return interpolate2d(clt, config->cltTimingBins, config->cltTimingExtra); } float getIatFuelCorrection() { @@ -376,9 +376,9 @@ float getBaroCorrection() { float pressure = Sensor::get(SensorType::BarometricPressure).value_or(101.325f); float correction = interpolate3d( - engineConfiguration->baroCorrTable, - engineConfiguration->baroCorrPressureBins, pressure, - engineConfiguration->baroCorrRpmBins, Sensor::getOrZero(SensorType::Rpm) + config->baroCorrTable, + config->baroCorrPressureBins, pressure, + config->baroCorrRpmBins, Sensor::getOrZero(SensorType::Rpm) ); if (cisnan(correction) || correction < 0.01) { diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index 3fa6400ee6..0e0222511e 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -65,17 +65,17 @@ float getCurveValue(int index, float key) { // not great code at all :( switch (index) { default: - return interpolate2d(key, engineConfiguration->scriptCurve1Bins, engineConfiguration->scriptCurve1); + return interpolate2d(key, config->scriptCurve1Bins, config->scriptCurve1); case 1: - return interpolate2d(key, engineConfiguration->scriptCurve2Bins, engineConfiguration->scriptCurve2); + return interpolate2d(key, config->scriptCurve2Bins, config->scriptCurve2); case 2: - return interpolate2d(key, engineConfiguration->scriptCurve3Bins, engineConfiguration->scriptCurve3); + return interpolate2d(key, config->scriptCurve3Bins, config->scriptCurve3); case 3: - return interpolate2d(key, engineConfiguration->scriptCurve4Bins, engineConfiguration->scriptCurve4); + return interpolate2d(key, config->scriptCurve4Bins, config->scriptCurve4); case 4: - return interpolate2d(key, engineConfiguration->scriptCurve5Bins, engineConfiguration->scriptCurve5); + return interpolate2d(key, config->scriptCurve5Bins, config->scriptCurve5); case 5: - return interpolate2d(key, engineConfiguration->scriptCurve6Bins, engineConfiguration->scriptCurve6); + return interpolate2d(key, config->scriptCurve6Bins, config->scriptCurve6); } } diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index db6719046e..074c0230b4 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -589,12 +589,12 @@ bool validateConfig() { // Ignition { - ensureArrayIsAscending("Dwell RPM", engineConfiguration->sparkDwellRpmBins); + ensureArrayIsAscending("Dwell RPM", config->sparkDwellRpmBins); ensureArrayIsAscending("Ignition load", config->ignitionLoadBins); ensureArrayIsAscending("Ignition RPM", config->ignitionRpmBins); - ensureArrayIsAscending("Ignition CLT corr", engineConfiguration->cltTimingBins); + ensureArrayIsAscending("Ignition CLT corr", config->cltTimingBins); ensureArrayIsAscending("Ignition IAT corr IAT", config->ignitionIatCorrLoadBins); ensureArrayIsAscending("Ignition IAT corr RPM", config->ignitionIatCorrRpmBins); @@ -610,12 +610,12 @@ bool validateConfig() { // Cranking tables ensureArrayIsAscending("Cranking fuel mult", config->crankingFuelBins); ensureArrayIsAscending("Cranking duration", config->crankingCycleBins); - ensureArrayIsAscending("Cranking TPS", engineConfiguration->crankingTpsBins); + ensureArrayIsAscending("Cranking TPS", config->crankingTpsBins); // Idle tables - ensureArrayIsAscending("Idle target RPM", engineConfiguration->cltIdleRpmBins); + ensureArrayIsAscending("Idle target RPM", config->cltIdleRpmBins); ensureArrayIsAscending("Idle warmup mult", config->cltIdleCorrBins); - ensureArrayIsAscendingOrDefault("Idle coasting position", engineConfiguration->iacCoastingBins); + ensureArrayIsAscendingOrDefault("Idle coasting position", config->iacCoastingBins); ensureArrayIsAscendingOrDefault("Idle VE RPM", config->idleVeRpmBins); ensureArrayIsAscendingOrDefault("Idle VE Load", config->idleVeLoadBins); ensureArrayIsAscendingOrDefault("Idle timing", config->idleAdvanceBins); diff --git a/firmware/controllers/engine_cycle/aux_valves.cpp b/firmware/controllers/engine_cycle/aux_valves.cpp index a168ca0453..feec6ae885 100644 --- a/firmware/controllers/engine_cycle/aux_valves.cpp +++ b/firmware/controllers/engine_cycle/aux_valves.cpp @@ -88,12 +88,12 @@ void recalculateAuxValveTiming() { } engine->engineState.auxValveStart = interpolate2d(tps, - engineConfiguration->scriptCurve1Bins, - engineConfiguration->scriptCurve1); + config->scriptCurve1Bins, + config->scriptCurve1); engine->engineState.auxValveEnd = interpolate2d(tps, - engineConfiguration->scriptCurve2Bins, - engineConfiguration->scriptCurve2); + config->scriptCurve2Bins, + config->scriptCurve2); if (engine->engineState.auxValveStart >= engine->engineState.auxValveEnd) { // this is a fatal error to make this really visible diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 37ff324c7d..5dc2ca5751 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -56,18 +56,18 @@ float getIgnitionLoad() { */ void setSingleCoilDwell() { for (int i = 0; i < DWELL_CURVE_SIZE; i++) { - engineConfiguration->sparkDwellRpmBins[i] = (i + 1) * 50; - engineConfiguration->sparkDwellValues[i] = 4; + config->sparkDwellRpmBins[i] = (i + 1) * 50; + config->sparkDwellValues[i] = 4; } - engineConfiguration->sparkDwellRpmBins[5] = 500; - engineConfiguration->sparkDwellValues[5] = 4; + config->sparkDwellRpmBins[5] = 500; + config->sparkDwellValues[5] = 4; - engineConfiguration->sparkDwellRpmBins[6] = 4500; - engineConfiguration->sparkDwellValues[6] = 4; + config->sparkDwellRpmBins[6] = 4500; + config->sparkDwellValues[6] = 4; - engineConfiguration->sparkDwellRpmBins[7] = 12500; - engineConfiguration->sparkDwellValues[7] = 0; + config->sparkDwellRpmBins[7] = 12500; + config->sparkDwellValues[7] = 0; } /** @@ -81,7 +81,7 @@ floatms_t IgnitionState::getSparkDwell(int rpm) { } else { efiAssert(CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN); - baseDwell = interpolate2d(rpm, engineConfiguration->sparkDwellRpmBins, engineConfiguration->sparkDwellValues); + baseDwell = interpolate2d(rpm, config->sparkDwellRpmBins, config->sparkDwellValues); dwellVoltageCorrection = interpolate2d( Sensor::getOrZero(SensorType::BatteryVoltage), engineConfiguration->dwellVoltageCorrVoltBins, diff --git a/firmware/controllers/sensors/ego.cpp b/firmware/controllers/sensors/ego.cpp index 606906be13..b8a8ff37a7 100644 --- a/firmware/controllers/sensors/ego.cpp +++ b/firmware/controllers/sensors/ego.cpp @@ -126,7 +126,7 @@ float getAfr() { float volts = getVoltageDivided("ego", sensor->hwChannel); if (engineConfiguration->afr_type == ES_NarrowBand) { - float afr = interpolate2d(volts, engineConfiguration->narrowToWideOxygenBins, engineConfiguration->narrowToWideOxygen); + float afr = interpolate2d(volts, config->narrowToWideOxygenBins, config->narrowToWideOxygen); #ifdef EFI_NARROW_EGO_AVERAGING if (useAveraging) afr = updateEgoAverage(afr); diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 2bacad22f7..5107d844f1 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -981,11 +981,11 @@ static void getValue(const char *paramStr) { } static void setScriptCurve1Value(float value) { - setLinearCurve(engineConfiguration->scriptCurve1, value, value, 1); + setLinearCurve(config->scriptCurve1, value, value, 1); } static void setScriptCurve2Value(float value) { - setLinearCurve(engineConfiguration->scriptCurve2, value, value, 1); + setLinearCurve(config->scriptCurve2, value, value, 1); } struct command_i_s { diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 71bf00e5b2..d0f8c3bc6c 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -86,13 +86,13 @@ ! so not forget to change fileVersion in rusefi.ini ! todo: this not needed in light of TS_SIGNATURE but rusEFI console still uses it. Need to migrate ! rusEFI console from TS_FILE_VERSION to TS_SIGNATURE :( -#define TS_FILE_VERSION 20210310 +#define TS_FILE_VERSION 20210311 ! This is the version of the data stored in flash configuration ! Any time an incompatible change is made to the configuration format stored in flash, ! update this string to the current date! It is required to also update TS_SIGNATURE above ! when this happens. -#define FLASH_DATA_VERSION 10010 +#define FLASH_DATA_VERSION 10011 #define LOG_DELIMITER "`" @@ -441,10 +441,6 @@ uint8_t autoscale engineSnifferRpmThreshold;Engine sniffer would be disabled abo uint8_t multisparkMaxExtraSparkCount;+Configures the maximum number of extra sparks to fire (does not include main spark);"count", 1, 0, 1, 5, 0 - -uint8_t[DWELL_CURVE_SIZE] autoscale sparkDwellRpmBins;On Single Coil or Wasted Spark setups you have to lower dwell at high RPM;"RPM", @@RPM_1_BYTE_PACKING_MULT@@, 0, 0, 18000, 2 - float[DWELL_CURVE_SIZE] sparkDwellValues;;"ms", 1, 0, 0, 30, 2 - struct injector_s float flow;+This is your injector flow at the fuel pressure used in the vehicle. cc/min, cubic centimetre per minute\nBy the way, g/s = 0.125997881 * (lb/hr)\ng/s = 0.125997881 * (cc/min)/10.5\ng/s = 0.0119997981 * cc/min;"cm3/min", 1, 0, 0, 99999, 2 float[VBAT_INJECTOR_CURVE_SIZE] battLagCorrBins;set_flat_injector_lag LAG\nset_injector_lag VOLTAGE LAG;"volts", 1, 0, 0, 20, 2 @@ -1114,18 +1110,11 @@ float noAccelAfterHardLimitPeriodSecs;TODO: finish this #413;"sec", 1, 0, 0, 60, int mapAveragingSchedulingAtIndex;+At what trigger index should some MAP-related math be executed? This is a performance trick to reduce load on synchronization trigger callback.;"index", 1, 0, 0, 7000, 0 -float[BARO_CORR_SIZE] baroCorrPressureBins;;"kPa", 1, 0, 0, 200, 2 -float[BARO_CORR_SIZE] baroCorrRpmBins;;"RPM", 1, 0, 0, 18000, 2 -float[BARO_CORR_SIZE x BARO_CORR_SIZE] baroCorrTable;;"ratio", 1, 0, 0, 2, 2 - #define pin_mode_e_enum "default", "INVALID", "INVALID", "INVALID", "opendrain", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PULLUP", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PULLDOWN" custom pin_mode_e 1 bits, U08, @OFFSET@, [0:6], @@pin_mode_e_enum@@ - - float[CRANKING_CURVE_SIZE] crankingTpsCoef;Cranking fuel correction coefficient based on TPS;"Ratio", 1, 0, 0, 700, 2 - float[CRANKING_CURVE_SIZE] crankingTpsBins;;"%", 1, 0, 0, 100, 2 - + ! todo: rename field remove 'ms', also fix typo in name should be 'tachPulseDuration' and that would be an incompatible breaking change for users :( float tachPulseDuractionMs;+Duration in ms or duty cycle depending on selected mode;"", 1, 0, 0, 100, 2 @@ -1165,9 +1154,6 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\ int16_t startUpFuelPumpDuration;+on ECU start turn fuel pump on to build fuel pressure;"seconds", 1, 0, 0, 6000, 0 int16_t idlePidRpmDeadZone;+If the RPM closer to target than this value, disable closed loop idle correction to prevent oscillation;"RPM", 1, 0, 0, 200, 0 - - float[CLT_CURVE_SIZE] cltIdleRpmBins;CLT-based target RPM for automatic idle controller;"C", 1, 0, -100, 250, 2 - uint8_t[CLT_CURVE_SIZE] autoscale cltIdleRpm;See idleRpmPid;"RPM", @@RPM_1_BYTE_PACKING_MULT@@, 0, 0, 8000, 0 float targetVBatt;+This is the target battery voltage the alternator PID control will attempt to maintain;"Volts", 1, 0, 0, 30, 1 float alternatorOffAboveTps;+Turns off alternator output above specified TPS, enabling this reduced parasitic drag on the engine at full load.;"%", 1, 0, 0, 200, 2 @@ -1275,8 +1261,6 @@ custom pwm_freq_t 2 scalar, U16, @OFFSET@, "Hz", 1, 0, 0, 3000, 0 uint8_t fan1ExtraIdle;+Additional idle % when fan #1 is active;"%", 1, 0, 0, 100, 0 int alternatorPwmFrequency;;"Hz", 1, 0, 0, 3000, 0 - float[NARROW_BAND_WIDE_BAND_CONVERSION_SIZE] narrowToWideOxygenBins;Narrow Band WBO Approximation;"V", 1, 0, -10, 10, 3 - float[NARROW_BAND_WIDE_BAND_CONVERSION_SIZE] narrowToWideOxygen;;"ratio", 1, 0, -40, 40, 2 vvt_mode_e[CAMS_PER_BANK iterate] vvtMode;set vvt_mode X uint8_t[CAMS_PER_BANK_padding] vvtModePadding;; @@ -1285,8 +1269,6 @@ custom pwm_freq_t 2 scalar, U16, @OFFSET@, "Hz", 1, 0, 0, 3000, 0 adc_channel_e[AUX_ANALOG_INPUT_COUNT iterate] auxAnalogInputs; output_pin_e[MAX_CYLINDER_COUNT iterate] trailingCoilPins; - float[CLT_TIMING_CURVE_SIZE] cltTimingBins;CLT-based timing correction;"C", 1, 0, -100, 250, 1 - float[CLT_TIMING_CURVE_SIZE] cltTimingExtra;;"degree", 1, 0, -400, 400, 0 custom tle8888_mode_e 1 bits, U08, @OFFSET@, [0:1], "Auto", "SemiAuto", "Manual", "Hall" tle8888_mode_e tle8888mode; @@ -1350,25 +1332,15 @@ custom stepper_num_micro_steps_e 1 bits, U08, @OFFSET@, [0:3], @@stepper_num_mic output_pin_e fan2Pin; uint8_t fan2OnTemperature;+Cooling fan turn-on temperature threshold, in Celsius;"deg C", 1, 0, 0, 150, 0 uint8_t fan2OffTemperature;+Cooling fan turn-off temperature threshold, in Celsius;"deg C", 1, 0, 0, 150, 0 + #define SCRIPT_CURVE_COUNT 6 #define SCRIPT_TABLE_COUNT 4 - float[SCRIPT_CURVE_16] scriptCurve1Bins;;"x", 1, 0, -999, 1000, 3 - float[SCRIPT_CURVE_16] scriptCurve1;;"y", 1, 0, -999, 1000, 3 - float[SCRIPT_CURVE_16] scriptCurve2Bins;;"x", 1, 0, -999, 1000, 3 - float[SCRIPT_CURVE_16] scriptCurve2;;"y", 1, 0, -999, 1000, 3 - float[SCRIPT_CURVE_8] scriptCurve3Bins;;"x", 1, 0, -999, 1000, 3 - float[SCRIPT_CURVE_8] scriptCurve3;;"y", 1, 0, -999, 1000, 3 - float[SCRIPT_CURVE_8] scriptCurve4Bins;;"x", 1, 0, -999, 1000, 3 - float[SCRIPT_CURVE_8] scriptCurve4;;"y", 1, 0, -999, 1000, 3 Gpio stepperEnablePin; Gpio tle8888_cs; pin_output_mode_e tle8888_csPinMode; Gpio mc33816_cs; -float[CRANKING_ADVANCE_CURVE_SIZE] crankingAdvanceBins;+Optional timing advance table for Cranking (see useSeparateAdvanceForCranking);"RPM", 1, 0, 0, 18000, 2 -float[CRANKING_ADVANCE_CURVE_SIZE] crankingAdvance ;+Optional timing advance table for Cranking (see useSeparateAdvanceForCranking);"deg", 1, 0, -20, 90, 2 - Gpio[SERVO_COUNT iterate] servoOutputPins;todo: more comments int16_t coastingFuelCutRpmHigh;+This sets the RPM above which fuel cut is active.;"rpm", 1, 0, 0, 5000, 0 @@ -1379,8 +1351,6 @@ float[CRANKING_ADVANCE_CURVE_SIZE] crankingAdvance ;+Optional timing advance int16_t pidExtraForLowRpm;+Increases PID reaction for RPMscriptCurveName[3], "hello"); - setLinearCurve(engineConfiguration->scriptCurve4, 500, 600, 1); + setLinearCurve(config->scriptCurve4, 500, 600, 1); int index = getCurveIndexByName("helLO"); ASSERT_EQ(index, 3); diff --git a/unit_tests/tests/test_idle_controller.cpp b/unit_tests/tests/test_idle_controller.cpp index 95881865c1..225b94bde6 100644 --- a/unit_tests/tests/test_idle_controller.cpp +++ b/unit_tests/tests/test_idle_controller.cpp @@ -55,9 +55,9 @@ TEST(idle_v2, testTargetRpm) { EngineTestHelper eth(TEST_ENGINE); IdleController dut; - for (size_t i = 0; i < efi::size(engineConfiguration->cltIdleRpmBins); i++) { - engineConfiguration->cltIdleRpmBins[i] = i * 10; - engineConfiguration->cltIdleRpm[i] = i * 100; + for (size_t i = 0; i < efi::size(config->cltIdleRpmBins); i++) { + config->cltIdleRpmBins[i] = i * 10; + config->cltIdleRpm[i] = i * 100; } EXPECT_FLOAT_EQ(100, dut.getTargetRpm(10)); @@ -285,8 +285,8 @@ TEST(idle_v2, openLoopCoastingTable) { // enable & configure feature engineConfiguration->useIacTableForCoasting = true; for (size_t i = 0; i < CLT_CURVE_SIZE; i++) { - engineConfiguration->iacCoastingBins[i] = 10 * i; - engineConfiguration->iacCoasting[i] = 5 * i; + config->iacCoastingBins[i] = 10 * i; + config->iacCoasting[i] = 5 * i; } EXPECT_FLOAT_EQ(10, dut.getOpenLoop(ICP::Coasting, 20, 0, 2));