Browse Source

Merge pull request #4025 from thinkyhead/rc_fix_ultralcd_move_e

Fix manual move for multiple extruders
pull/1/head
Scott Lahteine 9 years ago
committed by GitHub
parent
commit
b4c37a676f
  1. 47
      Marlin/ultralcd.cpp

47
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 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; 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; bool encoderRateMultiplierEnabled;
int32_t lastEncoderMovementMillis; 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 (manual_move_axis != (int8_t)NO_AXIS && millis() >= manual_move_start_time && !planner.is_full()) {
#if ENABLED(DELTA) #if ENABLED(DELTA)
calculate_delta(current_position); 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 #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 #endif
manual_move_axis = (int8_t)NO_AXIS; 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 * Set a flag that lcd_update() should start a move
* to "current_position" after a short delay. * 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_start_time = millis() + 500UL; // 1/2 second delay
manual_move_axis = (int8_t)axis; manual_move_axis = (int8_t)axis;
} }
@ -1233,7 +1245,7 @@ static void lcd_status_screen() {
float move_menu_scale; 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(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
refresh_cmd_timeout(); refresh_cmd_timeout();
@ -1250,27 +1262,27 @@ static void lcd_status_screen() {
#if ENABLED(DELTA) #if ENABLED(DELTA)
static float delta_clip_radius_2 = (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS); 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 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_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(PSTR(MSG_MOVE_Y), Y_AXIS, max(sw_endstop_min[Y_AXIS], -clip), min(sw_endstop_max[Y_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 #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_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(PSTR(MSG_MOVE_Y), Y_AXIS, sw_endstop_min[Y_AXIS], sw_endstop_max[Y_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 #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( static void lcd_move_e(
#if EXTRUDERS > 1 #if EXTRUDERS > 1
uint8_t e int8_t eindex = -1
#endif #endif
) { ) {
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
#if EXTRUDERS > 1
unsigned short original_active_extruder = active_extruder;
active_extruder = e;
#endif
if (encoderPosition) { if (encoderPosition) {
current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale; current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
encoderPosition = 0; encoderPosition = 0;
manual_move_to_current(E_AXIS); manual_move_to_current(E_AXIS
#if EXTRUDERS > 1
, eindex
#endif
);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
if (lcdDrawUpdate) { if (lcdDrawUpdate) {
@ -1292,9 +1304,6 @@ static void lcd_status_screen() {
lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS])); lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS]));
} }
if (LCD_CLICKED) lcd_goto_previous_menu(true); if (LCD_CLICKED) lcd_goto_previous_menu(true);
#if EXTRUDERS > 1
active_extruder = original_active_extruder;
#endif
} }
#if EXTRUDERS > 1 #if EXTRUDERS > 1

Loading…
Cancel
Save