From c3560e0288cc4c4ee9caeb70abb4f17cbed5d8d5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 19:10:09 -0700 Subject: [PATCH 1/3] 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 341eb3c0d0..7ed146cb83 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 2/3] 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 7ed146cb83..aa24a7a8f5 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 3/3] 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 a51d483e8f..a27795eb5c 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 aa24a7a8f5..c96f098994 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); }