Browse Source

Merge pull request #4240 from AnHardt/sampler-8-7-16

Today's fix and cleanup collection
pull/1/head
Scott Lahteine 8 years ago
committed by GitHub
parent
commit
aa3ab93971
  1. 15
      Marlin/Conditionals.h
  2. 327
      Marlin/Marlin_main.cpp
  3. 14
      Marlin/ultralcd.cpp

15
Marlin/Conditionals.h

@ -842,5 +842,20 @@
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2 #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
#endif #endif
#endif #endif
/**
* MIN_Z_HEIGHT_FOR_HOMING / Z_RAISE_BETWEEN_PROBINGS
*/
#ifndef MIN_Z_HEIGHT_FOR_HOMING
#ifndef Z_RAISE_BETWEEN_PROBINGS
#define MIN_Z_HEIGHT_FOR_HOMING 0
#else
#define MIN_Z_HEIGHT_FOR_HOMING Z_RAISE_BETWEEN_PROBINGS
#endif
#endif
#ifndef Z_RAISE_BETWEEN_PROBINGS
#define Z_RAISE_BETWEEN_PROBING MIN_Z_HEIGHT_FOR_HOMING
#endif
#endif //CONFIGURATION_LCD #endif //CONFIGURATION_LCD
#endif //CONDITIONALS_H #endif //CONDITIONALS_H

327
Marlin/Marlin_main.cpp

