From 811967923ab7c9f1cd3a35c3cccba0903e7e61c4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 12 Jun 2016 16:51:28 -0700 Subject: [PATCH 1/2] Fix manual_move to move the correct E stepper --- Marlin/ultralcd.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 0fe780919..5d89ed94b 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -91,8 +91,13 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update - int8_t manual_move_axis = (int8_t)NO_AXIS; millis_t manual_move_start_time = 0; + int8_t manual_move_axis = (int8_t)NO_AXIS; + #if EXTRUDERS > 1 + int8_t manual_move_e_index = 0; + #else + #define manual_move_e_index 0 + #endif bool encoderRateMultiplierEnabled; int32_t lastEncoderMovementMillis; @@ -1208,9 +1213,9 @@ static void lcd_status_screen() { if (manual_move_axis != (int8_t)NO_AXIS && millis() >= manual_move_start_time && !planner.is_full()) { #if ENABLED(DELTA) calculate_delta(current_position); - planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[manual_move_axis]/60, active_extruder); + planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[manual_move_axis]/60, manual_move_e_index); #else - planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[manual_move_axis]/60, active_extruder); + planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[manual_move_axis]/60, manual_move_e_index); #endif manual_move_axis = (int8_t)NO_AXIS; } @@ -1220,7 +1225,14 @@ static void lcd_status_screen() { * Set a flag that lcd_update() should start a move * to "current_position" after a short delay. */ - inline void manual_move_to_current(AxisEnum axis) { + inline void manual_move_to_current(AxisEnum axis + #if EXTRUDERS > 1 + , int8_t eindex=-1 + #endif + ) { + #if EXTRUDERS > 1 + if (axis == E_AXIS) manual_move_e_index = eindex >= 0 ? eindex : active_extruder; + #endif manual_move_start_time = millis() + 500UL; // 1/2 second delay manual_move_axis = (int8_t)axis; } @@ -1259,18 +1271,18 @@ static void lcd_status_screen() { static void lcd_move_z() { _lcd_move(PSTR(MSG_MOVE_Z), Z_AXIS, sw_endstop_min[Z_AXIS], sw_endstop_max[Z_AXIS]); } static void lcd_move_e( #if EXTRUDERS > 1 - uint8_t e + int8_t eindex = -1 #endif ) { ENCODER_DIRECTION_NORMAL(); - #if EXTRUDERS > 1 - unsigned short original_active_extruder = active_extruder; - active_extruder = e; - #endif if (encoderPosition) { current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale; encoderPosition = 0; - manual_move_to_current(E_AXIS); + manual_move_to_current(E_AXIS + #if EXTRUDERS > 1 + , eindex + #endif + ); lcdDrawUpdate = LCDVIEW_REDRAW_NOW; } if (lcdDrawUpdate) { @@ -1292,9 +1304,6 @@ static void lcd_status_screen() { lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS])); } if (LCD_CLICKED) lcd_goto_previous_menu(true); - #if EXTRUDERS > 1 - active_extruder = original_active_extruder; - #endif } #if EXTRUDERS > 1 From 4d2119f83a9578492467d4d7c58707510cd48576 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 12 Jun 2016 16:51:39 -0700 Subject: [PATCH 2/2] _lcd_move => _lcd_move_xyz --- Marlin/ultralcd.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 5d89ed94b..0c8ccc07d 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1245,7 +1245,7 @@ static void lcd_status_screen() { float move_menu_scale; - static void _lcd_move(const char* name, AxisEnum axis, float min, float max) { + static void _lcd_move_xyz(const char* name, AxisEnum axis, float min, float max) { ENCODER_DIRECTION_NORMAL(); if (encoderPosition) { refresh_cmd_timeout(); @@ -1262,13 +1262,13 @@ static void lcd_status_screen() { #if ENABLED(DELTA) static float delta_clip_radius_2 = (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS); static int delta_clip( float a ) { return sqrt(delta_clip_radius_2 - a*a); } - static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(sw_endstop_min[X_AXIS], -clip), min(sw_endstop_max[X_AXIS], clip)); } - static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, max(sw_endstop_min[Y_AXIS], -clip), min(sw_endstop_max[Y_AXIS], clip)); } + static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS, max(sw_endstop_min[X_AXIS], -clip), min(sw_endstop_max[X_AXIS], clip)); } + static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS, max(sw_endstop_min[Y_AXIS], -clip), min(sw_endstop_max[Y_AXIS], clip)); } #else - static void lcd_move_x() { _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, sw_endstop_min[X_AXIS], sw_endstop_max[X_AXIS]); } - static void lcd_move_y() { _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, sw_endstop_min[Y_AXIS], sw_endstop_max[Y_AXIS]); } + static void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS, sw_endstop_min[X_AXIS], sw_endstop_max[X_AXIS]); } + static void lcd_move_y() { _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS, sw_endstop_min[Y_AXIS], sw_endstop_max[Y_AXIS]); } #endif - static void lcd_move_z() { _lcd_move(PSTR(MSG_MOVE_Z), Z_AXIS, sw_endstop_min[Z_AXIS], sw_endstop_max[Z_AXIS]); } + static void lcd_move_z() { _lcd_move_xyz(PSTR(MSG_MOVE_Z), Z_AXIS, sw_endstop_min[Z_AXIS], sw_endstop_max[Z_AXIS]); } static void lcd_move_e( #if EXTRUDERS > 1 int8_t eindex = -1