parent
63b2a08234
commit
823a5ea3ad
|
@ -160,19 +160,13 @@ int table2D_getValue(struct table2D *fromTable, int X_in)
|
||||||
int16_t yMax = table2D_getRawValue(fromTable, xMax);
|
int16_t yMax = table2D_getRawValue(fromTable, xMax);
|
||||||
int16_t yMin = table2D_getRawValue(fromTable, xMin);
|
int16_t yMin = table2D_getRawValue(fromTable, xMin);
|
||||||
|
|
||||||
//Float version
|
/* Float version (if m, yMax, yMin and n were float's)
|
||||||
/*
|
int yVal = (m * (yMax - yMin)) / n;
|
||||||
int yVal = (m / n) * (abs(yMax - yMin));
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Non-Float version
|
//Non-Float version
|
||||||
int16_t yVal = ((long)(m << 6) / n) * (abs(yMax - yMin));
|
int16_t yVal = ( ((int32_t) m) * (yMax-yMin) ) / n;
|
||||||
yVal = (yVal >> 6);
|
returnValue = yMin + yVal;
|
||||||
|
|
||||||
if (yMax > yMin) { yVal = yMin + yVal; }
|
|
||||||
else { yVal = yMin - yVal; }
|
|
||||||
|
|
||||||
returnValue = yVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fromTable->lastInput = X_in;
|
fromTable->lastInput = X_in;
|
||||||
|
|
Loading…
Reference in New Issue