From e3dfcc4df910e033788a3eb838db2b8754d737db Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 12 Jun 2018 05:45:11 -0400 Subject: [PATCH] more detailed warning --- firmware/controllers/algo/advance_map.cpp | 2 +- firmware/controllers/algo/engine.cpp | 2 +- firmware/controllers/core/interpolation.cpp | 6 +----- firmware/controllers/core/interpolation.h | 3 +-- firmware/controllers/engine_controller.cpp | 2 +- firmware/controllers/math/speed_density.cpp | 6 +++--- firmware/controllers/sensors/ego.cpp | 2 +- firmware/controllers/sensors/map.cpp | 4 ++-- firmware/controllers/sensors/oil_pressure.cpp | 2 +- firmware/controllers/sensors/thermistors.cpp | 2 +- firmware/controllers/sensors/tps.cpp | 4 ++-- 11 files changed, 15 insertions(+), 20 deletions(-) diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index 7f6a5f7222..7ba7f73f2d 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -215,7 +215,7 @@ float getAdvanceForRpm(int rpm, float advanceMax) { return advanceMax; if (rpm < 600) return 10; - return interpolate(600, 10, 3000, advanceMax, rpm); + return interpolateMsg("advance", 600, 10, 3000, advanceMax, rpm); } #define round10(x) efiRound(x, 0.1) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index e67cadc607..15394cf410 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -73,7 +73,7 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // todo: move this logic somewhere to sensors folder? if (engineConfiguration->fuelLevelSensor != EFI_ADC_NONE) { float fuelLevelVoltage = getVoltageDivided("fuel", engineConfiguration->fuelLevelSensor); - sensors.fuelTankGauge = interpolate(boardConfiguration->fuelLevelEmptyTankVoltage, 0, + sensors.fuelTankGauge = interpolateMsg("fgauge", boardConfiguration->fuelLevelEmptyTankVoltage, 0, boardConfiguration->fuelLevelFullTankVoltage, 100, fuelLevelVoltage); } diff --git a/firmware/controllers/core/interpolation.cpp b/firmware/controllers/core/interpolation.cpp index 223655f685..b3b3d41409 100644 --- a/firmware/controllers/core/interpolation.cpp +++ b/firmware/controllers/core/interpolation.cpp @@ -100,7 +100,7 @@ float FastInterpolation::getValue(float x) { * @param y2 value of the second point * @param X key to be interpolated * - * @note For example, "interpolate(engineConfiguration.tpsMin, 0, engineConfiguration.tpsMax, 100, adc);" + * @note For example, "interpolateMsg("", engineConfiguration.tpsMin, 0, engineConfiguration.tpsMax, 100, adc);" */ float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x) { // todo: double comparison using EPS @@ -125,10 +125,6 @@ float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, fl return result; } -float interpolate(float x1, float y1, float x2, float y2, float x) { - return interpolateMsg("", x1, y1, x2, y2, x); -} - float interpolateClamped(float x1, float y1, float x2, float y2, float x) { if (x <= x1) return y1; diff --git a/firmware/controllers/core/interpolation.h b/firmware/controllers/core/interpolation.h index a728c2dc52..7c98363230 100644 --- a/firmware/controllers/core/interpolation.h +++ b/firmware/controllers/core/interpolation.h @@ -24,7 +24,6 @@ int findIndex(const float array[], int size, float value); int findIndexMsg(const char *msg, const float array[], int size, float value); void ensureArrayIsAscending(const char *msg, const float array[], int size); int findIndex2(const float array[], unsigned size, float value); -float interpolate(float x1, float y1, float x2, float y2, float x); float interpolateClamped(float x1, float y1, float x2, float y2, float x); float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x); float interpolate2d(const char *msg, float value, float bin[], float values[], int size); @@ -119,7 +118,7 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[], float rpmMinKeyMinValue = map[xIndex][yIndex]; float rpmMaxKeyMinValue = map[xIndex + 1][yIndex]; - float keyMinValue = interpolate(xMin, rpmMinKeyMinValue, xMax, rpmMaxKeyMinValue, x); + float keyMinValue = interpolateMsg("", xMin, rpmMinKeyMinValue, xMax, rpmMaxKeyMinValue, x); #if DEBUG_INTERPOLATION if (needInterpolationLogging()) { diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 0ddc4b8100..11e7a92ebd 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -733,5 +733,5 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 20180531; + return 20180612; } diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index e4c7fafe21..bf7ceeb41c 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -32,12 +32,12 @@ float getTCharge(int rpm, float tps, float coolantTemp, float airTemp DECLARE_EN warning(CUSTOM_ERR_6147, "t-getTCharge NaN"); return coolantTemp; } - float minRpmKcurrentTPS = interpolate(tpMin, engineConfiguration->tChargeMinRpmMinTps, tpMax, + float minRpmKcurrentTPS = interpolateMsg("minRpm", tpMin, engineConfiguration->tChargeMinRpmMinTps, tpMax, engineConfiguration->tChargeMinRpmMaxTps, tps); - float maxRpmKcurrentTPS = interpolate(tpMin, engineConfiguration->tChargeMaxRpmMinTps, tpMax, + float maxRpmKcurrentTPS = interpolateMsg("maxRpm", tpMin, engineConfiguration->tChargeMaxRpmMinTps, tpMax, engineConfiguration->tChargeMaxRpmMaxTps, tps); - float Tcharge_coff = interpolate(rpmMin, minRpmKcurrentTPS, rpmMax, maxRpmKcurrentTPS, rpm); + float Tcharge_coff = interpolateMsg("Kcurr", rpmMin, minRpmKcurrentTPS, rpmMax, maxRpmKcurrentTPS, rpm); if (cisnan(Tcharge_coff)) { warning(CUSTOM_ERR_6148, "t2-getTCharge NaN"); return coolantTemp; diff --git a/firmware/controllers/sensors/ego.cpp b/firmware/controllers/sensors/ego.cpp index 9502c421bc..b08cb0edcf 100644 --- a/firmware/controllers/sensors/ego.cpp +++ b/firmware/controllers/sensors/ego.cpp @@ -121,7 +121,7 @@ float getAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #endif } - return interpolate(sensor->v1, sensor->value1, sensor->v2, sensor->value2, volts) + return interpolateMsg("AFR", sensor->v1, sensor->value1, sensor->v2, sensor->value2, volts) + engineConfiguration->egoValueShift; } diff --git a/firmware/controllers/sensors/map.cpp b/firmware/controllers/sensors/map.cpp index cc30e64ad4..05fe3ba2f3 100644 --- a/firmware/controllers/sensors/map.cpp +++ b/firmware/controllers/sensors/map.cpp @@ -83,7 +83,7 @@ float decodePressure(float voltage, air_pressure_sensor_config_s * mapConfig DEC switch (mapConfig->type) { case MT_CUSTOM: // todo: migrate to 'FastInterpolation customMap' - return interpolate(engineConfiguration->mapLowValueVoltage, mapConfig->lowValue, + return interpolateMsg("map", engineConfiguration->mapLowValueVoltage, mapConfig->lowValue, engineConfiguration->mapHighValueVoltage, mapConfig->highValue, voltage); case MT_DENSO183: case MT_MPX4250: @@ -146,7 +146,7 @@ float getMapByVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX) { */ float getRawMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (engineConfiguration->hasFrequencyReportingMapSensor) { - return interpolate(boardConfiguration->mapFrequency0Kpa, 0, boardConfiguration->mapFrequency100Kpa, 100, mapFreq); + return interpolateMsg("rmap", boardConfiguration->mapFrequency0Kpa, 0, boardConfiguration->mapFrequency100Kpa, 100, mapFreq); } float voltage = getVoltageDivided("map", engineConfiguration->map.sensor.hwChannel); diff --git a/firmware/controllers/sensors/oil_pressure.cpp b/firmware/controllers/sensors/oil_pressure.cpp index 08dec51f1f..57b1f51924 100644 --- a/firmware/controllers/sensors/oil_pressure.cpp +++ b/firmware/controllers/sensors/oil_pressure.cpp @@ -23,5 +23,5 @@ float getOilPressure(DECLARE_ENGINE_PARAMETER_SIGNATURE) { float volts = getVoltageDivided("oilp", sensor->hwChannel); - return interpolate(sensor->v1, sensor->value1, sensor->v2, sensor->value2, volts); + return interpolateMsg("oil", sensor->v1, sensor->value1, sensor->v2, sensor->value2, volts); } diff --git a/firmware/controllers/sensors/thermistors.cpp b/firmware/controllers/sensors/thermistors.cpp index 0ac06dfdc9..835b364e4a 100644 --- a/firmware/controllers/sensors/thermistors.cpp +++ b/firmware/controllers/sensors/thermistors.cpp @@ -86,7 +86,7 @@ float getTemperatureC(ThermistorConf *config, ThermistorMath *tm, bool useLinear // should work as a short term fix. // todo: move 'useLinearXXXSensor' into termistor configuration record // yes, we use 'resistance' setting for 'voltage' here - return interpolate(config->config.resistance_1, config->config.tempC_1, + return interpolateMsg("temp", config->config.resistance_1, config->config.tempC_1, config->config.resistance_2, config->config.tempC_2, voltage); diff --git a/firmware/controllers/sensors/tps.cpp b/firmware/controllers/sensors/tps.cpp index b46dfa692a..cf3f96edfe 100644 --- a/firmware/controllers/sensors/tps.cpp +++ b/firmware/controllers/sensors/tps.cpp @@ -76,7 +76,7 @@ percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_SUFFIX) { warning(CUSTOM_INVALID_TPS_SETTING, "Invalid TPS configuration: same value %d", engineConfiguration->tpsMin); return NAN; } - float result = interpolate(TPS_TS_CONVERSION * engineConfiguration->tpsMax, 100, TPS_TS_CONVERSION * engineConfiguration->tpsMin, 0, adc); + float result = interpolateMsg("TPS", TPS_TS_CONVERSION * engineConfiguration->tpsMax, 100, TPS_TS_CONVERSION * engineConfiguration->tpsMin, 0, adc); if (result < engineConfiguration->tpsErrorDetectionTooLow) { #if EFI_PROD_CODE || defined(__DOXYGEN__) // too much noise with simulator @@ -142,7 +142,7 @@ percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_SIGNATURE) { return mockPedalPosition; } float voltage = getVoltageDivided("pPS", engineConfiguration->pedalPositionChannel); - float result = interpolate(engineConfiguration->throttlePedalUpVoltage, 0, engineConfiguration->throttlePedalWOTVoltage, 100, voltage); + float result = interpolateMsg("pedal", engineConfiguration->throttlePedalUpVoltage, 0, engineConfiguration->throttlePedalWOTVoltage, 100, voltage); // this would put the value into the 0-100 range return maxF(0, minF(100, result));