parent
7121a7bd22
commit
4a1d3de9a6
|
@ -312,7 +312,7 @@ expected<percent_t> EtbController::getOpenLoop(percent_t target) const {
|
||||||
// Don't apply open loop for wastegate/idle valve, only real ETB
|
// Don't apply open loop for wastegate/idle valve, only real ETB
|
||||||
if (m_function != ETB_Wastegate
|
if (m_function != ETB_Wastegate
|
||||||
&& m_function != ETB_IdleValve) {
|
&& m_function != ETB_IdleValve) {
|
||||||
ff = interpolate2d("etbb", target, engineConfiguration->etbBiasBins, engineConfiguration->etbBiasValues);
|
ff = interpolate2d(target, engineConfiguration->etbBiasBins, engineConfiguration->etbBiasValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine->engineState.etbFeedForward = ff;
|
engine->engineState.etbFeedForward = ff;
|
||||||
|
|
|
@ -202,7 +202,7 @@ int IdleController::getTargetRpm(float clt) const {
|
||||||
|
|
||||||
float fsioBump = engine->fsioState.fsioIdleTargetRPMAdjustment;
|
float fsioBump = engine->fsioState.fsioIdleTargetRPMAdjustment;
|
||||||
|
|
||||||
return fsioBump + interpolate2d("cltRpm", clt, CONFIG(cltIdleRpmBins), CONFIG(cltIdleRpm));
|
return fsioBump + interpolate2d(clt, CONFIG(cltIdleRpmBins), CONFIG(cltIdleRpm));
|
||||||
}
|
}
|
||||||
|
|
||||||
IIdleController::Phase IdleController::determinePhase(int rpm, int targetRpm, SensorResult tps) const {
|
IIdleController::Phase IdleController::determinePhase(int rpm, int targetRpm, SensorResult tps) const {
|
||||||
|
@ -233,13 +233,13 @@ IIdleController::Phase IdleController::determinePhase(int rpm, int targetRpm, Se
|
||||||
float IdleController::getCrankingOpenLoop(float clt) const {
|
float IdleController::getCrankingOpenLoop(float clt) const {
|
||||||
return
|
return
|
||||||
CONFIG(crankingIACposition) // Base cranking position (cranking page)
|
CONFIG(crankingIACposition) // Base cranking position (cranking page)
|
||||||
* interpolate2d("cltCrankingT", clt, config->cltCrankingCorrBins, config->cltCrankingCorr);
|
* interpolate2d(clt, config->cltCrankingCorrBins, config->cltCrankingCorr);
|
||||||
}
|
}
|
||||||
|
|
||||||
float IdleController::getRunningOpenLoop(float clt, SensorResult tps) const {
|
float IdleController::getRunningOpenLoop(float clt, SensorResult tps) const {
|
||||||
float running =
|
float running =
|
||||||
CONFIG(manIdlePosition) // Base idle position (slider)
|
CONFIG(manIdlePosition) // Base idle position (slider)
|
||||||
* interpolate2d("cltT", clt, config->cltIdleCorrBins, config->cltIdleCorr);
|
* interpolate2d(clt, config->cltIdleCorrBins, config->cltIdleCorr);
|
||||||
|
|
||||||
// Now we bump it by the AC/fan amount if necessary
|
// Now we bump it by the AC/fan amount if necessary
|
||||||
running += engine->acSwitchState ? CONFIG(acIdleExtraOffset) : 0;
|
running += engine->acSwitchState ? CONFIG(acIdleExtraOffset) : 0;
|
||||||
|
@ -429,7 +429,7 @@ static percent_t automaticIdleController(float tpsPos, float rpm, int targetRpm,
|
||||||
engine->engineState.idle.idleState = PID_UPPER;
|
engine->engineState.idle.idleState = PID_UPPER;
|
||||||
const auto [cltValid, clt] = Sensor::get(SensorType::Clt);
|
const auto [cltValid, clt] = Sensor::get(SensorType::Clt);
|
||||||
if (CONFIG(useIacTableForCoasting) && cltValid) {
|
if (CONFIG(useIacTableForCoasting) && cltValid) {
|
||||||
percent_t iacPosForCoasting = interpolate2d("iacCoasting", clt, CONFIG(iacCoastingBins), CONFIG(iacCoasting));
|
percent_t iacPosForCoasting = interpolate2d(clt, CONFIG(iacCoastingBins), CONFIG(iacCoasting));
|
||||||
newValue = interpolateClamped(idlePidLowerRpm, newValue, idlePidLowerRpm + CONFIG(idlePidRpmUpperLimit), iacPosForCoasting, rpm);
|
newValue = interpolateClamped(idlePidLowerRpm, newValue, idlePidLowerRpm + CONFIG(idlePidRpmUpperLimit), iacPosForCoasting, rpm);
|
||||||
} else {
|
} else {
|
||||||
// Well, just leave it as is, without PID regulation...
|
// Well, just leave it as is, without PID regulation...
|
||||||
|
@ -490,11 +490,11 @@ static percent_t automaticIdleController(float tpsPos, float rpm, int targetRpm,
|
||||||
float cltCorrection;
|
float cltCorrection;
|
||||||
// Use separate CLT correction table for cranking
|
// Use separate CLT correction table for cranking
|
||||||
if (engineConfiguration->overrideCrankingIacSetting && phase == IIdleController::Phase::Cranking) {
|
if (engineConfiguration->overrideCrankingIacSetting && phase == IIdleController::Phase::Cranking) {
|
||||||
cltCorrection = interpolate2d("cltCrankingT", clt, config->cltCrankingCorrBins, config->cltCrankingCorr);
|
cltCorrection = interpolate2d(clt, config->cltCrankingCorrBins, config->cltCrankingCorr);
|
||||||
} else {
|
} else {
|
||||||
// this value would be ignored if running in AUTO mode
|
// this value would be ignored if running in AUTO mode
|
||||||
// but we need it while cranking in AUTO mode
|
// but we need it while cranking in AUTO mode
|
||||||
cltCorrection = interpolate2d("cltT", clt, config->cltIdleCorrBins, config->cltIdleCorr);
|
cltCorrection = interpolate2d(clt, config->cltIdleCorrBins, config->cltIdleCorr);
|
||||||
}
|
}
|
||||||
|
|
||||||
percent_t iacPosition;
|
percent_t iacPosition;
|
||||||
|
|
|
@ -242,7 +242,7 @@ float LoadAccelEnrichment::getEngineLoadEnrichment(DECLARE_ENGINE_PARAMETER_SIGN
|
||||||
if (distance <= 0) // checking if indexes are out of order due to circular buffer nature
|
if (distance <= 0) // checking if indexes are out of order due to circular buffer nature
|
||||||
distance += minI(cb.getCount(), cb.getSize());
|
distance += minI(cb.getCount(), cb.getSize());
|
||||||
|
|
||||||
taper = interpolate2d("accel", distance, engineConfiguration->mapAccelTaperBins, engineConfiguration->mapAccelTaperMult);
|
taper = interpolate2d(distance, engineConfiguration->mapAccelTaperBins, engineConfiguration->mapAccelTaperMult);
|
||||||
|
|
||||||
result = taper * d * engineConfiguration->engineLoadAccelEnrichmentMultiplier;
|
result = taper * d * engineConfiguration->engineLoadAccelEnrichmentMultiplier;
|
||||||
} else if (d < -engineConfiguration->engineLoadDecelEnleanmentThreshold) {
|
} else if (d < -engineConfiguration->engineLoadDecelEnleanmentThreshold) {
|
||||||
|
|
|
@ -83,7 +83,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
|
||||||
|
|
||||||
// get advance from the separate table for Idle
|
// get advance from the separate table for Idle
|
||||||
if (CONFIG(useSeparateAdvanceForIdle) && isIdling()) {
|
if (CONFIG(useSeparateAdvanceForIdle) && isIdling()) {
|
||||||
float idleAdvance = interpolate2d("idleAdvance", rpm, config->idleAdvanceBins, config->idleAdvance);
|
float idleAdvance = interpolate2d(rpm, config->idleAdvanceBins, config->idleAdvance);
|
||||||
|
|
||||||
auto [valid, tps] = Sensor::get(SensorType::DriverThrottleIntent);
|
auto [valid, tps] = Sensor::get(SensorType::DriverThrottleIntent);
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
@ -146,7 +146,7 @@ angle_t getAdvanceCorrections(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
static angle_t getCrankingAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
static angle_t getCrankingAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
// get advance from the separate table for Cranking
|
// get advance from the separate table for Cranking
|
||||||
if (CONFIG(useSeparateAdvanceForCranking)) {
|
if (CONFIG(useSeparateAdvanceForCranking)) {
|
||||||
return interpolate2d("crankingAdvance", rpm, CONFIG(crankingAdvanceBins), CONFIG(crankingAdvance));
|
return interpolate2d(rpm, CONFIG(crankingAdvanceBins), CONFIG(crankingAdvance));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interpolate the cranking timing angle to the earlier running angle for faster engine start
|
// Interpolate the cranking timing angle to the earlier running angle for faster engine start
|
||||||
|
|
|
@ -26,7 +26,7 @@ float AirmassModelBase::getVe(int rpm, float load) const {
|
||||||
auto tps = Sensor::get(SensorType::Tps1);
|
auto tps = Sensor::get(SensorType::Tps1);
|
||||||
// get VE from the separate table for Idle if idling
|
// get VE from the separate table for Idle if idling
|
||||||
if (isIdling() && tps && CONFIG(useSeparateVeForIdle)) {
|
if (isIdling() && tps && CONFIG(useSeparateVeForIdle)) {
|
||||||
float idleVe = interpolate2d("idleVe", rpm, config->idleVeBins, config->idleVe);
|
float idleVe = interpolate2d(rpm, config->idleVeBins, config->idleVe);
|
||||||
// interpolate between idle table and normal (running) table using TPS threshold
|
// interpolate between idle table and normal (running) table using TPS threshold
|
||||||
ve = interpolateClamped(0.0f, idleVe, CONFIG(idlePidDeactivationTpsThreshold), ve, tps.Value);
|
ve = interpolateClamped(0.0f, idleVe, CONFIG(idlePidDeactivationTpsThreshold), ve, tps.Value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
cltTimingCorrection = getCltTimingCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
|
cltTimingCorrection = getCltTimingCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
engineNoiseHipLevel = interpolate2d("knock", rpm, engineConfiguration->knockNoiseRpmBins,
|
engineNoiseHipLevel = interpolate2d(rpm, engineConfiguration->knockNoiseRpmBins,
|
||||||
engineConfiguration->knockNoise);
|
engineConfiguration->knockNoise);
|
||||||
|
|
||||||
baroCorrection = getBaroCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
|
baroCorrection = getBaroCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
|
@ -78,7 +78,6 @@ float InjectorModel::getInjectorMassFlowRate() const {
|
||||||
|
|
||||||
float InjectorModel::getDeadtime() const {
|
float InjectorModel::getDeadtime() const {
|
||||||
return interpolate2d(
|
return interpolate2d(
|
||||||
"lag",
|
|
||||||
ENGINE(sensors.vBatt),
|
ENGINE(sensors.vBatt),
|
||||||
engineConfiguration->injector.battLagCorrBins,
|
engineConfiguration->injector.battLagCorrBins,
|
||||||
engineConfiguration->injector.battLagCorr
|
engineConfiguration->injector.battLagCorr
|
||||||
|
|
|
@ -71,7 +71,7 @@ DISPLAY(DISPLAY_IF(isCrankingState)) float getCrankingFuel3(
|
||||||
* Cranking fuel changes over time
|
* Cranking fuel changes over time
|
||||||
*/
|
*/
|
||||||
DISPLAY_TEXT(Duration_coef);
|
DISPLAY_TEXT(Duration_coef);
|
||||||
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(durationCoefficient) = interpolate2d("crank", revolutionCounterSinceStart, config->crankingCycleBins,
|
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(durationCoefficient) = interpolate2d(revolutionCounterSinceStart, config->crankingCycleBins,
|
||||||
config->crankingCycleCoef);
|
config->crankingCycleCoef);
|
||||||
DISPLAY_TEXT(eol);
|
DISPLAY_TEXT(eol);
|
||||||
|
|
||||||
|
@ -82,21 +82,21 @@ DISPLAY(DISPLAY_IF(isCrankingState)) float getCrankingFuel3(
|
||||||
auto clt = Sensor::get(SensorType::Clt);
|
auto clt = Sensor::get(SensorType::Clt);
|
||||||
DISPLAY_TEXT(Coolant_coef);
|
DISPLAY_TEXT(Coolant_coef);
|
||||||
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(coolantTemperatureCoefficient) =
|
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(coolantTemperatureCoefficient) =
|
||||||
interpolate2d("crank", clt.value_or(20), config->crankingFuelBins, config->crankingFuelCoef);
|
interpolate2d(clt.value_or(20), config->crankingFuelBins, config->crankingFuelCoef);
|
||||||
DISPLAY_SENSOR(CLT);
|
DISPLAY_SENSOR(CLT);
|
||||||
DISPLAY_TEXT(eol);
|
DISPLAY_TEXT(eol);
|
||||||
|
|
||||||
auto tps = Sensor::get(SensorType::DriverThrottleIntent);
|
auto tps = Sensor::get(SensorType::DriverThrottleIntent);
|
||||||
|
|
||||||
DISPLAY_TEXT(TPS_coef);
|
DISPLAY_TEXT(TPS_coef);
|
||||||
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(tpsCoefficient) = tps.Valid ? 1 : interpolate2d("crankTps", tps.Value, engineConfiguration->crankingTpsBins,
|
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(tpsCoefficient) = tps.Valid ? 1 : interpolate2d(tps.Value, engineConfiguration->crankingTpsBins,
|
||||||
engineConfiguration->crankingTpsCoef);
|
engineConfiguration->crankingTpsCoef);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(tpsCoefficient) =
|
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(tpsCoefficient) =
|
||||||
tps.Valid
|
tps.Valid
|
||||||
? interpolate2d("crankTps", tps.Value, engineConfiguration->crankingTpsBins, engineConfiguration->crankingTpsCoef)
|
? interpolate2d(tps.Value, engineConfiguration->crankingTpsBins, engineConfiguration->crankingTpsCoef)
|
||||||
: 1; // in case of failed TPS, don't correct.*/
|
: 1; // in case of failed TPS, don't correct.*/
|
||||||
DISPLAY_SENSOR(TPS);
|
DISPLAY_SENSOR(TPS);
|
||||||
DISPLAY_TEXT(eol);
|
DISPLAY_TEXT(eol);
|
||||||
|
@ -367,7 +367,7 @@ float getCltFuelCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return 1; // this error should be already reported somewhere else, let's just handle it
|
return 1; // this error should be already reported somewhere else, let's just handle it
|
||||||
|
|
||||||
return interpolate2d("cltf", clt, config->cltFuelCorrBins, config->cltFuelCorr);
|
return interpolate2d(clt, config->cltFuelCorrBins, config->cltFuelCorr);
|
||||||
}
|
}
|
||||||
|
|
||||||
angle_t getCltTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
angle_t getCltTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
@ -376,7 +376,7 @@ angle_t getCltTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return 0; // this error should be already reported somewhere else, let's just handle it
|
return 0; // this error should be already reported somewhere else, let's just handle it
|
||||||
|
|
||||||
return interpolate2d("timc", clt, engineConfiguration->cltTimingBins, engineConfiguration->cltTimingExtra);
|
return interpolate2d(clt, engineConfiguration->cltTimingBins, engineConfiguration->cltTimingExtra);
|
||||||
}
|
}
|
||||||
|
|
||||||
float getIatFuelCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
float getIatFuelCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
@ -385,7 +385,7 @@ float getIatFuelCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return 1; // this error should be already reported somewhere else, let's just handle it
|
return 1; // this error should be already reported somewhere else, let's just handle it
|
||||||
|
|
||||||
return interpolate2d("iatc", iat, config->iatFuelCorrBins, config->iatFuelCorr);
|
return interpolate2d(iat, config->iatFuelCorrBins, config->iatFuelCorr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -106,11 +106,11 @@ void recalculateAuxValveTiming(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
engine->engineState.auxValveStart = interpolate2d("aux", tps,
|
engine->engineState.auxValveStart = interpolate2d(tps,
|
||||||
engineConfiguration->fsioCurve1Bins,
|
engineConfiguration->fsioCurve1Bins,
|
||||||
engineConfiguration->fsioCurve1);
|
engineConfiguration->fsioCurve1);
|
||||||
|
|
||||||
engine->engineState.auxValveEnd = interpolate2d("aux", tps,
|
engine->engineState.auxValveEnd = interpolate2d(tps,
|
||||||
engineConfiguration->fsioCurve2Bins,
|
engineConfiguration->fsioCurve2Bins,
|
||||||
engineConfiguration->fsioCurve2);
|
engineConfiguration->fsioCurve2);
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
int rpm = GET_RPM();
|
int rpm = GET_RPM();
|
||||||
if (isValidRpm(rpm)) {
|
if (isValidRpm(rpm)) {
|
||||||
MAP_sensor_config_s * c = &engineConfiguration->map;
|
MAP_sensor_config_s * c = &engineConfiguration->map;
|
||||||
angle_t start = interpolate2d("mapa", rpm, c->samplingAngleBins, c->samplingAngle);
|
angle_t start = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle);
|
||||||
efiAssertVoid(CUSTOM_ERR_MAP_START_ASSERT, !cisnan(start), "start");
|
efiAssertVoid(CUSTOM_ERR_MAP_START_ASSERT, !cisnan(start), "start");
|
||||||
|
|
||||||
angle_t offsetAngle = ENGINE(triggerCentral.triggerFormDetails).eventAngles[CONFIG(mapAveragingSchedulingAtIndex)];
|
angle_t offsetAngle = ENGINE(triggerCentral.triggerFormDetails).eventAngles[CONFIG(mapAveragingSchedulingAtIndex)];
|
||||||
|
@ -245,7 +245,7 @@ void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
fixAngle(cylinderStart, "cylinderStart", CUSTOM_ERR_6562);
|
fixAngle(cylinderStart, "cylinderStart", CUSTOM_ERR_6562);
|
||||||
engine->engineState.mapAveragingStart[i] = cylinderStart;
|
engine->engineState.mapAveragingStart[i] = cylinderStart;
|
||||||
}
|
}
|
||||||
engine->engineState.mapAveragingDuration = interpolate2d("samp", rpm, c->samplingWindowBins, c->samplingWindow);
|
engine->engineState.mapAveragingDuration = interpolate2d(rpm, c->samplingWindowBins, c->samplingWindow);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||||
engine->engineState.mapAveragingStart[i] = NAN;
|
engine->engineState.mapAveragingStart[i] = NAN;
|
||||||
|
|
|
@ -117,7 +117,7 @@ floatms_t getSparkDwell(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
} else {
|
} else {
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN);
|
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN);
|
||||||
|
|
||||||
dwellMs = interpolate2d("dwell", rpm, engineConfiguration->sparkDwellRpmBins, engineConfiguration->sparkDwellValues);
|
dwellMs = interpolate2d(rpm, engineConfiguration->sparkDwellRpmBins, engineConfiguration->sparkDwellValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cisnan(dwellMs) || dwellMs <= 0) {
|
if (cisnan(dwellMs) || dwellMs <= 0) {
|
||||||
|
|
|
@ -130,7 +130,7 @@ float getAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
float volts = getVoltageDivided("ego", sensor->hwChannel PASS_ENGINE_PARAMETER_SUFFIX);
|
float volts = getVoltageDivided("ego", sensor->hwChannel PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
if (CONFIG(afr_type) == ES_NarrowBand) {
|
if (CONFIG(afr_type) == ES_NarrowBand) {
|
||||||
float afr = interpolate2d("narrow", volts, engineConfiguration->narrowToWideOxygenBins, engineConfiguration->narrowToWideOxygen);
|
float afr = interpolate2d(volts, engineConfiguration->narrowToWideOxygenBins, engineConfiguration->narrowToWideOxygen);
|
||||||
#ifdef EFI_NARROW_EGO_AVERAGING
|
#ifdef EFI_NARROW_EGO_AVERAGING
|
||||||
if (useAveraging)
|
if (useAveraging)
|
||||||
afr = updateEgoAverage(afr);
|
afr = updateEgoAverage(afr);
|
||||||
|
|
|
@ -22,7 +22,7 @@ bool hasMafSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
float getRealMaf(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
float getRealMaf(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
float volts = getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE);
|
float volts = getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
return interpolate2d("maf", volts, config->mafDecodingBins, config->mafDecoding);
|
return interpolate2d(volts, config->mafDecodingBins, config->mafDecoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fillTheRest(persistent_config_s *e, int i) {
|
static void fillTheRest(persistent_config_s *e, int i) {
|
||||||
|
|
|
@ -578,9 +578,9 @@ float cjGetAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
float pumpCurrent = (globalInstance.vUa - globalInstance.vUaCal) * globalInstance.amplCoeff * (CJ125_PUMP_CURRENT_FACTOR / CJ125_PUMP_SHUNT_RESISTOR);
|
float pumpCurrent = (globalInstance.vUa - globalInstance.vUaCal) * globalInstance.amplCoeff * (CJ125_PUMP_CURRENT_FACTOR / CJ125_PUMP_SHUNT_RESISTOR);
|
||||||
|
|
||||||
if (engineConfiguration->cj125isLsu49) {
|
if (engineConfiguration->cj125isLsu49) {
|
||||||
globalInstance.lambda = interpolate2d("cj125Lsu", pumpCurrent, pumpCurrentLsu49, lambdaLsu49);
|
globalInstance.lambda = interpolate2d(pumpCurrent, pumpCurrentLsu49, lambdaLsu49);
|
||||||
} else {
|
} else {
|
||||||
globalInstance.lambda = interpolate2d("cj125Lsu", pumpCurrent, pumpCurrentLsu42, lambdaLsu42);
|
globalInstance.lambda = interpolate2d(pumpCurrent, pumpCurrentLsu42, lambdaLsu42);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: make configurable stoich ratio
|
// todo: make configurable stoich ratio
|
||||||
|
|
|
@ -93,7 +93,7 @@ static float linterp(float low, float high, float frac)
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
|
||||||
template <class TBin, class TValue, int TSize>
|
template <class TBin, class TValue, int TSize>
|
||||||
float interpolate2d(const char *msg, const float value, const TBin (&bin)[TSize], const TValue (&values)[TSize]) {
|
float interpolate2d(const float value, const TBin (&bin)[TSize], const TValue (&values)[TSize]) {
|
||||||
// Enforce numeric only (int, float, uintx_t, etc)
|
// Enforce numeric only (int, float, uintx_t, etc)
|
||||||
static_assert(std::is_arithmetic_v<TBin>, "Table values must be an arithmetic type");
|
static_assert(std::is_arithmetic_v<TBin>, "Table values must be an arithmetic type");
|
||||||
|
|
||||||
|
@ -107,11 +107,6 @@ float interpolate2d(const char *msg, const float value, const TBin (&bin)[TSize]
|
||||||
return priv::linterp(low, high, frac);
|
return priv::linterp(low, high, frac);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class TBin, class TValue, int TSize>
|
|
||||||
float interpolate2d(const float value, const TBin (&bin)[TSize], const TValue (&values)[TSize]) {
|
|
||||||
return interpolate2d("", value, bin, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
int needInterpolationLogging(void);
|
int needInterpolationLogging(void);
|
||||||
|
|
||||||
/** @brief Binary search
|
/** @brief Binary search
|
||||||
|
|
|
@ -75,19 +75,19 @@ TEST(misc, testInterpolate2d) {
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
printf("Left size\r\n");
|
printf("Left size\r\n");
|
||||||
result = interpolate2d("t", 0, bins4, values4);
|
result = interpolate2d(0, bins4, values4);
|
||||||
ASSERT_EQ(1, result);
|
ASSERT_EQ(1, result);
|
||||||
|
|
||||||
printf("Right size\r\n");
|
printf("Right size\r\n");
|
||||||
result = interpolate2d("t", 10, bins4, values4);
|
result = interpolate2d(10, bins4, values4);
|
||||||
ASSERT_EQ(400, result);
|
ASSERT_EQ(400, result);
|
||||||
|
|
||||||
printf("Middle1\r\n");
|
printf("Middle1\r\n");
|
||||||
result = interpolate2d("t", 3, bins4, values4);
|
result = interpolate2d(3, bins4, values4);
|
||||||
ASSERT_EQ(30, result);
|
ASSERT_EQ(30, result);
|
||||||
|
|
||||||
printf("Middle1\r\n");
|
printf("Middle1\r\n");
|
||||||
result = interpolate2d("t", 3.5, bins4, values4);
|
result = interpolate2d(3.5, bins4, values4);
|
||||||
ASSERT_EQ(215, result);
|
ASSERT_EQ(215, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue