aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256
diff options
context:
space:
mode:
authorNicolas Schodet2011-01-31 01:15:16 +0100
committerNicolas Schodet2011-02-09 00:55:56 +0100
commit8a96ebc7aed6c6af5ced04d13821d1eccc87acc8 (patch)
tree3b55eb1dfa62bbe3499e4cdf6cab74a876c87c7a /AT91SAM7S256
parent98a83508a996d82886d7a76e7687eb59b7b965e8 (diff)
slightly change the fractional change algorithm to minimize mean error
Diffstat (limited to 'AT91SAM7S256')
-rw-r--r--AT91SAM7S256/Source/d_output.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/AT91SAM7S256/Source/d_output.c b/AT91SAM7S256/Source/d_output.c
index 536e3cc..9d1ed6d 100644
--- a/AT91SAM7S256/Source/d_output.c
+++ b/AT91SAM7S256/Source/d_output.c
@@ -876,16 +876,16 @@ SLONG dOutputFractionalChange(SLONG Value, SWORD *FracError)
/* Apply fractional change in case RegulationTime is different from
* SPEED_TIME. In this case, fractional part is accumulated until it reach
- * one (with "one" being SPEED_TIME). This is use the same principle as the
- * Bresenham algorithm. */
+ * one half (with "one" being SPEED_TIME). This is use the same principle
+ * as the Bresenham algorithm. */
IntegerChange = Value * RegulationTime / SPEED_TIME;
*FracError += Value * RegulationTime % SPEED_TIME;
- if (*FracError > SPEED_TIME)
+ if (*FracError > SPEED_TIME / 2)
{
*FracError -= SPEED_TIME;
IntegerChange++;
}
- else if (*FracError < -SPEED_TIME)
+ else if (*FracError < -SPEED_TIME / 2)
{
*FracError += SPEED_TIME;
IntegerChange--;