From 82ef101ed5220280fb11c289790f869b816746d7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 30 Mar 2016 16:41:16 -0700 Subject: [PATCH 1/2] Deploy & Stow in G29 for Delta + Z Servo Endstop --- Marlin/Conditionals.h | 2 +- Marlin/Marlin_main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index 66861b62f1..08c39d4e2b 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -339,7 +339,7 @@ #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER)) #endif - #define SERVO_LEVELING (defined(AUTO_BED_LEVELING_FEATURE) && defined(Z_ENDSTOP_SERVO_NR)) + #define SERVO_LEVELING (ENABLED(AUTO_BED_LEVELING_FEATURE) && defined(Z_ENDSTOP_SERVO_NR) && Z_ENDSTOP_SERVO_NR >= 0) /** * Sled Options diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a7618eaf7d..f789e2b88e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3074,7 +3074,7 @@ inline void gcode_G28() { #if ENABLED(Z_PROBE_SLED) dock_sled(false); // engage (un-dock) the Z probe - #elif ENABLED(Z_PROBE_ALLEN_KEY) //|| SERVO_LEVELING + #elif ENABLED(Z_PROBE_ALLEN_KEY) || (ENABLED(DELTA) && SERVO_LEVELING) deploy_z_probe(); #endif @@ -3342,7 +3342,7 @@ inline void gcode_G28() { #if ENABLED(DELTA) // Allen Key Probe for Delta - #if ENABLED(Z_PROBE_ALLEN_KEY) + #if ENABLED(Z_PROBE_ALLEN_KEY) || SERVO_LEVELING stow_z_probe(); #elif Z_RAISE_AFTER_PROBING > 0 raise_z_after_probing(); // ??? From bc86ee02714d1135721f197fbfe0a6b1cd8e3fc3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 30 Mar 2016 17:19:54 -0700 Subject: [PATCH 2/2] Simplify `homeaxis` with some macros --- Marlin/Marlin_main.cpp | 87 ++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index f789e2b88e..1318f2168f 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1999,24 +1999,33 @@ static void homeaxis(AxisEnum axis) { sync_plan_position(); #if ENABLED(Z_PROBE_SLED) - // Get Probe - if (axis == Z_AXIS) { - if (axis_home_dir < 0) dock_sled(false); - } + #define _Z_SERVO_TEST (axis != Z_AXIS) // deploy Z, servo.move XY + #define _Z_PROBE_SUBTEST false // Z will never be invoked + #define _Z_DEPLOY (dock_sled(false)) + #define _Z_STOW (dock_sled(true)) #elif SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE) - - // Deploy a Z probe if there is one, and homing towards the bed - if (axis == Z_AXIS) { - if (axis_home_dir < 0) deploy_z_probe(); - } - + #define _Z_SERVO_TEST (axis != Z_AXIS) // servo.move XY + #define _Z_PROBE_SUBTEST false // Z will never be invoked + #define _Z_DEPLOY (deploy_z_probe()) + #define _Z_STOW (stow_z_probe()) + #elif HAS_SERVO_ENDSTOPS + #define _Z_SERVO_TEST true // servo.move X, Y, Z + #define _Z_PROBE_SUBTEST (axis == Z_AXIS) // Z is a probe #endif + if (axis == Z_AXIS) { + // If there's a Z probe that needs deployment... + #if ENABLED(Z_PROBE_SLED) || SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE) + // ...and homing Z towards the bed? Deploy it. + if (axis_home_dir < 0) _Z_DEPLOY; + #endif + } + #if HAS_SERVO_ENDSTOPS - // Engage Servo endstop if enabled - if (axis != Z_AXIS && servo_endstop_id[axis] >= 0) { + // Engage an X or Y Servo endstop if enabled + if (_Z_SERVO_TEST && servo_endstop_id[axis] >= 0) { servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][0]); - z_probe_is_active = true; + if (_Z_PROBE_SUBTEST) z_probe_is_active = true; } #endif @@ -2145,43 +2154,31 @@ static void homeaxis(AxisEnum axis) { axis_known_position[axis] = true; axis_homed[axis] = true; - #if ENABLED(Z_PROBE_SLED) - // bring Z probe back - if (axis == Z_AXIS) { - if (axis_home_dir < 0) dock_sled(true); + // Put away the Z probe + #if ENABLED(Z_PROBE_SLED) || SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE) + if (axis == Z_AXIS && axis_home_dir < 0) { + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) { + SERIAL_ECHOLNPGM("> SERVO_LEVELING > " STRINGIFY(_Z_STOW)); + } + #endif + _Z_STOW; } - #elif SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE) + #endif - // Deploy a Z probe if there is one, and homing towards the bed - if (axis == Z_AXIS) { - if (axis_home_dir < 0) { - #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) { - SERIAL_ECHOLNPGM("> SERVO_LEVELING > stow_z_probe"); - } - #endif - stow_z_probe(); - } + // Retract Servo endstop if enabled + #if HAS_SERVO_ENDSTOPS + if (_Z_SERVO_TEST && servo_endstop_id[axis] >= 0) { + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) { + SERIAL_ECHOLNPGM("> SERVO_ENDSTOPS > Stow with servo.move()"); + } + #endif + servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][1]); + if (_Z_PROBE_SUBTEST) z_probe_is_active = false; } - else - #endif - { - #if HAS_SERVO_ENDSTOPS - // Retract Servo endstop if enabled - if (servo_endstop_id[axis] >= 0) { - #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) { - SERIAL_ECHOLNPGM("> SERVO_ENDSTOPS > Stow with servo.move()"); - } - #endif - servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][1]); - z_probe_is_active = false; - } - #endif - } - } #if ENABLED(DEBUG_LEVELING_FEATURE)