more detailed warning

This commit is contained in:
rusefi 2018-06-12 05:45:11 -04:00
parent 9158dc22f2
commit e3dfcc4df9
11 changed files with 15 additions and 20 deletions

View File

@ -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)

View File

@ -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);
}

View File

@ -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;

View File

@ -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()) {

View File

@ -733,5 +733,5 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20180531;
return 20180612;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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));