diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index fe8f0114ca..c461f5bca6 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -94,15 +94,15 @@ void Engine::initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUF void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { int rpm = rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE); isEngineChartEnabled = CONFIG(isEngineChartEnabled) && rpm < CONFIG(engineSnifferRpmThreshold); - sensorChartMode = rpm < CONFIG(sensorSnifferRpmThreshold) ? boardConfiguration->sensorChartMode : SC_OFF; + sensorChartMode = rpm < CONFIG(sensorSnifferRpmThreshold) ? CONFIGB(sensorChartMode) : SC_OFF; engineState.updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE); // todo: move this logic somewhere to sensors folder? if (CONFIG(fuelLevelSensor) != EFI_ADC_NONE) { float fuelLevelVoltage = getVoltageDivided("fuel", engineConfiguration->fuelLevelSensor); - sensors.fuelTankGauge = interpolateMsg("fgauge", boardConfiguration->fuelLevelEmptyTankVoltage, 0, - boardConfiguration->fuelLevelFullTankVoltage, 100, + sensors.fuelTankGauge = interpolateMsg("fgauge", CONFIGB(fuelLevelEmptyTankVoltage), 0, + CONFIGB(fuelLevelFullTankVoltage), 100, fuelLevelVoltage); } sensors.vBatt = hasVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) ? getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) : 12; diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index b2acbb68b1..35734124b5 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -134,7 +134,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // todo: move this into slow callback, no reason for IAT corr to be here iatFuelCorrection = getIatFuelCorrection(engine->sensors.iat PASS_ENGINE_PARAMETER_SUFFIX); // todo: move this into slow callback, no reason for CLT corr to be here - if (boardConfiguration->useWarmupPidAfr && engine->sensors.clt < engineConfiguration->warmupAfrThreshold) { + if (CONFIGB(useWarmupPidAfr) && engine->sensors.clt < engineConfiguration->warmupAfrThreshold) { if (rpm < 200) { cltFuelCorrection = 1; warmupAfrPid.reset(); @@ -193,7 +193,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (CONFIG(useSeparateVeForIdle)) { float idleVe = interpolate2d("idleVe", rpm, config->idleVeBins, config->idleVe, IDLE_VE_CURVE_SIZE); // interpolate between idle table and normal (running) table using TPS threshold - rawVe = interpolateClamped(0.0f, idleVe, boardConfiguration->idlePidDeactivationTpsThreshold, rawVe, tps); + rawVe = interpolateClamped(0.0f, idleVe, CONFIGB(idlePidDeactivationTpsThreshold), rawVe, tps); } currentVE = baroCorrection * rawVe * 0.01; targetAFR = afrMap.getValue(rpm, map); diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 5b2e4d9f8e..8db61f0e17 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -636,7 +636,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #endif prepareVoidConfiguration(engineConfiguration); - boardConfiguration->mafSensorType = Bosch0280218037; + CONFIGB(mafSensorType) = Bosch0280218037; setBosch0280218037(config); setBosch02880155868(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -646,7 +646,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } - boardConfiguration->mapMinBufferLength = 1; + CONFIGB(mapMinBufferLength) = 1; engineConfiguration->idlePidRpmDeadZone = 50; engineConfiguration->startOfCrankingPrimingPulse = 0; diff --git a/firmware/controllers/global_shared.h b/firmware/controllers/global_shared.h index fd7e02d2d3..a301fb5947 100644 --- a/firmware/controllers/global_shared.h +++ b/firmware/controllers/global_shared.h @@ -48,6 +48,7 @@ * optimization which is hopefully useful at least for anything trigger-related */ #define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x +#define CONFIGB(x) persistentState.persistentConfiguration.engineConfiguration.bc.x #define DEFINE_CONFIG_PARAM(x, y) diff --git a/unit_tests/global.h b/unit_tests/global.h index 01e30b4930..41c2e18fe4 100644 --- a/unit_tests/global.h +++ b/unit_tests/global.h @@ -91,6 +91,7 @@ class Engine; EXPAND_Engine #define CONFIG(x) engineConfiguration->x +#define CONFIGB(x) engine->engineConfigurationPtr->bc.x #define ENGINE(x) engine->x #define CONFIG_PARAM(x) (x)