From 8db7fb226a515a0b0dd1ca009ea2e27f2a03c5f0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 28 Apr 2018 08:14:20 -0500 Subject: [PATCH] Fix M420 C for UBL --- Marlin/src/feature/bedlevel/ubl/ubl.h | 2 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 8 ++++---- Marlin/src/gcode/bedlevel/M420.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index 0d126daf9..a79d9a67e 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -124,7 +124,7 @@ class unified_bed_leveling { static void reset(); static void invalidate(); static void set_all_mesh_points_to_value(const float value); - static void adjust_mesh_to_mean(const float value); + static void adjust_mesh_to_mean(const bool cflag, const float value); static bool sanity_check(); static void G29() _O0; // O0 for no optimization diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 433e36cbf..8a1cb40c3 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -544,7 +544,7 @@ #endif break; - case 5: adjust_mesh_to_mean(g29_constant); break; + case 5: adjust_mesh_to_mean(g29_c_flag, g29_constant); break; case 6: shift_mesh_height(); break; } @@ -634,7 +634,7 @@ return; } - void unified_bed_leveling::adjust_mesh_to_mean(const float value) { + void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) { float sum = 0.0; int n = 0; for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) @@ -665,7 +665,7 @@ SERIAL_ECHO_F(sigma, 6); SERIAL_EOL(); - if (g29_c_flag) + if (cflag) for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) if (!isnan(z_values[x][y])) @@ -1081,7 +1081,7 @@ SERIAL_EOL(); #endif - adjust_mesh_to_mean(g29_constant); + adjust_mesh_to_mean(g29_c_flag, g29_constant); #if HAS_BED_PROBE SERIAL_PROTOCOLPGM("zprobe_zoffset: "); diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index 2df7d9028..3edcea603 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -116,7 +116,7 @@ void GcodeSuite::M420() { #if ENABLED(AUTO_BED_LEVELING_UBL) set_bed_leveling_enabled(false); - ubl.adjust_mesh_to_mean(cval); + ubl.adjust_mesh_to_mean(true, cval); #else