From 301c5ed149d93ee9f9139b7ef7089a844660fa88 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Fri, 27 Oct 2017 20:16:27 +0200 Subject: [PATCH] dda.c: get endstops back working In the endstop_trigger case, we look, if will are cruising. -> Yes: Take the rampdown_steps for calculation -> No: We are still accelerating. So we want to decelerate the same amount of steps. --- dda.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dda.c b/dda.c index cdd3719..bc7b1f1 100644 --- a/dda.c +++ b/dda.c @@ -829,16 +829,16 @@ void dda_clock() { // For always smooth operations, don't halt apruptly, // but start deceleration here. ATOMIC_START + move_state.endstop_stop = 1; move_step_no = dda->total_steps - move_state.steps[dda->fast_axis]; - move_state.endstop_stop = 1; - if (move_step_no < dda->rampup_steps) // still accelerating - dda->total_steps = move_step_no * 2; - else - // A "-=" would overflow earlier. - dda->total_steps = dda->total_steps - dda->rampdown_steps + - move_step_no; + if (move_step_no > dda->rampup_steps) { // cruising? + move_step_no = dda->total_steps - dda->rampdown_steps; + } + dda->rampdown_steps = move_step_no; + dda->total_steps = move_step_no * 2; + move_state.steps[dda->fast_axis] = move_step_no; ATOMIC_END // Not atomic, because not used in dda_step(). dda->rampup_steps = 0; // in case we're still accelerating