1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-23 20:18:52 +00:00

Use segmented moves when moving axis from LCD

This commit is contained in:
Thomas Moore 2017-10-07 18:16:41 -05:00 committed by Scott Lahteine
parent 5ad8f5c306
commit 9b0ee53b12

View File

@ -461,6 +461,13 @@ uint16_t max_display_update_time = 0;
#define manual_move_e_index 0
#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)
uint8_t lcd_sd_status;
#endif
@ -2735,9 +2742,45 @@ void kill_screen(const char* lcd_msg) {
* and the planner can accept one, send immediately
*/
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()) {
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;
#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);
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) {
if (lcd_clicked) { return lcd_goto_previous_menu(); }
ENCODER_DIRECTION_NORMAL();
if (encoderPosition) {
if (encoderPosition && !processing_manual_move) {
gcode.refresh_cmd_timeout();
float min = current_position[axis] - 1000,
@ -2788,9 +2831,6 @@ void kill_screen(const char* lcd_msg) {
}
#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
// This assumes the center is 0,0
#if ENABLED(DELTA)
@ -2800,17 +2840,33 @@ void kill_screen(const char* lcd_msg) {
}
#endif
// Limit only when trying to move towards the limit
if ((int32_t)encoderPosition < 0) NOLESS(current_position[axis], min);
if ((int32_t)encoderPosition > 0) NOMORE(current_position[axis], max);
// 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
if ((int32_t)encoderPosition < 0) NOLESS(current_position[axis], min);
if ((int32_t)encoderPosition > 0) NOMORE(current_position[axis], max);
#endif
manual_move_to_current(axis);
encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
}
if (lcdDrawUpdate)
lcd_implementation_drawedit(name, move_menu_scale >= 0.1 ? ftostr41sign(current_position[axis]) : ftostr43sign(current_position[axis]));
encoderPosition = 0;
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_y() { _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS); }
@ -2823,16 +2879,23 @@ void kill_screen(const char* lcd_msg) {
if (lcd_clicked) { return lcd_goto_previous_menu(); }
ENCODER_DIRECTION_NORMAL();
if (encoderPosition) {
current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
encoderPosition = 0;
manual_move_to_current(E_AXIS
#if E_MANUAL > 1
, eindex
if (!processing_manual_move) {
const float diff = float((int32_t)encoderPosition) * move_menu_scale;
#if IS_KINEMATIC
manual_move_offset += diff;
#else
current_position[E_AXIS] += diff;
#endif
);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
manual_move_to_current(E_AXIS
#if E_MANUAL > 1
, eindex
#endif
);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
}
encoderPosition = 0;
}
if (lcdDrawUpdate) {
if (lcdDrawUpdate && !processing_manual_move) {
PGM_P pos_label;
#if E_MANUAL == 1
pos_label = PSTR(MSG_MOVE_E);
@ -2851,7 +2914,11 @@ void kill_screen(const char* lcd_msg) {
#endif // E_MANUAL > 2
}
#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
));
}
}