From 22489c69cbb5fc939789b93b0fa12367cf2b14cc Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Tue, 3 Jan 2017 21:10:29 +0100 Subject: [PATCH] dda.c: simply resort the values and save up to 8 clocks ATmega sizes '168 '328(P) '644(P) '1280 Program: 18266 bytes 128% 60% 29% 15% Data: 1936 bytes 190% 95% 48% 24% EEPROM: 32 bytes 4% 2% 2% 1% short-moves.gcode statistics: LED on occurences: 888. LED on time minimum: 243 clock cycles. LED on time maximum: 555 clock cycles. LED on time average: 250.375 clock cycles. smooth-curves.gcode statistics: LED on occurences: 22589. LED on time minimum: 243 clock cycles. LED on time maximum: 572 clock cycles. LED on time average: 292.139 clock cycles. triangle-odd.gcode statistics: LED on occurences: 1636. LED on time minimum: 243 clock cycles. LED on time maximum: 555 clock cycles. LED on time average: 275.699 clock cycles. --- dda.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dda.c b/dda.c index b1245b8..b7e8efb 100644 --- a/dda.c +++ b/dda.c @@ -538,33 +538,33 @@ void dda_step(DDA *dda) { if (move_state.steps[X]) { move_state.counter[X] -= dda->delta[X]; if (move_state.counter[X] < 0) { + move_state.counter[X] += dda->total_steps; x_step(); move_state.steps[X]--; - move_state.counter[X] += dda->total_steps; } } if (move_state.steps[Y]) { move_state.counter[Y] -= dda->delta[Y]; if (move_state.counter[Y] < 0) { + move_state.counter[Y] += dda->total_steps; y_step(); move_state.steps[Y]--; - move_state.counter[Y] += dda->total_steps; } } if (move_state.steps[Z]) { move_state.counter[Z] -= dda->delta[Z]; if (move_state.counter[Z] < 0) { + move_state.counter[Z] += dda->total_steps; z_step(); move_state.steps[Z]--; - move_state.counter[Z] += dda->total_steps; } } if (move_state.steps[E]) { move_state.counter[E] -= dda->delta[E]; if (move_state.counter[E] < 0) { + move_state.counter[E] += dda->total_steps; e_step(); move_state.steps[E]--; - move_state.counter[E] += dda->total_steps; } } move_state.step_no++;