DDA: Move axis calculations into loops, part 6b.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.
Part 6b moves do_step() from the "tidiest" place into where it's
currently used, dda.c. Binary size goes down another 34 bytes, to
a total savings of 408 bytes and performance is much better, but
still 16% lower than without using loops:
SIZES ATmega... '168 '328(P) '644(P) '1280
FLASH : 19874 bytes 139% 65% 32% 16%
RAM : 2302 bytes 225% 113% 57% 29%
EEPROM: 32 bytes 4% 2% 2% 1%
short-moves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 888.
Sum of all LED on time: 320000 clock cycles.
LED on time minimum: 351 clock cycles.
LED on time maximum: 772 clock cycles.
LED on time average: 360.36 clock cycles.
smooth-curves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 9124.
Sum of all LED on time: 3875874 clock cycles.
LED on time minimum: 356 clock cycles.
LED on time maximum: 773 clock cycles.
LED on time average: 424.8 clock cycles.
triangle-odd.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 1636.
Sum of all LED on time: 640357 clock cycles.
LED on time minimum: 351 clock cycles.
LED on time maximum: 773 clock cycles.
LED on time average: 391.416 clock cycles.
This commit is contained in:
parent
b83449d8c3
commit
808f5dcfca
12
dda.c
12
dda.c
|
|
@ -471,6 +471,18 @@ void dda_start(DDA *dda) {
|
|||
current_position.F = dda->endpoint.F;
|
||||
}
|
||||
|
||||
// step the 'n' axis
|
||||
static void do_step(enum axis_e n) {
|
||||
if (n == X)
|
||||
x_step();
|
||||
else if (n == Y)
|
||||
y_step();
|
||||
else if (n == Z)
|
||||
z_step();
|
||||
else if (n == E)
|
||||
e_step();
|
||||
}
|
||||
|
||||
/*! STEP
|
||||
\param *dda the current move
|
||||
|
||||
|
|
|
|||
13
pinio.c
13
pinio.c
|
|
@ -42,16 +42,3 @@ void power_off() {
|
|||
|
||||
ps_is_on = 0;
|
||||
}
|
||||
|
||||
// step the 'n' axis
|
||||
void do_step(enum axis_e n) {
|
||||
if (n == X)
|
||||
x_step();
|
||||
else if (n == Y)
|
||||
y_step();
|
||||
else if (n == Z)
|
||||
z_step();
|
||||
else if (n == E)
|
||||
e_step();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue