Merge pull request #7894 from tcm0116/2.0.x-lcd_segmented_moves

[2.0.x] Use segmented moves when moving axis from LCD
This commit is contained in:
Scott Lahteine 2017-10-10 00:28:34 -05:00 committed by GitHub
commit 1f05f10346

View file

@ -461,6 +461,13 @@ uint16_t max_display_update_time = 0;
#define manual_move_e_index 0 #define manual_move_e_index 0
#endif #endif
#if IS_KINEMATIC
bool processing_manual_move = false;
float manual_move_offset = 0.0;
#else
constexpr bool processing_manual_move = false;
#endif
#if PIN_EXISTS(SD_DETECT) #if PIN_EXISTS(SD_DETECT)
uint8_t lcd_sd_status; uint8_t lcd_sd_status;
#endif #endif
@ -2735,9 +2742,45 @@ void kill_screen(const char* lcd_msg) {
* and the planner can accept one, send immediately * and the planner can accept one, send immediately
*/ */
inline void manage_manual_move() { inline void manage_manual_move() {
if (processing_manual_move) return;
if (manual_move_axis != (int8_t)NO_AXIS && ELAPSED(millis(), manual_move_start_time) && !planner.is_full()) { if (manual_move_axis != (int8_t)NO_AXIS && ELAPSED(millis(), manual_move_start_time) && !planner.is_full()) {
#if IS_KINEMATIC
const float old_feedrate = feedrate_mm_s;
feedrate_mm_s = MMM_TO_MMS(manual_feedrate_mm_m[manual_move_axis]);
#if EXTRUDERS > 1
const int8_t old_extruder = active_extruder;
active_extruder = manual_move_e_index;
#endif
// Set movement on a single axis
set_destination_to_current();
destination[manual_move_axis] += manual_move_offset;
// Reset for the next move
manual_move_offset = 0.0;
manual_move_axis = (int8_t)NO_AXIS;
// Set a blocking flag so no new moves can be added until all segments are done
processing_manual_move = true;
prepare_move_to_destination(); // will call set_current_to_destination
processing_manual_move = false;
feedrate_mm_s = old_feedrate;
#if EXTRUDERS > 1
active_extruder = old_extruder;
#endif
#else
planner.buffer_line_kinematic(current_position, MMM_TO_MMS(manual_feedrate_mm_m[manual_move_axis]), manual_move_e_index); planner.buffer_line_kinematic(current_position, MMM_TO_MMS(manual_feedrate_mm_m[manual_move_axis]), manual_move_e_index);
manual_move_axis = (int8_t)NO_AXIS; manual_move_axis = (int8_t)NO_AXIS;
#endif
} }
} }
@ -2770,7 +2813,7 @@ void kill_screen(const char* lcd_msg) {
void _lcd_move_xyz(const char* name, AxisEnum axis) { void _lcd_move_xyz(const char* name, AxisEnum axis) {
if (lcd_clicked) { return lcd_goto_previous_menu(); } if (lcd_clicked) { return lcd_goto_previous_menu(); }
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition && !processing_manual_move) {
gcode.refresh_cmd_timeout(); gcode.refresh_cmd_timeout();
float min = current_position[axis] - 1000, float min = current_position[axis] - 1000,
@ -2788,9 +2831,6 @@ void kill_screen(const char* lcd_msg) {
} }
#endif #endif
// Get the new position
current_position[axis] += float((int32_t)encoderPosition) * move_menu_scale;
// Delta limits XY based on the current offset from center // Delta limits XY based on the current offset from center
// This assumes the center is 0,0 // This assumes the center is 0,0
#if ENABLED(DELTA) #if ENABLED(DELTA)
@ -2800,17 +2840,33 @@ void kill_screen(const char* lcd_msg) {
} }
#endif #endif
// Get the new position
const float diff = float((int32_t)encoderPosition) * move_menu_scale;
#if IS_KINEMATIC
manual_move_offset += diff;
// Limit only when trying to move towards the limit
if ((int32_t)encoderPosition < 0) NOLESS(manual_move_offset, min - current_position[axis]);
if ((int32_t)encoderPosition > 0) NOMORE(manual_move_offset, max - current_position[axis]);
#else
current_position[axis] += diff;
// Limit only when trying to move towards the limit // Limit only when trying to move towards the limit
if ((int32_t)encoderPosition < 0) NOLESS(current_position[axis], min); if ((int32_t)encoderPosition < 0) NOLESS(current_position[axis], min);
if ((int32_t)encoderPosition > 0) NOMORE(current_position[axis], max); if ((int32_t)encoderPosition > 0) NOMORE(current_position[axis], max);
#endif
manual_move_to_current(axis); manual_move_to_current(axis);
encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
if (lcdDrawUpdate) encoderPosition = 0;
lcd_implementation_drawedit(name, move_menu_scale >= 0.1 ? ftostr41sign(current_position[axis]) : ftostr43sign(current_position[axis])); if (lcdDrawUpdate && !processing_manual_move) {
const float pos = current_position[axis]
#if IS_KINEMATIC
+ manual_move_offset
#endif
;
lcd_implementation_drawedit(name, move_menu_scale >= 0.1 ? ftostr41sign(pos) : ftostr43sign(pos));
}
} }
void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS); } void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS); }
void lcd_move_y() { _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS); } void lcd_move_y() { _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS); }
@ -2823,8 +2879,13 @@ void kill_screen(const char* lcd_msg) {
if (lcd_clicked) { return lcd_goto_previous_menu(); } if (lcd_clicked) { return lcd_goto_previous_menu(); }
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale; if (!processing_manual_move) {
encoderPosition = 0; const float diff = float((int32_t)encoderPosition) * move_menu_scale;
#if IS_KINEMATIC
manual_move_offset += diff;
#else
current_position[E_AXIS] += diff;
#endif
manual_move_to_current(E_AXIS manual_move_to_current(E_AXIS
#if E_MANUAL > 1 #if E_MANUAL > 1
, eindex , eindex
@ -2832,7 +2893,9 @@ void kill_screen(const char* lcd_msg) {
); );
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
if (lcdDrawUpdate) { encoderPosition = 0;
}
if (lcdDrawUpdate && !processing_manual_move) {
PGM_P pos_label; PGM_P pos_label;
#if E_MANUAL == 1 #if E_MANUAL == 1
pos_label = PSTR(MSG_MOVE_E); pos_label = PSTR(MSG_MOVE_E);
@ -2851,7 +2914,11 @@ void kill_screen(const char* lcd_msg) {
#endif // E_MANUAL > 2 #endif // E_MANUAL > 2
} }
#endif // E_MANUAL > 1 #endif // E_MANUAL > 1
lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS])); lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS]
#if IS_KINEMATIC
+ manual_move_offset
#endif
));
} }
} }