auto-sync

This commit is contained in:
rusEfi 2015-03-18 21:05:22 -05:00
parent 032a12edca
commit 961716d6c2
1 changed files with 15 additions and 9 deletions

View File

@ -219,13 +219,13 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
int xIndex = findIndex(xBin, xBinSize, x);
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("X index=%d\r\n", xIndex);
printf("X index=%d\r\n", xIndex);
#endif
int yIndex = findIndex(yBin, yBinSize, y);
if (xIndex < 0 && yIndex < 0) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("X and Y are smaller than smallest cell in table: %d\r\n", xIndex);
printf("X and Y are smaller than smallest cell in table: %d\r\n", xIndex);
#endif
return map[0][0];
}
@ -233,16 +233,22 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
if (xIndex < 0) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("X is smaller than smallest cell in table: %dr\n", xIndex);
printf("X is smaller than smallest cell in table: %dr\n", xIndex);
#endif
// no interpolation should be fine here.
return map[0][yIndex];
if (yIndex == yBinSize - 1)
return map[0][yIndex];
float keyMin = yBin[yIndex];
float keyMax = yBin[yIndex + 1];
float rpmMinValue = map[0][yIndex];
float rpmMaxValue = map[0][yIndex + 1];
return interpolate(keyMin, rpmMinValue, keyMax, rpmMaxValue, y);
}
if (yIndex < 0) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("Y is smaller than smallest cell in table: %d\r\n", yIndex);
printf("Y is smaller than smallest cell in table: %d\r\n", yIndex);
#endif
// no interpolation should be fine here.
return map[xIndex][0];
@ -251,7 +257,7 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
if (xIndex == xBinSize - 1 && yIndex == yBinSize - 1) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("X and Y are larger than largest cell in table: %d %d\r\n", xIndex, yIndex);
printf("X and Y are larger than largest cell in table: %d %d\r\n", xIndex, yIndex);
#endif
return map[xBinSize - 1][yBinSize - 1];
}
@ -259,7 +265,7 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
if (xIndex == xBinSize - 1) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("TODO BETTER LOGGING x overflow %d\r\n", yIndex);
printf("TODO BETTER LOGGING x overflow %d\r\n", yIndex);
#endif
// todo: implement better handling - y interpolation
return map[xBinSize - 1][yIndex];
@ -268,7 +274,7 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
if (yIndex == yBinSize - 1) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("Y is larger than largest cell in table: %d\r\n", yIndex);
printf("Y is larger than largest cell in table: %d\r\n", yIndex);
#endif
// todo: implement better handling - x interpolation
return map[xIndex][yBinSize - 1];