@ -1620,10 +1620,6 @@ static void setup_for_endstop_or_probe_move() {
feedrate_multiplier = 100; feedrate_multiplier = 100;
refresh_cmd_timeout(); refresh_cmd_timeout();
} }
static void setup_for_endstop_move() {
setup_for_endstop_or_probe_move();
endstops.enable();
}
static void clean_up_after_endstop_or_probe_move() { static void clean_up_after_endstop_or_probe_move() {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
@ -2348,161 +2344,134 @@ static void clean_up_after_endstop_or_probe_move() {
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS) #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
static void homeaxis(AxisEnum axis) { static void homeaxis(AxisEnum axis) {
#define HOMEAXIS_DO(LETTER) \
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
if (!(axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0)) return;
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> homeaxis(", axis); SERIAL_ECHOPAIR(">>> homeaxis(", axis);
SERIAL_ECHOLNPGM(")"); SERIAL_ECHOLNPGM(")");
} }
#endif #endif
#define HOMEAXIS_DO(LETTER) \
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
if (axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0) {
int axis_home_dir = int axis_home_dir =
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
(axis == X_AXIS) ? x_home_dir(active_extruder) : (axis == X_AXIS) ? x_home_dir(active_extruder) :
#endif
home_dir(axis);
// Homing Z towards the bed? Deploy the Z probe or endstop.
#if HAS_BED_PROBE
if (axis == Z_AXIS && axis_home_dir < 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
#endif
if (DEPLOY_PROBE()) return;
}
#endif #endif
home_dir(axis);
// Set the axis position as setup for the move // Homing Z towards the bed? Deploy the Z probe or endstop.
current_position[axis] = 0; #if HAS_BED_PROBE
sync_plan_position(); if (axis == Z_AXIS && axis_home_dir < 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
// Set a flag for Z motor locking if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
#if ENABLED(Z_DUAL_ENDSTOPS) #endif
if (axis == Z_AXIS) stepper.set_homing_flag(true); if (DEPLOY_PROBE()) return;
#endif }
#endif
// Move towards the endstop until an endstop is triggered // Set the axis position as setup for the move
destination[axis] = 1.5 * max_length(axis) * axis_home_dir; current_position[axis] = 0;
feedrate = homing_feedrate[axis]; sync_plan_position();
line_to_destination();
stepper.synchronize();
// Set the axis position as setup for the move // Set a flag for Z motor locking
current_position[axis] = 0; #if ENABLED(Z_DUAL_ENDSTOPS)
sync_plan_position(); if (axis == Z_AXIS) stepper.set_homing_flag(true);
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE) // Move towards the endstop until an endstop is triggered
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(false)"); destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
#endif feedrate = homing_feedrate[axis];
endstops.enable(false); // Disable endstops while moving away line_to_destination();
stepper.synchronize();
// Move away from the endstop by the axis HOME_BUMP_MM // Set the axis position as setup for the move
destination[axis] = -home_bump_mm(axis) * axis_home_dir; current_position[axis] = 0;
line_to_destination(); sync_plan_position();
stepper.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE) // Move away from the endstop by the axis HOME_BUMP_MM
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(true)"); destination[axis] = -home_bump_mm(axis) * axis_home_dir;
#endif line_to_destination();
endstops.enable(true); // Enable endstops for next homing move stepper.synchronize();
// Slow down the feedrate for the next move // Slow down the feedrate for the next move
set_homing_bump_feedrate(axis); set_homing_bump_feedrate(axis);
// Move slowly towards the endstop until triggered // Move slowly towards the endstop until triggered
destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir; destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir;
line_to_destination(); line_to_destination();
stepper.synchronize(); stepper.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
#endif #endif
#if ENABLED(Z_DUAL_ENDSTOPS) #if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) { if (axis == Z_AXIS) {
float adj = fabs(z_endstop_adj); float adj = fabs(z_endstop_adj);
bool lockZ1; bool lockZ1;
if (axis_home_dir > 0) { if (axis_home_dir > 0) {
adj = -adj; adj = -adj;
lockZ1 = (z_endstop_adj > 0); lockZ1 = (z_endstop_adj > 0);
} }
else else
lockZ1 = (z_endstop_adj < 0); lockZ1 = (z_endstop_adj < 0);
if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true); if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
sync_plan_position(); sync_plan_position();
// Move to the adjusted endstop height // Move to the adjusted endstop height
feedrate = homing_feedrate[axis]; feedrate = homing_feedrate[axis];
destination[Z_AXIS] = adj; destination[Z_AXIS] = adj;
line_to_destination(); line_to_destination();
stepper.synchronize(); stepper.synchronize();
if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false); if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
stepper.set_homing_flag(false); stepper.set_homing_flag(false);
} // Z_AXIS } // Z_AXIS
#endif #endif
#if ENABLED(DELTA) #if ENABLED(DELTA)
// retrace by the amount specified in endstop_adj // retrace by the amount specified in endstop_adj
if (endstop_adj[axis] * axis_home_dir < 0) { if (endstop_adj[axis] * axis_home_dir < 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE) sync_plan_position();
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(false)"); destination[axis] = endstop_adj[axis];
#endif
endstops.enable(false); // Disable endstops while moving away
sync_plan_position();
destination[axis] = endstop_adj[axis];
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
DEBUG_POS("", destination);
}
#endif
line_to_destination();
stepper.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(true)");
#endif
endstops.enable(true); // Enable endstops for next homing move
}
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
else { if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
SERIAL_ECHOPAIR("> endstop_adj * axis_home_dir = ", endstop_adj[axis] * axis_home_dir); DEBUG_POS("", destination);
SERIAL_EOL;
}
} }
#endif #endif
#endif line_to_destination();
stepper.synchronize();
// Set the axis position to its home position (plus home offsets) }
set_axis_is_at_home(axis); #endif
SYNC_PLAN_POSITION_KINEMATIC(); // Set the axis position to its home position (plus home offsets)
set_axis_is_at_home(axis);
#if ENABLED(DEBUG_LEVELING_FEATURE) SYNC_PLAN_POSITION_KINEMATIC();
if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
#endif
destination[axis] = current_position[axis]; #if ENABLED(DEBUG_LEVELING_FEATURE)
endstops.hit_on_purpose(); // clear endstop hit flags if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
axis_known_position[axis] = true; #endif
axis_homed[axis] = true;
// Put away the Z probe destination[axis] = current_position[axis];
#if HAS_BED_PROBE endstops.hit_on_purpose(); // clear endstop hit flags
if (axis == Z_AXIS && axis_home_dir < 0) { axis_known_position[axis] = true;
#if ENABLED(DEBUG_LEVELING_FEATURE) axis_homed[axis] = true;
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
#endif
if (STOW_PROBE()) return;
}
#endif
} // Put away the Z probe
#if HAS_BED_PROBE
if (axis == Z_AXIS && axis_home_dir < 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
#endif
if (STOW_PROBE()) return;
}
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
@ -2779,8 +2748,6 @@ inline void gcode_G4() {
int x_axis_home_dir = home_dir(X_AXIS); int x_axis_home_dir = home_dir(X_AXIS);
#endif #endif
SYNC_PLAN_POSITION_KINEMATIC();
float mlx = max_length(X_AXIS), mly = max_length(Y_AXIS), float mlx = max_length(X_AXIS), mly = max_length(Y_AXIS),
mlratio = mlx > mly ? mly / mlx : mlx / mly; mlratio = mlx > mly ? mly / mlx : mlx / mly;
@ -2789,30 +2756,9 @@ inline void gcode_G4() {
feedrate = min(homing_feedrate[X_AXIS], homing_feedrate[Y_AXIS]) * sqrt(mlratio * mlratio + 1); feedrate = min(homing_feedrate[X_AXIS], homing_feedrate[Y_AXIS]) * sqrt(mlratio * mlratio + 1);
line_to_destination(); line_to_destination();
stepper.synchronize(); stepper.synchronize();
set_axis_is_at_home(X_AXIS);
set_axis_is_at_home(Y_AXIS);
SYNC_PLAN_POSITION_KINEMATIC();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> QUICK_HOME 1", current_position);
#endif
destination[X_AXIS] = current_position[X_AXIS];
destination[Y_AXIS] = current_position[Y_AXIS];
line_to_destination();
stepper.synchronize();
endstops.hit_on_purpose(); // clear endstop hit flags endstops.hit_on_purpose(); // clear endstop hit flags
current_position[X_AXIS] = destination[X_AXIS]; destination[X_AXIS] = destination[Y_AXIS] = 0;
current_position[Y_AXIS] = destination[Y_AXIS];
#if DISABLED(SCARA)
current_position[Z_AXIS] = destination[Z_AXIS];
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> QUICK_HOME 2", current_position);
#endif
} }
#endif // QUICK_HOME #endif // QUICK_HOME
@ -2866,7 +2812,12 @@ inline void gcode_G28() {
} }
#endif #endif
setup_for_endstop_move(); setup_for_endstop_or_probe_move();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(true)");
#endif
endstops.enable(true); // Enable endstops for next homing move
#if ENABLED(DELTA) #if ENABLED(DELTA)
/** /**
@ -2915,10 +2866,10 @@ inline void gcode_G28() {
#endif #endif
} }
#elif defined(MIN_Z_HEIGHT_FOR_HOMING) && MIN_Z_HEIGHT_FOR_HOMING > 0 #else
// Raise Z before homing X or Y, if specified
if (home_all_axis || homeX || homeY) { if (home_all_axis || homeX || homeY) {
// Raise Z before homing any other axes and z is not already high enough (never lower z)
float z_dest = home_offset[Z_AXIS] + MIN_Z_HEIGHT_FOR_HOMING; float z_dest = home_offset[Z_AXIS] + MIN_Z_HEIGHT_FOR_HOMING;
if (z_dest > current_position[Z_AXIS]) { if (z_dest > current_position[Z_AXIS]) {
@ -2930,19 +2881,13 @@ inline void gcode_G28() {
#endif #endif
feedrate = homing_feedrate[Z_AXIS]; feedrate = homing_feedrate[Z_AXIS];
line_to_z(z_dest);
#if HAS_BED_PROBE stepper.synchronize();
do_blocking_move_to_z(z_dest);
#else
line_to_z(z_dest);
stepper.synchronize();
#endif
destination[Z_AXIS] = current_position[Z_AXIS] = z_dest; destination[Z_AXIS] = current_position[Z_AXIS] = z_dest;
} }
} }
#endif // MIN_Z_HEIGHT_FOR_HOMING #endif
#if ENABLED(QUICK_HOME) #if ENABLED(QUICK_HOME)
@ -3044,36 +2989,30 @@ inline void gcode_G28() {
*/ */
current_position[X_AXIS] = destination[X_AXIS]; current_position[X_AXIS] = destination[X_AXIS];
current_position[Y_AXIS] = destination[Y_AXIS]; current_position[Y_AXIS] = destination[Y_AXIS];
// Home the Z axis
HOMEAXIS(Z);
} }
else if (homeZ) { // Don't need to Home Z twice // Let's see if X and Y are homed
if (axis_unhomed_error(true, true, false)) return;
// Let's see if X and Y are homed /**
if (axis_unhomed_error(true, true, false)) return; * Make sure the Z probe is within the physical limits
* NOTE: This doesn't necessarily ensure the Z probe is also
* within the bed!
*/
float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS];
if ( cpx >= X_MIN_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
&& cpx <= X_MAX_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
&& cpy >= Y_MIN_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)
&& cpy <= Y_MAX_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)) {
/** // Home the Z axis
* Make sure the Z probe is within the physical limits HOMEAXIS(Z);
* NOTE: This doesn't necessarily ensure the Z probe is also }
* within the bed! else {
*/ LCD_MESSAGEPGM(MSG_ZPROBE_OUT);
float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS]; SERIAL_ECHO_START;
if ( cpx >= X_MIN_POS - (X_PROBE_OFFSET_FROM_EXTRUDER) SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT);
&& cpx <= X_MAX_POS - (X_PROBE_OFFSET_FROM_EXTRUDER) }
&& cpy >= Y_MIN_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)
&& cpy <= Y_MAX_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)) {
// Home the Z axis
HOMEAXIS(Z);
}
else {
LCD_MESSAGEPGM(MSG_ZPROBE_OUT);
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT);
}
} // !home_all_axes && homeZ
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
@ -3099,7 +3038,11 @@ inline void gcode_G28() {
#endif // !DELTA (gcode_G28) #endif // !DELTA (gcode_G28)
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.not_homing()");
#endif
endstops.not_homing(); endstops.not_homing();
endstops.hit_on_purpose(); // clear endstop hit flags
// Enable mesh leveling again // Enable mesh leveling again
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
@ -3139,8 +3082,6 @@ inline void gcode_G28() {
clean_up_after_endstop_or_probe_move(); clean_up_after_endstop_or_probe_move();
endstops.hit_on_purpose(); // clear endstop hit flags
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28"); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
#endif #endif

14
Marlin/ultralcd.cpp

@ -978,17 +978,13 @@ static void lcd_status_screen() {
// Note: During Manual Bed Leveling the homed Z position is MESH_HOME_SEARCH_Z // Note: During Manual Bed Leveling the homed Z position is MESH_HOME_SEARCH_Z
// Z position will be restored with the final action, a G28 // Z position will be restored with the final action, a G28
inline void _mbl_goto_xy(float x, float y) { inline void _mbl_goto_xy(float x, float y) {
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + MIN_Z_HEIGHT_FOR_HOMING;
#if MIN_Z_HEIGHT_FOR_HOMING > 0
+ MIN_Z_HEIGHT_FOR_HOMING
#endif
;
line_to_current(Z_AXIS); line_to_current(Z_AXIS);
current_position[X_AXIS] = x + home_offset[X_AXIS]; current_position[X_AXIS] = x + home_offset[X_AXIS];
current_position[Y_AXIS] = y + home_offset[Y_AXIS]; current_position[Y_AXIS] = y + home_offset[Y_AXIS];
line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS); line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS);
#if MIN_Z_HEIGHT_FOR_HOMING > 0 #if MIN_Z_HEIGHT_FOR_HOMING > 0
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; // How do condition and action match?
line_to_current(Z_AXIS); line_to_current(Z_AXIS);
#endif #endif
stepper.synchronize(); stepper.synchronize();
@ -1038,11 +1034,7 @@ static void lcd_status_screen() {
if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) { if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
lcd_goto_screen(_lcd_level_bed_done, true); lcd_goto_screen(_lcd_level_bed_done, true);
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + MIN_Z_HEIGHT_FOR_HOMING;
#if MIN_Z_HEIGHT_FOR_HOMING > 0
+ MIN_Z_HEIGHT_FOR_HOMING
#endif
;
line_to_current(Z_AXIS); line_to_current(Z_AXIS);
stepper.synchronize(); stepper.synchronize();

Loading…
Cancel
Save