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:
Markus Hitter 2014-06-17 22:13:25 +02:00
parent b83449d8c3
commit 808f5dcfca
3 changed files with 12 additions and 16 deletions

12
dda.c
View File

@ -471,6 +471,18 @@ void dda_start(DDA *dda) {
current_position.F = dda->endpoint.F; 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 /*! STEP
\param *dda the current move \param *dda the current move

13
pinio.c
View File

@ -42,16 +42,3 @@ void power_off() {
ps_is_on = 0; 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();
}

View File

@ -6,7 +6,6 @@
#define _PINIO_H #define _PINIO_H
#include "config_wrapper.h" #include "config_wrapper.h"
#include "dda.h"
#ifdef SIMULATOR #ifdef SIMULATOR
#include "simulator.h" #include "simulator.h"
@ -34,8 +33,6 @@ inline void power_init(void) {
void power_on(void); void power_on(void);
void power_off(void); void power_off(void);
void do_step(enum axis_e n);
/* /*
X Stepper X Stepper
*/ */