fix encoder scaling overflow bug

pull/112/head
gabrielburnworth 2019-04-24 19:01:07 -07:00
parent 2c30fb1df3
commit f7de42d3a2
2 changed files with 5 additions and 2 deletions

View File

@ -106,9 +106,11 @@ long StepperControlEncoder::currentPosition()
else
{
#if defined(FARMDUINO_V14)
return position * scalingFactor / 40000 * encoderInvert;
floatScalingFactor = scalingFactor / 40000.0;
return position * floatScalingFactor * encoderInvert;
#endif
return position * scalingFactor / 10000 * encoderInvert;
floatScalingFactor = scalingFactor / 10000.0;
return position * floatScalingFactor * encoderInvert;
}
}

View File

@ -61,6 +61,7 @@ private:
// encoder
long position;
long scalingFactor;
float floatScalingFactor;
int encoderType;
int encoderInvert;