diff --git a/dda_lookahead.c b/dda_lookahead.c index 949cc19..05573b0 100644 --- a/dda_lookahead.c +++ b/dda_lookahead.c @@ -172,7 +172,7 @@ void dda_join_moves(DDA *prev, DDA *current) { // until then, we do not want to touch the current move settings. // Note: we assume 'current' will not be dispatched while this function runs, so we do not to // back up the move settings: they will remain constant. - uint32_t this_F, this_F_in_steps, this_F_start_in_steps, this_rampup, this_rampdown, this_total_steps; + uint32_t this_F, this_F_in_steps, this_F_start_in_steps, this_rampup, this_rampdown, this_total_steps, this_fast_axis; uint8_t this_id; static uint32_t la_cnt = 0; // Counter: how many moves did we join? #ifdef LOOKAHEAD_DEBUG @@ -203,6 +203,7 @@ void dda_join_moves(DDA *prev, DDA *current) { this_id = current->id; this_F = current->endpoint.F; this_total_steps = current->total_steps; + this_fast_axis = current->fast_axis; ATOMIC_END // Here we have to distinguish between feedrate along the movement @@ -217,10 +218,9 @@ void dda_join_moves(DDA *prev, DDA *current) { this_F = muldiv(current->fast_um, current->endpoint.F, current->distance); crossF = muldiv(current->fast_um, crossF, current->distance); - // TODO: calculate the steps from the fastest axis and not from X. - prev_F_in_steps = ACCELERATE_RAMP_LEN(prev_F); - this_F_in_steps = ACCELERATE_RAMP_LEN(this_F); - crossF_in_steps = ACCELERATE_RAMP_LEN(crossF); + prev_F_in_steps = acc_ramp_len(prev_F, this_fast_axis); + this_F_in_steps = acc_ramp_len(this_F, this_fast_axis); + crossF_in_steps = acc_ramp_len(crossF, this_fast_axis); // Show the proposed crossing speed - this might get adjusted below if (DEBUG_DDA && (debug_flags & DEBUG_DDA)) diff --git a/dda_maths.h b/dda_maths.h index 34a2eda..c0fb7b6 100644 --- a/dda_maths.h +++ b/dda_maths.h @@ -53,7 +53,4 @@ const uint8_t msbloc (uint32_t v); // Calculates acceleration ramp length in steps. uint32_t acc_ramp_len(uint32_t feedrate, uint8_t fast_axis); -// For X axis only, should become obsolete: -#define ACCELERATE_RAMP_LEN(speed) (((speed)*(speed)) / (uint32_t)((7200000.0f * ACCELERATION) / (float)STEPS_PER_M_X)) - #endif /* _DDA_MATHS_H */