From b34d101cffb77cdb763a8ea9e0a805a44775a0f4 Mon Sep 17 00:00:00 2001 From: "Andrew Stiegmann (stieg)" Date: Thu, 19 Nov 2020 20:28:10 -1000 Subject: [PATCH] fix: correct predictive timer interval calculation 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 --- src/predictive_timer/predictive_timer_2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/predictive_timer/predictive_timer_2.c b/src/predictive_timer/predictive_timer_2.c index 967d38b19..21b5bd49d 100644 --- a/src/predictive_timer/predictive_timer_2.c +++ b/src/predictive_timer/predictive_timer_2.c @@ -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;