diff --git a/firmware/util/containers/table_helper.h b/firmware/util/containers/table_helper.h index 6c65db35bf..c7f71fa14f 100644 --- a/firmware/util/containers/table_helper.h +++ b/firmware/util/containers/table_helper.h @@ -52,7 +52,7 @@ public: } // todo: we have a bit of a mess: in TunerStudio, RPM is X-axis - return interpolate3d(y, loadBins, LOAD_BIN_SIZE, xRpm, rpmBins, RPM_BIN_SIZE, pointers) * TValueMultiplier::asFloat(); + return interpolate3d(name, y, loadBins, LOAD_BIN_SIZE, xRpm, rpmBins, RPM_BIN_SIZE, pointers) * TValueMultiplier::asFloat(); } void setAll(vType value) { diff --git a/firmware/util/math/interpolation.h b/firmware/util/math/interpolation.h index 4c90f632d0..fef3a42ccf 100644 --- a/firmware/util/math/interpolation.h +++ b/firmware/util/math/interpolation.h @@ -173,7 +173,7 @@ int findIndexMsgExt(const char *msg, const kType array[], int size, kType value) * @brief Two-dimensional table lookup with linear interpolation */ template -float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kType yBin[], int yBinSize, const vType* const map[]) { +float interpolate3d(const char *msg, float x, const kType xBin[], int xBinSize, float y, const kType yBin[], int yBinSize, const vType* const map[]) { if (cisnan(x)) { warning(CUSTOM_INTEPOLATE_ERROR_3, "%.2f: x is NaN in interpolate3d", x); return NAN; @@ -209,7 +209,7 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT float rpmMinValue = map[0][yIndex]; float rpmMaxValue = map[0][yIndex + 1]; - return interpolateMsg("3d", keyMin, rpmMinValue, keyMax, rpmMaxValue, y); + return interpolateMsg(msg, keyMin, rpmMinValue, keyMax, rpmMaxValue, y); } if (yIndex < 0) { @@ -224,7 +224,7 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT float value1 = map[xIndex][0]; float value2 = map[xIndex + 1][0]; - return interpolateMsg("out3d", key1, value1, key2, value2, x); + return interpolateMsg(msg, key1, value1, key2, value2, x); } if (xIndex == xBinSize - 1 && yIndex == yBinSize - 1) { @@ -247,7 +247,7 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT float value1 = map[xIndex][yIndex]; float value2 = map[xIndex][yIndex + 1]; - return interpolateMsg("out3d", key1, value1, key2, value2, y); + return interpolateMsg(msg, key1, value1, key2, value2, y); } if (yIndex == yBinSize - 1) { @@ -262,7 +262,7 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT float value1 = map[xIndex][yIndex]; float value2 = map[xIndex + 1][yIndex]; - return interpolateMsg("out3d", key1, value1, key2, value2, x); + return interpolateMsg(msg, key1, value1, key2, value2, x); } /* @@ -275,7 +275,7 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT float rpmMinKeyMinValue = map[xIndex][yIndex]; float rpmMaxKeyMinValue = map[xIndex + 1][yIndex]; - float keyMinValue = interpolateMsg("", xMin, rpmMinKeyMinValue, xMax, rpmMaxKeyMinValue, x); + float keyMinValue = interpolateMsg(msg, xMin, rpmMinKeyMinValue, xMax, rpmMaxKeyMinValue, x); #if DEBUG_INTERPOLATION if (needInterpolationLogging()) { @@ -290,7 +290,7 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT float rpmMinKeyMaxValue = map[xIndex][keyMaxIndex]; float rpmMaxKeyMaxValue = map[rpmMaxIndex][keyMaxIndex]; - float keyMaxValue = interpolateMsg("3d", xMin, rpmMinKeyMaxValue, xMax, rpmMaxKeyMaxValue, x); + float keyMaxValue = interpolateMsg(msg, xMin, rpmMinKeyMaxValue, xMax, rpmMaxKeyMaxValue, x); #if DEBUG_INTERPOLATION if (needInterpolationLogging()) { @@ -303,7 +303,7 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT } #endif /* DEBUG_INTERPOLATION */ - return interpolateMsg("3d", keyMin, keyMinValue, keyMax, keyMaxValue, y); + return interpolateMsg(msg, keyMin, keyMinValue, keyMax, keyMaxValue, y); } void setCurveValue(float bins[], float values[], int size, float key, float value); void initInterpolation(Logging *sharedLogger); diff --git a/unit_tests/test_basic_math/test_interpolation_3d.cpp b/unit_tests/test_basic_math/test_interpolation_3d.cpp index 1e03d5cc4e..055c98596f 100644 --- a/unit_tests/test_basic_math/test_interpolation_3d.cpp +++ b/unit_tests/test_basic_math/test_interpolation_3d.cpp @@ -24,7 +24,7 @@ float *map[5] = { map0, map1, map2, map3, map4 }; static float getValue(float rpm, float maf) { - return interpolate3d(rpm, rpmBins, 5, maf, mafBins, 4, map); + return interpolate3d("test", rpm, rpmBins, 5, maf, mafBins, 4, map); } static void newTestToComfirmInterpolation() {