DDA: remember the fast axis micrometers and save their reconstruction.
No surprise, this saves a whopping 600 bytes.
This commit is contained in:
parent
297aa28dfd
commit
3da2363ac5
34
dda.c
34
dda.c
|
|
@ -186,12 +186,19 @@ void dda_create(DDA *dda, TARGET *target) {
|
||||||
target->Z - startpoint.Z, target->E - startpoint.E);
|
target->Z - startpoint.Z, target->E - startpoint.E);
|
||||||
|
|
||||||
dda->total_steps = dda->x_delta;
|
dda->total_steps = dda->x_delta;
|
||||||
if (dda->y_delta > dda->total_steps)
|
dda->fast_um = x_delta_um;
|
||||||
|
if (dda->y_delta > dda->total_steps) {
|
||||||
dda->total_steps = dda->y_delta;
|
dda->total_steps = dda->y_delta;
|
||||||
if (dda->z_delta > dda->total_steps)
|
dda->fast_um = y_delta_um;
|
||||||
|
}
|
||||||
|
if (dda->z_delta > dda->total_steps) {
|
||||||
dda->total_steps = dda->z_delta;
|
dda->total_steps = dda->z_delta;
|
||||||
if (dda->e_delta > dda->total_steps)
|
dda->fast_um = z_delta_um;
|
||||||
|
}
|
||||||
|
if (dda->e_delta > dda->total_steps) {
|
||||||
dda->total_steps = dda->e_delta;
|
dda->total_steps = dda->e_delta;
|
||||||
|
dda->fast_um = e_delta_um;
|
||||||
|
}
|
||||||
|
|
||||||
if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
|
if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
|
||||||
sersendf_P(PSTR(" [ts:%lu"), dda->total_steps);
|
sersendf_P(PSTR(" [ts:%lu"), dda->total_steps);
|
||||||
|
|
@ -347,24 +354,9 @@ void dda_create(DDA *dda, TARGET *target) {
|
||||||
if (dda->endpoint.F > 65535)
|
if (dda->endpoint.F > 65535)
|
||||||
dda->endpoint.F = 65535;
|
dda->endpoint.F = 65535;
|
||||||
|
|
||||||
// Note: this is inaccurate:
|
// Acceleration ramps are based on the fast axis, not the combined speed.
|
||||||
// - ACCELERATE_RAMP_LEN() uses STEPS_PER_M_X, so axes not matching
|
dda->rampup_steps =
|
||||||
// this get too much or not enough rampup steps.
|
ACCELERATE_RAMP_LEN(muldiv(dda->fast_um, dda->endpoint.F, distance));
|
||||||
uint32_t fast_um;
|
|
||||||
|
|
||||||
if (dda->total_steps == dda->x_delta)
|
|
||||||
fast_um = x_delta_um;
|
|
||||||
else if (dda->total_steps == dda->y_delta)
|
|
||||||
fast_um = y_delta_um;
|
|
||||||
else if (dda->total_steps == dda->z_delta)
|
|
||||||
fast_um = z_delta_um;
|
|
||||||
else if (dda->total_steps == dda->e_delta)
|
|
||||||
fast_um = e_delta_um;
|
|
||||||
else {
|
|
||||||
fast_um = 0;
|
|
||||||
sersendf_P(PSTR("WTF? No prev fast axis found\n"));
|
|
||||||
}
|
|
||||||
dda->rampup_steps = ACCELERATE_RAMP_LEN(muldiv(fast_um, dda->endpoint.F, distance));
|
|
||||||
|
|
||||||
if (dda->rampup_steps > dda->total_steps / 2)
|
if (dda->rampup_steps > dda->total_steps / 2)
|
||||||
dda->rampup_steps = dda->total_steps / 2;
|
dda->rampup_steps = dda->total_steps / 2;
|
||||||
|
|
|
||||||
4
dda.h
4
dda.h
|
|
@ -126,8 +126,8 @@ typedef struct {
|
||||||
uint32_t z_delta; ///< number of steps on Z axis
|
uint32_t z_delta; ///< number of steps on Z axis
|
||||||
uint32_t e_delta; ///< number of steps on E axis
|
uint32_t e_delta; ///< number of steps on E axis
|
||||||
|
|
||||||
/// total number of steps: set to \f$\max(\Delta x, \Delta y, \Delta z, \Delta e)\f$
|
uint32_t total_steps; ///< steps of the "fast" axis
|
||||||
uint32_t total_steps;
|
uint32_t fast_um; ///< movement length of this fast axis
|
||||||
|
|
||||||
uint32_t c; ///< time until next step, 24.8 fixed point
|
uint32_t c; ///< time until next step, 24.8 fixed point
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -351,38 +351,9 @@ void dda_join_moves(DDA *prev, DDA *current) {
|
||||||
//
|
//
|
||||||
// All calculations here are done along the fast axis, so recalculate
|
// All calculations here are done along the fast axis, so recalculate
|
||||||
// F and crossF to match this, too.
|
// F and crossF to match this, too.
|
||||||
uint32_t fast_um;
|
prev_F = muldiv(prev->fast_um, prev_F, prev->distance);
|
||||||
|
this_F = muldiv(current->fast_um, current->endpoint.F, current->distance);
|
||||||
// TODO: instead of reconstructing the fast axis distance, it
|
crossF = muldiv(current->fast_um, crossF, current->distance);
|
||||||
// could be stored right in dda_create().
|
|
||||||
if (prev->total_steps == prev->x_delta)
|
|
||||||
fast_um = prev->delta_um.X;
|
|
||||||
else if (prev->total_steps == prev->y_delta)
|
|
||||||
fast_um = prev->delta_um.Y;
|
|
||||||
else if (prev->total_steps == prev->z_delta)
|
|
||||||
fast_um = prev->delta_um.Z;
|
|
||||||
else if (prev->total_steps == prev->e_delta)
|
|
||||||
fast_um = prev->delta_um.E;
|
|
||||||
else {
|
|
||||||
fast_um = 0;
|
|
||||||
sersendf_P(PSTR("WTF? No prev fast axis found\n"));
|
|
||||||
}
|
|
||||||
prev_F = muldiv(fast_um, prev_F, prev->distance);
|
|
||||||
|
|
||||||
if (current->total_steps == current->x_delta)
|
|
||||||
fast_um = current->delta_um.X;
|
|
||||||
else if (current->total_steps == current->y_delta)
|
|
||||||
fast_um = current->delta_um.Y;
|
|
||||||
else if (current->total_steps == current->z_delta)
|
|
||||||
fast_um = current->delta_um.Z;
|
|
||||||
else if (current->total_steps == current->e_delta)
|
|
||||||
fast_um = current->delta_um.E;
|
|
||||||
else {
|
|
||||||
fast_um = 0;
|
|
||||||
sersendf_P(PSTR("WTF? No current fast axis found\n"));
|
|
||||||
}
|
|
||||||
crossF = muldiv(fast_um, crossF, current->distance);
|
|
||||||
this_F = muldiv(fast_um, current->endpoint.F, current->distance);
|
|
||||||
|
|
||||||
prev_F_in_steps = ACCELERATE_RAMP_LEN(prev_F);
|
prev_F_in_steps = ACCELERATE_RAMP_LEN(prev_F);
|
||||||
this_F_in_steps = ACCELERATE_RAMP_LEN(this_F);
|
this_F_in_steps = ACCELERATE_RAMP_LEN(this_F);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue