From 8534bc376c55740e93ca21ac626d56c47da10b91 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 17:56:37 -0700 Subject: [PATCH 1/6] Fix homing of YZ with DUAL_X_CARRIAGE --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a51d483e8..f3b83294c 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1504,7 +1504,7 @@ static void homeaxis(AxisEnum axis) { int axis_home_dir; #ifdef DUAL_X_CARRIAGE - if (axis == X_AXIS) axis_home_dir = x_home_dir(active_extruder); + axis_home_dir = (axis == X_AXIS) ? x_home_dir(active_extruder) : home_dir(axis); #else axis_home_dir = home_dir(axis); #endif From 996d0a9185f12806d51e77b5d163086f21f144d8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 18:06:36 -0700 Subject: [PATCH 2/6] Squish the code down a little --- Marlin/Marlin_main.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index f3b83294c..fb9739aad 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1501,13 +1501,11 @@ static void homeaxis(AxisEnum axis) { if (axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0) { - int axis_home_dir; - - #ifdef DUAL_X_CARRIAGE - axis_home_dir = (axis == X_AXIS) ? x_home_dir(active_extruder) : home_dir(axis); - #else - axis_home_dir = home_dir(axis); - #endif + int axis_home_dir = + #ifdef DUAL_X_CARRIAGE + (axis == X_AXIS) ? x_home_dir(active_extruder) : + #endif + home_dir(axis); // Set the axis position as setup for the move current_position[axis] = 0; From 64268f331263b0ff064274c3ee293f44b1bd144d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 18:16:44 -0700 Subject: [PATCH 3/6] Fixup axis_is_at_home a little --- Marlin/Marlin_main.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index fb9739aad..cc7679242 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -990,10 +990,10 @@ static void axis_is_at_home(int axis) { #endif #ifdef SCARA - float homeposition[3]; - if (axis < 2) { + if (axis == X_AXIS || axis == Y_AXIS) { + float homeposition[3]; for (int i = 0; i < 3; i++) homeposition[i] = base_home_pos(i); // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); @@ -1023,17 +1023,14 @@ static void axis_is_at_home(int axis) { // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } - else { - current_position[axis] = base_home_pos(axis) + home_offset[axis]; - min_pos[axis] = base_min_pos(axis) + home_offset[axis]; - max_pos[axis] = base_max_pos(axis) + home_offset[axis]; } - #else + else + #endif + { current_position[axis] = base_home_pos(axis) + home_offset[axis]; min_pos[axis] = base_min_pos(axis) + home_offset[axis]; max_pos[axis] = base_max_pos(axis) + home_offset[axis]; - #endif + } } /** From c3560e0288cc4c4ee9caeb70abb4f17cbed5d8d5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 19:10:09 -0700 Subject: [PATCH 4/6] Include axis parameter to ultralcd's line_to_current --- Marlin/ultralcd.cpp | 46 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 341eb3c0d..7ed146cb8 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -648,12 +648,12 @@ static void lcd_prepare_menu() { #endif // DELTA_CALIBRATION_MENU -inline void line_to_current() { +inline void line_to_current(AxisEnum axis) { #ifdef DELTA calculate_delta(current_position); - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder); #else - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder); #endif } @@ -667,7 +667,7 @@ static void _lcd_move(const char *name, int axis, int min, int max) { if (min_software_endstops && current_position[axis] < min) current_position[axis] = min; if (max_software_endstops && current_position[axis] > max) current_position[axis] = max; encoderPosition = 0; - line_to_current(); + line_to_current(axis); lcdDrawUpdate = 1; } if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis])); @@ -680,7 +680,7 @@ static void lcd_move_e() { if (encoderPosition != 0) { current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale; encoderPosition = 0; - line_to_current(); + line_to_current(E_AXIS); lcdDrawUpdate = 1; } if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS])); @@ -1803,7 +1803,7 @@ char *ftostr52(const float &x) { if (min_software_endstops && current_position[Z_AXIS] < Z_MIN_POS) current_position[Z_AXIS] = Z_MIN_POS; if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; encoderPosition = 0; - line_to_current(); + line_to_current(Z_AXIS); lcdDrawUpdate = 2; } if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS])); @@ -1811,48 +1811,44 @@ char *ftostr52(const float &x) { if (LCD_CLICKED) { if (!debounce_click) { debounce_click = true; - int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS; - int iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; - if (iy&1) { // Zig zag - ix = (MESH_NUM_X_POINTS - 1) - ix; - } + int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS, + iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; + if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag mbl.set_z(ix, iy, current_position[Z_AXIS]); _lcd_level_bed_position++; if (_lcd_level_bed_position == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) { current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; - line_to_current(); + line_to_current(Z_AXIS); mbl.active = 1; enqueuecommands_P(PSTR("G28")); lcd_return_to_status(); - } else { + } + else { current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; - line_to_current(); + line_to_current(Z_AXIS); ix = _lcd_level_bed_position % MESH_NUM_X_POINTS; iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; - if (iy&1) { // Zig zag - ix = (MESH_NUM_X_POINTS - 1) - ix; - } + if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag current_position[X_AXIS] = mbl.get_x(ix); current_position[Y_AXIS] = mbl.get_y(iy); - line_to_current(); + line_to_current(X_AXIS); lcdDrawUpdate = 2; } } - } else { + } + else { debounce_click = false; } } static void _lcd_level_bed_homing() { if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), "Homing"); - if (axis_known_position[X_AXIS] && - axis_known_position[Y_AXIS] && - axis_known_position[Z_AXIS]) { + if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) { current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); current_position[X_AXIS] = MESH_MIN_X; current_position[Y_AXIS] = MESH_MIN_Y; - line_to_current(); + line_to_current(X_AXIS); _lcd_level_bed_position = 0; lcd_goto_menu(_lcd_level_bed); } @@ -1860,9 +1856,7 @@ char *ftostr52(const float &x) { } static void lcd_level_bed() { - axis_known_position[X_AXIS] = false; - axis_known_position[Y_AXIS] = false; - axis_known_position[Z_AXIS] = false; + axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false; mbl.reset(); enqueuecommands_P(PSTR("G28")); lcdDrawUpdate = 2; From 31932912dd82178ac7010b52ab1694d903b5ee1e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 19:32:37 -0700 Subject: [PATCH 5/6] Use AxisEnum instead of int for _lcd_move --- Marlin/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 7ed146cb8..aa24a7a8f 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -660,7 +660,7 @@ inline void line_to_current(AxisEnum axis) { float move_menu_scale; static void lcd_move_menu_axis(); -static void _lcd_move(const char *name, int axis, int min, int max) { +static void _lcd_move(const char *name, AxisEnum axis, int min, int max) { if (encoderPosition != 0) { refresh_cmd_timeout(); current_position[axis] += float((int)encoderPosition) * move_menu_scale; From 2558c10c6c25bdcf524c118dac45a94a7c09ac8a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 20:06:17 -0700 Subject: [PATCH 6/6] Use the slower feedrate for XY axes --- Marlin/Marlin_main.cpp | 12 ++++++------ Marlin/ultralcd.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a51d483e8..a27795eb5 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3806,23 +3806,23 @@ inline void gcode_M206() { * M666: Set delta endstop adjustment */ inline void gcode_M666() { - for (int8_t i = 0; i < 3; i++) { + for (int8_t i = X_AXIS; i <= Z_AXIS; i++) { if (code_seen(axis_codes[i])) { endstop_adj[i] = code_value(); } } } -#elif defined(Z_DUAL_ENDSTOPS) +#elif defined(Z_DUAL_ENDSTOPS) // !DELTA && defined(Z_DUAL_ENDSTOPS) /** * M666: For Z Dual Endstop setup, set z axis offset to the z2 axis. */ inline void gcode_M666() { - if (code_seen('Z')) z_endstop_adj = code_value(); - SERIAL_ECHOPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj ); - SERIAL_EOL; + if (code_seen('Z')) z_endstop_adj = code_value(); + SERIAL_ECHOPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj); + SERIAL_EOL; } -#endif // DELTA +#endif // !DELTA && defined(Z_DUAL_ENDSTOPS) #ifdef FWRETRACT diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index aa24a7a8f..c96f09899 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1831,7 +1831,7 @@ char *ftostr52(const float &x) { if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag current_position[X_AXIS] = mbl.get_x(ix); current_position[Y_AXIS] = mbl.get_y(iy); - line_to_current(X_AXIS); + line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS); lcdDrawUpdate = 2; } } @@ -1848,7 +1848,7 @@ char *ftostr52(const float &x) { plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); current_position[X_AXIS] = MESH_MIN_X; current_position[Y_AXIS] = MESH_MIN_Y; - line_to_current(X_AXIS); + line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS); _lcd_level_bed_position = 0; lcd_goto_menu(_lcd_level_bed); }