Merge pull request #112 from FarmBot/scaling_overflow_bug_fix

fix encoder scaling overflow bug
pull/119/head
Connor Rigby 2019-10-22 10:54:03 -07:00 committed by GitHub
commit b52b0e4c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;