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

Today's fix and cleanup collection
This commit is contained in:
Scott Lahteine 2016-07-09 19:09:45 -07:00 committed by GitHub
commit aa3ab93971
3 changed files with 165 additions and 217 deletions

View File

@ -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

View File

@ -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,16 +2344,17 @@ 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)
@ -2394,21 +2391,11 @@ static void homeaxis(AxisEnum axis) {
current_position[axis] = 0; current_position[axis] = 0;
sync_plan_position(); sync_plan_position();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(false)");
#endif
endstops.enable(false); // Disable endstops while moving away
// Move away from the endstop by the axis HOME_BUMP_MM // Move away from the endstop by the axis HOME_BUMP_MM
destination[axis] = -home_bump_mm(axis) * axis_home_dir; destination[axis] = -home_bump_mm(axis) * axis_home_dir;
line_to_destination(); line_to_destination();
stepper.synchronize(); 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
// 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);
@ -2449,10 +2436,6 @@ static void homeaxis(AxisEnum axis) {
#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)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(false)");
#endif
endstops.enable(false); // Disable endstops while moving away
sync_plan_position(); sync_plan_position();
destination[axis] = endstop_adj[axis]; destination[axis] = endstop_adj[axis];
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
@ -2463,19 +2446,7 @@ static void homeaxis(AxisEnum axis) {
#endif #endif
line_to_destination(); line_to_destination();
stepper.synchronize(); 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)
else {
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> endstop_adj * axis_home_dir = ", endstop_adj[axis] * axis_home_dir);
SERIAL_EOL;
}
}
#endif
#endif #endif
// Set the axis position to its home position (plus home offsets) // Set the axis position to its home position (plus home offsets)
@ -2502,8 +2473,6 @@ static void homeaxis(AxisEnum axis) {
} }
#endif #endif
}
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("<<< homeaxis(", axis); SERIAL_ECHOPAIR("<<< homeaxis(", axis);
@ -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];
#if HAS_BED_PROBE
do_blocking_move_to_z(z_dest);
#else
line_to_z(z_dest); line_to_z(z_dest);
stepper.synchronize(); 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,13 +2989,8 @@ 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 // Let's see if X and Y are homed
if (axis_unhomed_error(true, true, false)) return; if (axis_unhomed_error(true, true, false)) return;
@ -3073,7 +3013,6 @@ inline void gcode_G28() {
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT); 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

View File

@ -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();