a new (slightly inelegant) stab at eliminating the slow tail problem

This commit is contained in:
Simen Svale Skogsrud
2011-02-16 22:58:53 +01:00
parent c02a6e2366
commit 1ed2195e11
4 changed files with 89 additions and 5 deletions

View File

@ -90,6 +90,7 @@ void st_wake_up() {
// block begins.
inline void trapezoid_generator_reset() {
trapezoid_adjusted_rate = current_block->initial_rate;
trapezoid_tick_cycle_counter = 0; // Always start a new trapezoid with a full acceleration tick
set_step_events_per_minute(trapezoid_adjusted_rate);
}
@ -104,9 +105,12 @@ inline void trapezoid_generator_tick() {
} else if (step_events_completed > current_block->decelerate_after) {
// NOTE: We will only reduce speed if the result will be > 0. This catches small
// rounding errors that might leave steps hanging after the last trapezoid tick.
if(current_block->rate_delta < trapezoid_adjusted_rate) {
if (trapezoid_adjusted_rate > current_block->rate_delta) {
trapezoid_adjusted_rate -= current_block->rate_delta;
}
}
if (trapezoid_adjusted_rate < current_block->final_rate) {
trapezoid_adjusted_rate = current_block->final_rate;
}
set_step_events_per_minute(trapezoid_adjusted_rate);
} else {
// Make sure we cruise at exactly nominal rate