From 37ebe5c35d6d74c6a0bfaaaa1d0b9057d8024849 Mon Sep 17 00:00:00 2001 From: Marek Bel <marek.bel@posta.cz> Date: Mon, 23 Apr 2018 20:31:08 +0200 Subject: [PATCH] Move default correction matrix of not calibrated printer to world2machine_default() function. Use world2machine_reset() to uncorrected matrix. Call it from world2machine_revert_to_uncorrected() and from world2machine_default() if there is no default shift to remove code duplication. --- Firmware/mesh_bed_calibration.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 5a9bf4ee..9c5b1271 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -707,22 +707,26 @@ void world2machine_reset() { const float vx[] = { 1.f, 0.f }; const float vy[] = { 0.f, 1.f }; -#ifdef DEFAULT_Y_OFFSET - const float cntr[] = { 0.f, DEFAULT_Y_OFFSET }; -#else const float cntr[] = { 0.f, 0.f }; -#endif world2machine_update(vx, vy, cntr); } +static void world2machine_default() +{ +#ifdef DEFAULT_Y_OFFSET + const float vx[] = { 1.f, 0.f }; + const float vy[] = { 0.f, 1.f }; + const float cntr[] = { 0.f, DEFAULT_Y_OFFSET }; + world2machine_update(vx, vy, cntr); +#else + world2machine_reset(); +#endif +} + void world2machine_revert_to_uncorrected() { if (world2machine_correction_mode != WORLD2MACHINE_CORRECTION_NONE) { - // Reset the machine correction matrix. - const float vx[] = { 1.f, 0.f }; - const float vy[] = { 0.f, 1.f }; - const float cntr[] = { 0.f, 0.f }; - world2machine_update(vx, vy, cntr); + world2machine_reset(); // Wait for the motors to stop and update the current position with the absolute values. st_synchronize(); current_position[X_AXIS] = st_get_position_mm(X_AXIS); @@ -793,7 +797,7 @@ void world2machine_initialize() if (reset) { // SERIAL_ECHOLNPGM("Invalid bed correction matrix. Resetting to identity."); reset_bed_offset_and_skew(); - world2machine_reset(); + world2machine_default(); } else { world2machine_update(vec_x, vec_y, cntr); /*