DDA: Convert TARGET axis vars to array.

In preparation for more efficient and scalable code using axis-loops
for common operations, add two new array-types for signed and unsigned
32-bit values per axis. Make the TARGET type use this array instead of
its current X, Y, Z, and E variables.

Traumflug notes:

- Did the usual conversion to spaces for changed lines.

- Added X = 0 to the enum. Just for peace of mind.

- Excellent patch!

Initially I wanted to make the new array an anonymous union with the
old variables to allow accessing values both ways. This way it would
have been possible to do the transition in smaller pieces. But as
the patch worked so flawlessly and binary size is precisely the
same, I abandoned this idea. Maybe it's a good idea in other areas.
This commit is contained in:
Phil Hord 2013-11-19 17:12:07 -05:00 committed by Markus Hitter
parent e76bfa0d05
commit d3f49b3e95
6 changed files with 139 additions and 128 deletions

View File

@ -37,10 +37,10 @@ static void clock_250ms(void) {
if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) {
// current position
update_current_position();
sersendf_P(PSTR("Pos: %lq,%lq,%lq,%lq,%lu\n"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F);
sersendf_P(PSTR("Pos: %lq,%lq,%lq,%lq,%lu\n"), current_position.axis[X], current_position.axis[Y], current_position.axis[Z], current_position.axis[E], current_position.F);
// target position
sersendf_P(PSTR("Dst: %lq,%lq,%lq,%lq,%lu\n"), movebuffer[mb_tail].endpoint.X, movebuffer[mb_tail].endpoint.Y, movebuffer[mb_tail].endpoint.Z, movebuffer[mb_tail].endpoint.E, movebuffer[mb_tail].endpoint.F);
sersendf_P(PSTR("Dst: %lq,%lq,%lq,%lq,%lu\n"), movebuffer[mb_tail].endpoint.axis[X], movebuffer[mb_tail].endpoint.axis[Y], movebuffer[mb_tail].endpoint.axis[Z], movebuffer[mb_tail].endpoint.axis[E], movebuffer[mb_tail].endpoint.F);
// Queue
print_queue();

101
dda.c
View File

@ -65,10 +65,10 @@ void dda_init(void) {
This is needed for example after homing or a G92. The new location must be in startpoint already.
*/
void dda_new_startpoint(void) {
startpoint_steps.X = um_to_steps_x(startpoint.X);
startpoint_steps.Y = um_to_steps_y(startpoint.Y);
startpoint_steps.Z = um_to_steps_z(startpoint.Z);
startpoint_steps.E = um_to_steps_e(startpoint.E);
startpoint_steps.axis[X] = um_to_steps_x(startpoint.axis[X]);
startpoint_steps.axis[Y] = um_to_steps_y(startpoint.axis[Y]);
startpoint_steps.axis[Z] = um_to_steps_z(startpoint.axis[Z]);
startpoint_steps.axis[E] = um_to_steps_e(startpoint.axis[E]);
}
/*! CREATE a dda given current_position and a target, save to passed location so we can write directly into the queue
@ -117,8 +117,8 @@ void dda_create(DDA *dda, TARGET *target) {
if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR("\nCreate: X %lq Y %lq Z %lq F %lu\n"),
dda->endpoint.X, dda->endpoint.Y,
dda->endpoint.Z, dda->endpoint.F);
dda->endpoint.axis[X], dda->endpoint.axis[Y],
dda->endpoint.axis[Z], dda->endpoint.F);
// we end at the passed target
memcpy(&(dda->endpoint), target, sizeof(TARGET));
@ -136,49 +136,50 @@ void dda_create(DDA *dda, TARGET *target) {
// TODO TODO: We should really make up a loop for all axes.
// Think of what happens when a sixth axis (multi colour extruder)
// appears?
x_delta_um = (uint32_t)abs32(target->X - startpoint.X);
y_delta_um = (uint32_t)abs32(target->Y - startpoint.Y);
z_delta_um = (uint32_t)abs32(target->Z - startpoint.Z);
x_delta_um = (uint32_t)abs32(target->axis[X] - startpoint.axis[X]);
y_delta_um = (uint32_t)abs32(target->axis[Y] - startpoint.axis[Y]);
z_delta_um = (uint32_t)abs32(target->axis[Z] - startpoint.axis[Z]);
steps = um_to_steps_x(target->X);
dda->x_delta = abs32(steps - startpoint_steps.X);
startpoint_steps.X = steps;
steps = um_to_steps_y(target->Y);
dda->y_delta = abs32(steps - startpoint_steps.Y);
startpoint_steps.Y = steps;
steps = um_to_steps_z(target->Z);
dda->z_delta = abs32(steps - startpoint_steps.Z);
startpoint_steps.Z = steps;
steps = um_to_steps_x(target->axis[X]);
dda->x_delta = abs32(steps - startpoint_steps.axis[X]);
startpoint_steps.axis[X] = steps;
steps = um_to_steps_y(target->axis[Y]);
dda->y_delta = abs32(steps - startpoint_steps.axis[Y]);
startpoint_steps.axis[Y] = steps;
steps = um_to_steps_z(target->axis[Z]);
dda->z_delta = abs32(steps - startpoint_steps.axis[Z]);
startpoint_steps.axis[Z] = steps;
dda->x_direction = (target->X >= startpoint.X)?1:0;
dda->y_direction = (target->Y >= startpoint.Y)?1:0;
dda->z_direction = (target->Z >= startpoint.Z)?1:0;
dda->x_direction = (target->axis[X] >= startpoint.axis[X])?1:0;
dda->y_direction = (target->axis[Y] >= startpoint.axis[Y])?1:0;
dda->z_direction = (target->axis[Z] >= startpoint.axis[Z])?1:0;
if (target->e_relative) {
e_delta_um = abs32(target->E);
dda->e_delta = abs32(um_to_steps_e(target->E));
dda->e_direction = (target->E >= 0)?1:0;
e_delta_um = abs32(target->axis[E]);
dda->e_delta = abs32(um_to_steps_e(target->axis[E]));
dda->e_direction = (target->axis[E] >= 0)?1:0;
}
else {
e_delta_um = (uint32_t)abs32(target->E - startpoint.E);
steps = um_to_steps_e(target->E);
dda->e_delta = abs32(steps - startpoint_steps.E);
startpoint_steps.E = steps;
dda->e_direction = (target->E >= startpoint.E)?1:0;
e_delta_um = (uint32_t)abs32(target->axis[E] - startpoint.axis[E]);
steps = um_to_steps_e(target->axis[E]);
dda->e_delta = abs32(steps - startpoint_steps.axis[E]);
startpoint_steps.axis[E] = steps;
dda->e_direction = (target->axis[E] >= startpoint.axis[E])?1:0;
}
#ifdef LOOKAHEAD
// Also displacements in micrometers, but for the lookahead alogrithms.
dda->delta_um.X = target->X - startpoint.X;
dda->delta_um.Y = target->Y - startpoint.Y;
dda->delta_um.Z = target->Z - startpoint.Z;
dda->delta_um.E = target->e_relative ? target->E : target->E - startpoint.E;
dda->delta_um.X = target->axis[X] - startpoint.axis[X];
dda->delta_um.Y = target->axis[Y] - startpoint.axis[Y];
dda->delta_um.Z = target->axis[Z] - startpoint.axis[Z];
dda->delta_um.E = target->e_relative ? target->axis[E] :
target->axis[E] - startpoint.axis[E];
#endif
if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR("[%ld,%ld,%ld,%ld]"),
target->X - startpoint.X, target->Y - startpoint.Y,
target->Z - startpoint.Z, target->E - startpoint.E);
target->axis[X] - startpoint.axis[X], target->axis[Y] - startpoint.axis[Y],
target->axis[Z] - startpoint.axis[Z], target->axis[E] - startpoint.axis[E]);
dda->total_steps = dda->x_delta;
dda->fast_um = x_delta_um;
@ -444,8 +445,8 @@ void dda_start(DDA *dda) {
if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR("Start: X %lq Y %lq Z %lq F %lu\n"),
dda->endpoint.X, dda->endpoint.Y,
dda->endpoint.Z, dda->endpoint.F);
dda->endpoint.axis[X], dda->endpoint.axis[Y],
dda->endpoint.axis[Z], dda->endpoint.F);
if ( ! dda->nullmove) {
// get ready to go
@ -885,45 +886,45 @@ void update_current_position() {
DDA *dda = &movebuffer[mb_tail];
if (queue_empty()) {
current_position.X = startpoint.X;
current_position.Y = startpoint.Y;
current_position.Z = startpoint.Z;
current_position.E = startpoint.E;
current_position.axis[X] = startpoint.axis[X];
current_position.axis[Y] = startpoint.axis[Y];
current_position.axis[Z] = startpoint.axis[Z];
current_position.axis[E] = startpoint.axis[E];
}
else if (dda->live) {
if (dda->x_direction)
// (STEPS_PER_M_X / 1000) is a bit inaccurate for low STEPS_PER_M numbers
current_position.X = dda->endpoint.X -
current_position.axis[X] = dda->endpoint.axis[X] -
// should be: move_state.x_steps * 1000000 / STEPS_PER_M_X)
// but x_steps can be like 1000000 already, so we'd overflow
move_state.x_steps * 1000 / ((STEPS_PER_M_X + 500) / 1000);
else
current_position.X = dda->endpoint.X +
current_position.axis[X] = dda->endpoint.axis[X] +
move_state.x_steps * 1000 / ((STEPS_PER_M_X + 500) / 1000);
if (dda->y_direction)
current_position.Y = dda->endpoint.Y -
current_position.axis[Y] = dda->endpoint.axis[Y] -
move_state.y_steps * 1000 / ((STEPS_PER_M_Y + 500) / 1000);
else
current_position.Y = dda->endpoint.Y +
current_position.axis[Y] = dda->endpoint.axis[Y] +
move_state.y_steps * 1000 / ((STEPS_PER_M_Y + 500) / 1000);
if (dda->z_direction)
current_position.Z = dda->endpoint.Z -
current_position.axis[Z] = dda->endpoint.axis[Z] -
move_state.z_steps * 1000 / ((STEPS_PER_M_Z + 500) / 1000);
else
current_position.Z = dda->endpoint.Z +
current_position.axis[Z] = dda->endpoint.axis[Z] +
move_state.z_steps * 1000 / ((STEPS_PER_M_Z + 500) / 1000);
if (dda->endpoint.e_relative) {
current_position.E = move_state.e_steps * 1000 / ((STEPS_PER_M_E + 500) / 1000);
current_position.axis[E] = move_state.e_steps * 1000 / ((STEPS_PER_M_E + 500) / 1000);
}
else {
if (dda->e_direction)
current_position.E = dda->endpoint.E -
current_position.axis[E] = dda->endpoint.axis[E] -
move_state.e_steps * 1000 / ((STEPS_PER_M_E + 500) / 1000);
else
current_position.E = dda->endpoint.E +
current_position.axis[E] = dda->endpoint.axis[E] +
move_state.e_steps * 1000 / ((STEPS_PER_M_E + 500) / 1000);
}

30
dda.h
View File

@ -16,7 +16,23 @@
*/
// Enum to denote an axis
enum axis_e { X, Y, Z, E };
enum axis_e { X = 0, Y, Z, E, AXIS_COUNT };
/**
\typedef axes_uint32_t
\brief n-dimensional vector used to describe uint32_t axis information.
Stored value can be anything unsigned. Units should be specified when declared.
*/
typedef uint32_t axes_uint32_t[AXIS_COUNT];
/**
\typedef axes_int32_t
\brief n-dimensional vector used to describe int32_t axis information.
Stored value can be anything unsigned. Units should be specified when declared.
*/
typedef int32_t axes_int32_t[AXIS_COUNT];
/**
\struct TARGET
@ -25,16 +41,10 @@ enum axis_e { X, Y, Z, E };
X, Y, Z and E are in micrometers unless explcitely stated. F is in mm/min.
*/
typedef struct {
// TODO TODO: We should really make up a loop for all axes.
// Think of what happens when a sixth axis (multi colour extruder)
// appears?
int32_t X;
int32_t Y;
int32_t Z;
int32_t E;
uint32_t F;
axes_int32_t axis;
uint32_t F;
uint8_t e_relative :1; ///< bool: e axis relative? Overrides all_relative
uint8_t e_relative :1; ///< bool: e axis relative? Overrides all_relative
} TARGET;
/**

View File

@ -122,35 +122,35 @@ void gcode_parse_char(uint8_t c) {
break;
case 'X':
if (next_target.option_inches)
next_target.target.X = decfloat_to_int(&read_digit, 25400);
next_target.target.axis[X] = decfloat_to_int(&read_digit, 25400);
else
next_target.target.X = decfloat_to_int(&read_digit, 1000);
next_target.target.axis[X] = decfloat_to_int(&read_digit, 1000);
if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_int32(next_target.target.X);
serwrite_int32(next_target.target.axis[X]);
break;
case 'Y':
if (next_target.option_inches)
next_target.target.Y = decfloat_to_int(&read_digit, 25400);
next_target.target.axis[Y] = decfloat_to_int(&read_digit, 25400);
else
next_target.target.Y = decfloat_to_int(&read_digit, 1000);
next_target.target.axis[Y] = decfloat_to_int(&read_digit, 1000);
if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_int32(next_target.target.Y);
serwrite_int32(next_target.target.axis[Y]);
break;
case 'Z':
if (next_target.option_inches)
next_target.target.Z = decfloat_to_int(&read_digit, 25400);
next_target.target.axis[Z] = decfloat_to_int(&read_digit, 25400);
else
next_target.target.Z = decfloat_to_int(&read_digit, 1000);
next_target.target.axis[Z] = decfloat_to_int(&read_digit, 1000);
if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_int32(next_target.target.Z);
serwrite_int32(next_target.target.axis[Z]);
break;
case 'E':
if (next_target.option_inches)
next_target.target.E = decfloat_to_int(&read_digit, 25400);
next_target.target.axis[E] = decfloat_to_int(&read_digit, 25400);
else
next_target.target.E = decfloat_to_int(&read_digit, 1000);
next_target.target.axis[E] = decfloat_to_int(&read_digit, 1000);
if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint32(next_target.target.E);
serwrite_uint32(next_target.target.axis[E]);
break;
case 'F':
// just use raw integer, we need move distance and n_steps to convert it to a useful value, so wait until we have those to convert it
@ -375,10 +375,10 @@ void gcode_parse_char(uint8_t c) {
// last_field and read_digit are reset above already
if (next_target.option_all_relative) {
next_target.target.X = next_target.target.Y = next_target.target.Z = 0;
next_target.target.axis[X] = next_target.target.axis[Y] = next_target.target.axis[Z] = 0;
}
if (next_target.option_all_relative || next_target.option_e_relative) {
next_target.target.E = 0;
next_target.target.axis[E] = 0;
}
}
}

View File

@ -49,9 +49,9 @@ void process_gcode_command() {
// convert relative to absolute
if (next_target.option_all_relative) {
next_target.target.X += startpoint.X;
next_target.target.Y += startpoint.Y;
next_target.target.Z += startpoint.Z;
next_target.target.axis[X] += startpoint.axis[X];
next_target.target.axis[Y] += startpoint.axis[Y];
next_target.target.axis[Z] += startpoint.axis[Z];
}
// E relative movement.
@ -63,28 +63,28 @@ void process_gcode_command() {
// implement axis limits
#ifdef X_MIN
if (next_target.target.X < X_MIN * 1000.)
next_target.target.X = X_MIN * 1000.;
if (next_target.target.axis[X] < X_MIN * 1000.)
next_target.target.axis[X] = X_MIN * 1000.;
#endif
#ifdef X_MAX
if (next_target.target.X > X_MAX * 1000.)
next_target.target.X = X_MAX * 1000.;
if (next_target.target.axis[X] > X_MAX * 1000.)
next_target.target.axis[X] = X_MAX * 1000.;
#endif
#ifdef Y_MIN
if (next_target.target.Y < Y_MIN * 1000.)
next_target.target.Y = Y_MIN * 1000.;
if (next_target.target.axis[Y] < Y_MIN * 1000.)
next_target.target.axis[Y] = Y_MIN * 1000.;
#endif
#ifdef Y_MAX
if (next_target.target.Y > Y_MAX * 1000.)
next_target.target.Y = Y_MAX * 1000.;
if (next_target.target.axis[Y] > Y_MAX * 1000.)
next_target.target.axis[Y] = Y_MAX * 1000.;
#endif
#ifdef Z_MIN
if (next_target.target.Z < Z_MIN * 1000.)
next_target.target.Z = Z_MIN * 1000.;
if (next_target.target.axis[Z] < Z_MIN * 1000.)
next_target.target.axis[Z] = Z_MIN * 1000.;
#endif
#ifdef Z_MAX
if (next_target.target.Z > Z_MAX * 1000.)
next_target.target.Z = Z_MAX * 1000.;
if (next_target.target.axis[Z] > Z_MAX * 1000.)
next_target.target.axis[Z] = Z_MAX * 1000.;
#endif
@ -264,27 +264,27 @@ void process_gcode_command() {
queue_wait();
if (next_target.seen_X) {
startpoint.X = next_target.target.X;
startpoint.axis[X] = next_target.target.axis[X];
axisSelected = 1;
}
if (next_target.seen_Y) {
startpoint.Y = next_target.target.Y;
startpoint.axis[Y] = next_target.target.axis[Y];
axisSelected = 1;
}
if (next_target.seen_Z) {
startpoint.Z = next_target.target.Z;
startpoint.axis[Z] = next_target.target.axis[Z];
axisSelected = 1;
}
if (next_target.seen_E) {
startpoint.E = next_target.target.E;
startpoint.axis[E] = next_target.target.axis[E];
axisSelected = 1;
}
if (axisSelected == 0) {
startpoint.X = next_target.target.X =
startpoint.Y = next_target.target.Y =
startpoint.Z = next_target.target.Z =
startpoint.E = next_target.target.E = 0;
startpoint.axis[X] = next_target.target.axis[X] =
startpoint.axis[Y] = next_target.target.axis[Y] =
startpoint.axis[Z] = next_target.target.axis[Z] =
startpoint.axis[E] = next_target.target.axis[E] = 0;
}
dda_new_startpoint();
@ -557,16 +557,16 @@ void process_gcode_command() {
#endif
update_current_position();
sersendf_P(PSTR("X:%lq,Y:%lq,Z:%lq,E:%lq,F:%lu"),
current_position.X, current_position.Y,
current_position.Z, current_position.E,
current_position.axis[X], current_position.axis[Y],
current_position.axis[Z], current_position.axis[E],
current_position.F);
#ifdef DEBUG
if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) {
sersendf_P(PSTR(",c:%lu}\nEndpoint: X:%ld,Y:%ld,Z:%ld,E:%ld,F:%lu,c:%lu}"),
movebuffer[mb_tail].c, movebuffer[mb_tail].endpoint.X,
movebuffer[mb_tail].endpoint.Y, movebuffer[mb_tail].endpoint.Z,
movebuffer[mb_tail].endpoint.E, movebuffer[mb_tail].endpoint.F,
movebuffer[mb_tail].c, movebuffer[mb_tail].endpoint.axis[X],
movebuffer[mb_tail].endpoint.axis[Y], movebuffer[mb_tail].endpoint.axis[Z],
movebuffer[mb_tail].endpoint.axis[E], movebuffer[mb_tail].endpoint.F,
#ifdef ACCELERATION_REPRAP
movebuffer[mb_tail].end_c
#else

48
home.c
View File

@ -72,7 +72,7 @@ void home_x_negative() {
#if defined X_MIN_PIN
TARGET t = startpoint;
t.X = -1000000;
t.axis[X] = -1000000;
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X) // Preprocessor can't check this :-/
t.F = SEARCH_FAST_X;
else
@ -81,7 +81,7 @@ void home_x_negative() {
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X) {
// back off slowly
t.X = +1000000;
t.axis[X] = +1000000;
t.F = SEARCH_FEEDRATE_X;
enqueue_home(&t, 0x1, 0);
}
@ -89,9 +89,9 @@ void home_x_negative() {
// set X home
queue_wait(); // we have to wait here, see G92
#ifdef X_MIN
startpoint.X = next_target.target.X = (int32_t)(X_MIN * 1000.0);
startpoint.axis[X] = next_target.target.axis[X] = (int32_t)(X_MIN * 1000.0);
#else
startpoint.X = next_target.target.X = 0;
startpoint.axis[X] = next_target.target.axis[X] = 0;
#endif
dda_new_startpoint();
#endif
@ -105,7 +105,7 @@ void home_x_positive() {
#if defined X_MAX_PIN && defined X_MAX
TARGET t = startpoint;
t.X = +1000000;
t.axis[X] = +1000000;
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X)
t.F = SEARCH_FAST_X;
else
@ -113,7 +113,7 @@ void home_x_positive() {
enqueue_home(&t, 0x1, 1);
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X) {
t.X = -1000000;
t.axis[X] = -1000000;
t.F = SEARCH_FEEDRATE_X;
enqueue_home(&t, 0x1, 0);
}
@ -121,10 +121,10 @@ void home_x_positive() {
// set X home
queue_wait();
// set position to MAX
startpoint.X = next_target.target.X = (int32_t)(X_MAX * 1000.);
startpoint.axis[X] = next_target.target.axis[X] = (int32_t)(X_MAX * 1000.);
dda_new_startpoint();
// go to zero
t.X = 0;
t.axis[X] = 0;
t.F = MAXIMUM_FEEDRATE_X;
enqueue(&t);
#endif
@ -135,7 +135,7 @@ void home_y_negative() {
#if defined Y_MIN_PIN
TARGET t = startpoint;
t.Y = -1000000;
t.axis[Y] = -1000000;
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y)
t.F = SEARCH_FAST_Y;
else
@ -143,7 +143,7 @@ void home_y_negative() {
enqueue_home(&t, 0x2, 1);
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y) {
t.Y = +1000000;
t.axis[Y] = +1000000;
t.F = SEARCH_FEEDRATE_Y;
enqueue_home(&t, 0x2, 0);
}
@ -151,9 +151,9 @@ void home_y_negative() {
// set Y home
queue_wait();
#ifdef Y_MIN
startpoint.Y = next_target.target.Y = (int32_t)(Y_MIN * 1000.);
startpoint.axis[Y] = next_target.target.axis[Y] = (int32_t)(Y_MIN * 1000.);
#else
startpoint.Y = next_target.target.Y = 0;
startpoint.axis[Y] = next_target.target.axis[Y] = 0;
#endif
dda_new_startpoint();
#endif
@ -167,7 +167,7 @@ void home_y_positive() {
#if defined Y_MAX_PIN && defined Y_MAX
TARGET t = startpoint;
t.Y = +1000000;
t.axis[Y] = +1000000;
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y)
t.F = SEARCH_FAST_Y;
else
@ -175,7 +175,7 @@ void home_y_positive() {
enqueue_home(&t, 0x2, 1);
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y) {
t.Y = -1000000;
t.axis[Y] = -1000000;
t.F = SEARCH_FEEDRATE_Y;
enqueue_home(&t, 0x2, 0);
}
@ -183,10 +183,10 @@ void home_y_positive() {
// set Y home
queue_wait();
// set position to MAX
startpoint.Y = next_target.target.Y = (int32_t)(Y_MAX * 1000.);
startpoint.axis[Y] = next_target.target.axis[Y] = (int32_t)(Y_MAX * 1000.);
dda_new_startpoint();
// go to zero
t.Y = 0;
t.axis[Y] = 0;
t.F = MAXIMUM_FEEDRATE_Y;
enqueue(&t);
#endif
@ -197,7 +197,7 @@ void home_z_negative() {
#if defined Z_MIN_PIN
TARGET t = startpoint;
t.Z = -1000000;
t.axis[Z] = -1000000;
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z)
t.F = SEARCH_FAST_Z;
else
@ -205,7 +205,7 @@ void home_z_negative() {
enqueue_home(&t, 0x4, 1);
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z) {
t.Z = +1000000;
t.axis[Z] = +1000000;
t.F = SEARCH_FEEDRATE_Z;
enqueue_home(&t, 0x4, 0);
}
@ -213,9 +213,9 @@ void home_z_negative() {
// set Z home
queue_wait();
#ifdef Z_MIN
startpoint.Z = next_target.target.Z = (int32_t)(Z_MIN * 1000.);
startpoint.axis[Z] = next_target.target.axis[Z] = (int32_t)(Z_MIN * 1000.);
#else
startpoint.Z = next_target.target.Z = 0;
startpoint.axis[Z] = next_target.target.axis[Z] = 0;
#endif
dda_new_startpoint();
z_disable();
@ -230,7 +230,7 @@ void home_z_positive() {
#if defined Z_MAX_PIN && defined Z_MAX
TARGET t = startpoint;
t.Z = +1000000;
t.axis[Z] = +1000000;
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z)
t.F = SEARCH_FAST_Z;
else
@ -238,7 +238,7 @@ void home_z_positive() {
enqueue_home(&t, 0x4, 1);
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z) {
t.Z = -1000000;
t.axis[Z] = -1000000;
t.F = SEARCH_FEEDRATE_Z;
enqueue_home(&t, 0x4, 0);
}
@ -246,10 +246,10 @@ void home_z_positive() {
// set Z home
queue_wait();
// set position to MAX
startpoint.Z = next_target.target.Z = (int32_t)(Z_MAX * 1000.);
startpoint.axis[Z] = next_target.target.axis[Z] = (int32_t)(Z_MAX * 1000.);
dda_new_startpoint();
// go to zero
t.Z = 0;
t.axis[Z] = 0;
t.F = MAXIMUM_FEEDRATE_Z;
enqueue(&t);
#endif