Merge pull request #8345 from tcm0116/1.1.x-delta_height

[1.1.x] Add delta_height variable in lieu of using home_offset
This commit is contained in:
Scott Lahteine 2017-11-09 01:19:48 -06:00 committed by GitHub
commit b6b4bf0959
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 84 additions and 92 deletions

View file

@ -627,7 +627,8 @@ static uint8_t target_extruder;
float delta[ABC];
// Initialized by settings.load()
float delta_endstop_adj[ABC] = { 0 },
float delta_height,
delta_endstop_adj[ABC] = { 0 },
delta_radius,
delta_tower_angle_trim[ABC],
delta_tower[ABC][2],
@ -1443,6 +1444,12 @@ bool get_target_extruder_from_command(const uint16_t code) {
soft_endstop_max[axis] = base_max_pos(axis) + offs;
}
}
#elif ENABLED(DELTA)
soft_endstop_min[axis] = base_min_pos(axis) + offs;
soft_endstop_max[axis] = (axis == Z_AXIS ? delta_height : base_max_pos(axis)) + offs;
#else
soft_endstop_min[axis] = base_min_pos(axis) + offs;
soft_endstop_max[axis] = base_max_pos(axis) + offs;
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
@ -1568,6 +1575,10 @@ static void set_axis_is_at_home(const AxisEnum axis) {
soft_endstop_max[axis] = base_max_pos(axis); // + (cartes[axis] - base_home_pos(axis));
}
else
#elif ENABLED(DELTA)
if (axis == Z_AXIS)
current_position[axis] = delta_height;
else
#endif
{
current_position[axis] = base_home_pos(axis);
@ -2377,11 +2388,7 @@ static void clean_up_after_endstop_or_probe_move() {
}
#endif
return current_position[Z_AXIS] + zprobe_zoffset
#if ENABLED(DELTA)
+ home_offset[Z_AXIS] // Account for delta height adjustment
#endif
;
return current_position[Z_AXIS] + zprobe_zoffset;
}
/**
@ -3930,14 +3937,13 @@ inline void gcode_G4() {
sync_plan_position();
// Move all carriages together linearly until an endstop is hit.
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (delta_height + 10);
feedrate_mm_s = homing_feedrate(X_AXIS);
buffer_line_to_current_position();
stepper.synchronize();
// If an endstop was not hit, then damage can occur if homing is continued.
// This can occur if the delta height (DELTA_HEIGHT + home_offset[Z_AXIS]) is
// not set correctly.
// This can occur if the delta height not set correctly.
if (!(Endstops::endstop_hit_bits & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX)))) {
LCD_MESSAGEPGM(MSG_ERR_HOMING_FAILED);
SERIAL_ERROR_START();
@ -5475,7 +5481,7 @@ void home_all_axes() { gcode_G28(true); }
}
static void print_G33_settings(const bool end_stops, const bool tower_angles) {
SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
SERIAL_PROTOCOLPAIR(".Height:", delta_height);
if (end_stops) {
print_signed_float(PSTR("Ex"), delta_endstop_adj[A_AXIS]);
print_signed_float(PSTR("Ey"), delta_endstop_adj[B_AXIS]);
@ -5723,7 +5729,7 @@ void home_all_axes() { gcode_G28(true); }
delta_endstop_adj[(axis + 1) % 3] -= 1.0 / 4.5;
delta_endstop_adj[(axis + 2) % 3] += 1.0 / 4.5;
z_temp = MAX3(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
home_offset[Z_AXIS] -= z_temp;
delta_height -= z_temp;
LOOP_XYZ(axis) delta_endstop_adj[axis] -= z_temp;
recalc_delta_settings(delta_radius, delta_diagonal_rod, delta_tower_angle_trim);
@ -5743,7 +5749,7 @@ void home_all_axes() { gcode_G28(true); }
delta_endstop_adj[(axis+1) % 3] += 1.0/4.5;
delta_endstop_adj[(axis+2) % 3] -= 1.0/4.5;
z_temp = MAX3(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
home_offset[Z_AXIS] -= z_temp;
delta_height -= z_temp;
LOOP_XYZ(axis) delta_endstop_adj[axis] -= z_temp;
recalc_delta_settings(delta_radius, delta_diagonal_rod, delta_tower_angle_trim);
switch (axis) {
@ -5852,7 +5858,7 @@ void home_all_axes() { gcode_G28(true); }
delta_endstop_adj[C_AXIS]
},
dr_old = delta_radius,
zh_old = home_offset[Z_AXIS],
zh_old = delta_height,
ta_old[ABC] = {
delta_tower_angle_trim[A_AXIS],
delta_tower_angle_trim[B_AXIS],
@ -5931,7 +5937,7 @@ void home_all_axes() { gcode_G28(true); }
if (zero_std_dev < zero_std_dev_min) {
COPY(e_old, delta_endstop_adj);
dr_old = delta_radius;
zh_old = home_offset[Z_AXIS];
zh_old = delta_height;
COPY(ta_old, delta_tower_angle_trim);
}
@ -6015,7 +6021,7 @@ void home_all_axes() { gcode_G28(true); }
else if (zero_std_dev >= test_precision) { // step one back
COPY(delta_endstop_adj, e_old);
delta_radius = dr_old;
home_offset[Z_AXIS] = zh_old;
delta_height = zh_old;
COPY(delta_tower_angle_trim, ta_old);
}
@ -6029,7 +6035,7 @@ void home_all_axes() { gcode_G28(true); }
// adjust delta_height and endstops by the max amount
const float z_temp = MAX3(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
home_offset[Z_AXIS] -= z_temp;
delta_height -= z_temp;
LOOP_XYZ(axis) delta_endstop_adj[axis] -= z_temp;
}
recalc_delta_settings(delta_radius, delta_diagonal_rod, delta_tower_angle_trim);
@ -8981,7 +8987,7 @@ inline void gcode_M205() {
*/
inline void gcode_M665() {
if (parser.seen('H')) {
home_offset[Z_AXIS] = parser.value_linear_units() - DELTA_HEIGHT;
delta_height = parser.value_linear_units();
update_software_endstops(Z_AXIS);
}
if (parser.seen('L')) delta_diagonal_rod = parser.value_linear_units();
@ -10089,7 +10095,7 @@ inline void gcode_M502() {
#endif
#if ENABLED(DELTA) // correct the delta_height
home_offset[Z_AXIS] -= diff;
delta_height -= diff;
#endif
}