From 0f7393a13e44958ed60371936c0bd2f699d1a137 Mon Sep 17 00:00:00 2001 From: Gabe Rosenhouse Date: Sun, 16 Feb 2014 10:42:29 -0800 Subject: [PATCH] Refactor 'accurate' auto bed leveling to use probe_pt() --- Marlin/Marlin_main.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 783b6da76c..9032713750 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1436,31 +1436,20 @@ void process_commands() for (int xCount=0; xCount < ACCURATE_BED_LEVELING_POINTS; xCount++) { + float z_before; if (probePointCounter == 0) { // raise before probing - do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_RAISE_BEFORE_PROBING); + z_before = Z_RAISE_BEFORE_PROBING; } else { // raise extruder - do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS); + z_before = current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS; } + float measured_z = probe_pt(xProbe, yProbe, z_before); - do_blocking_move_to(xProbe - X_PROBE_OFFSET_FROM_EXTRUDER, yProbe - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]); - - engage_z_probe(); // Engage Z Servo endstop if available - run_z_probe(); - eqnBVector[probePointCounter] = current_position[Z_AXIS]; - retract_z_probe(); - - SERIAL_PROTOCOLPGM("Bed x: "); - SERIAL_PROTOCOL(xProbe); - SERIAL_PROTOCOLPGM(" y: "); - SERIAL_PROTOCOL(yProbe); - SERIAL_PROTOCOLPGM(" z: "); - SERIAL_PROTOCOL(current_position[Z_AXIS]); - SERIAL_PROTOCOLPGM("\n"); + eqnBVector[probePointCounter] = measured_z; eqnAMatrix[probePointCounter + 0*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = xProbe; eqnAMatrix[probePointCounter + 1*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = yProbe;