From 9fe9c919a49ff734646e750a1fa2c45501193ba8 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Fri, 17 Oct 2014 18:36:03 +0200 Subject: [PATCH] dda.c: add some TODOs about duplicate and redundant code. --- dda.c | 8 ++++++++ dda_lookahead.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/dda.c b/dda.c index 70a184a..c5d4f2c 100644 --- a/dda.c +++ b/dda.c @@ -205,11 +205,19 @@ void dda_create(DDA *dda, TARGET *target) { // just signedness and storage location. Ideally, dda is used // as storage place only if neccessary (LOOKAHEAD turned on?) // because this space is multiplied by the movement queue size. + // + // Update 2014/10: it was tried to use delta_um[]'s sign to set stepper + // direction in dda_start() to allow getting rid of + // some of this redundancy, but this increases dda_start() + // by at least 20 clock cycles. Not good for performance. + // Tried code can be found in the archive folder. dda->delta_um[i] = (delta_steps >= 0) ? (int32_t)delta_um[i] : -(int32_t)delta_um[i]; #endif } + // TODO: this can likely be, at least partially, joined with the above for() + // loop. Lots of almost-duplicate code. if ( ! target->e_relative) { int32_t delta_steps; diff --git a/dda_lookahead.c b/dda_lookahead.c index 4323a25..60c856a 100644 --- a/dda_lookahead.c +++ b/dda_lookahead.c @@ -193,6 +193,12 @@ void dda_find_crossing_speed(DDA *prev, DDA *current) { prev->distance, current->distance); // Find individual axis speeds. + // TODO: this is eight expensive muldiv()s. It should be possible to store + // currF as prevF for the next calculation somehow, to save 4 of + // these 8 muldiv()s. This would also allow to get rid of + // dda->delta_um[] and using delta_um[] from dda_create() instead. + // Caveat: bail out condition above and some other non-continuous + // situations might need some extra code for handling. for (i = X; i < AXIS_COUNT; i++) { prevF[i] = muldiv(prev->delta_um[i], F, prev->distance); currF[i] = muldiv(current->delta_um[i], F, current->distance);