Skip to content

Commit

Permalink
fix: correct predictive timer interval calculation
Browse files Browse the repository at this point in the history
We were dividing our slots value by 0.9 (90%) when we should have
been multiplying this value by 90%. We want to target usage of
90% of our slots and this is the correct math. Otherwise we will
constantly overflow and have poor results at the end of the lap
when we run out of buffer space.  This leads to poor measurements
and thus the jumps people were seeing.  *sigh*

Resolves: #108
  • Loading branch information
Andrew Stiegmann (stieg) committed Dec 14, 2020
1 parent 055fc1c commit b34d101
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/predictive_timer/predictive_timer_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static tiny_millis_t adjustPollInterval(tiny_millis_t lapTime)
}

// Careful here of gotchas with tiny_millis_t and floats.
pollInterval = lapTime / (slots / 0.9f);
pollInterval = lapTime / (slots * 0.9f);
DEBUG("Setting poll interval to %ull\n", pollInterval);

return pollInterval;
Expand Down

0 comments on commit b34d101

Please sign in to comment.