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.
This commit is contained in:
Nico Tonnhofer 2017-01-03 21:10:29 +01:00
parent b36aa4168a
commit 22489c69cb
1 changed files with 4 additions and 4 deletions

8
dda.c
View File

@ -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++;