From 1451b7eacf74c45a29e9ee41ba83c6f659df36a0 Mon Sep 17 00:00:00 2001 From: Roxy-3D Date: Thu, 6 Apr 2017 18:46:47 -0500 Subject: [PATCH] UBL's Grid Based Leveling code Pretty much... The code is in place. Still more work to do. But it has a lot of hooks and variables in other code, so commit and merge before I pick up a million 'Conflicts'. --- Marlin/G26_Mesh_Validation_Tool.cpp | 32 ++-- Marlin/Marlin.h | 9 ++ Marlin/Marlin_main.cpp | 2 - Marlin/_Bootscreen.h | 110 ++++++++++++++ Marlin/least_squares_fit.cpp | 134 +++++++++++++++++ Marlin/ubl.cpp | 19 +-- Marlin/ubl_G29.cpp | 221 ++++++++++++++++++++++++++-- Marlin/ubl_motion.cpp | 41 +++--- 8 files changed, 501 insertions(+), 67 deletions(-) create mode 100644 Marlin/_Bootscreen.h create mode 100644 Marlin/least_squares_fit.cpp diff --git a/Marlin/G26_Mesh_Validation_Tool.cpp b/Marlin/G26_Mesh_Validation_Tool.cpp index 12042a5de..0bf62432a 100644 --- a/Marlin/G26_Mesh_Validation_Tool.cpp +++ b/Marlin/G26_Mesh_Validation_Tool.cpp @@ -219,8 +219,8 @@ move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0); move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount); - ubl.has_control_of_lcd_panel++; - //debug_current_and_destination((char*)"Starting G26 Mesh Validation Pattern."); + ubl.has_control_of_lcd_panel = true; + //debug_current_and_destination(PSTR("Starting G26 Mesh Validation Pattern.")); /** * Declare and generate a sin() & cos() table to be used during the circle drawing. This will lighten @@ -346,12 +346,12 @@ } - //debug_current_and_destination((char*)"Looking for lines to connect."); + //debug_current_and_destination(PSTR("Looking for lines to connect.")); look_for_lines_to_connect(); - //debug_current_and_destination((char*)"Done with line connect."); + //debug_current_and_destination(PSTR("Done with line connect.")); } - //debug_current_and_destination((char*)"Done with current circle."); + //debug_current_and_destination(PSTR("Done with current circle.")); } while (location.x_index >= 0 && location.y_index >= 0); @@ -362,16 +362,16 @@ retract_filament(destination); destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; - //debug_current_and_destination((char*)"ready to do Z-Raise."); + //debug_current_and_destination(PSTR("ready to do Z-Raise.")); move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Raise the nozzle - //debug_current_and_destination((char*)"done doing Z-Raise."); + //debug_current_and_destination(PSTR("done doing Z-Raise.")); destination[X_AXIS] = x_pos; // Move back to the starting position destination[Y_AXIS] = y_pos; //destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Move back to the starting position - //debug_current_and_destination((char*)"done doing X/Y move."); + //debug_current_and_destination(PSTR("done doing X/Y move.")); ubl.has_control_of_lcd_panel = false; // Give back control of the LCD Panel! @@ -458,7 +458,7 @@ SERIAL_ECHOPAIR(", ey=", ey); SERIAL_CHAR(')'); SERIAL_EOL; - //debug_current_and_destination((char*)"Connecting horizontal line."); + //debug_current_and_destination(PSTR("Connecting horizontal line.")); } print_line_from_here_to_there(LOGICAL_X_POSITION(sx), LOGICAL_Y_POSITION(sy), layer_height, LOGICAL_X_POSITION(ex), LOGICAL_Y_POSITION(ey), layer_height); @@ -489,7 +489,7 @@ SERIAL_ECHOPAIR(", ey=", ey); SERIAL_CHAR(')'); SERIAL_EOL; - debug_current_and_destination((char*)"Connecting vertical line."); + debug_current_and_destination(PSTR("Connecting vertical line.")); } print_line_from_here_to_there(LOGICAL_X_POSITION(sx), LOGICAL_Y_POSITION(sy), layer_height, LOGICAL_X_POSITION(ex), LOGICAL_Y_POSITION(ey), layer_height); bit_set(vertical_mesh_line_flags, i, j); // Mark it as done so we don't do it again @@ -525,7 +525,7 @@ stepper.synchronize(); set_destination_to_current(); - //if (ubl.g26_debug_flag) debug_current_and_destination((char*)" in move_to() done with Z move"); + //if (ubl.g26_debug_flag) debug_current_and_destination(PSTR(" in move_to() done with Z move")); } // Check if X or Y is involved in the movement. @@ -538,11 +538,11 @@ destination[Y_AXIS] = y; destination[E_AXIS] += e_delta; - //if (ubl.g26_debug_flag) debug_current_and_destination((char*)" in move_to() doing last move"); + //if (ubl.g26_debug_flag) debug_current_and_destination(PSTR(" in move_to() doing last move")); ubl_line_to_destination(feed_value, 0); - //if (ubl.g26_debug_flag) debug_current_and_destination((char*)" in move_to() after last move"); + //if (ubl.g26_debug_flag) debug_current_and_destination(PSTR(" in move_to() after last move")); stepper.synchronize(); set_destination_to_current(); @@ -613,7 +613,7 @@ //if (ubl.g26_debug_flag) { // SERIAL_ECHOLNPGM(" doing printing move."); - // debug_current_and_destination((char*)"doing final move_to() inside print_line_from_here_to_there()"); + // debug_current_and_destination(PSTR("doing final move_to() inside print_line_from_here_to_there()")); //} move_to(ex, ey, ez, e_pos_delta); // Get to the ending point with an appropriate amount of extrusion } @@ -771,7 +771,7 @@ lcd_setstatuspgm(PSTR("G26 Heating Bed."), 99); lcd_quick_feedback(); #endif - ubl.has_control_of_lcd_panel++; + ubl.has_control_of_lcd_panel = true; thermalManager.setTargetBed(bed_temp); while (abs(thermalManager.degBed() - bed_temp) > 3) { if (ubl_lcd_clicked()) return exit_from_g26(); @@ -808,7 +808,7 @@ if (prime_flag == -1) { // The user wants to control how much filament gets purged - ubl.has_control_of_lcd_panel++; + ubl.has_control_of_lcd_panel = true; lcd_setstatuspgm(PSTR("User-Controlled Prime"), 99); chirp_at_user(); diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 476e92839..d2b168b42 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -288,6 +288,13 @@ float code_value_temp_diff(); void set_bed_leveling_enabled(bool enable=true); #endif +#if ENABLED(AUTO_BED_LEVELING_UBL) +struct linear_fit { + double A, B, D; +}; +struct linear_fit *lsf_linear_fit( double *, double *, double *, int ); +#endif + #if PLANNER_LEVELING void reset_bed_level(); #endif @@ -298,6 +305,8 @@ float code_value_temp_diff(); #if HAS_BED_PROBE extern float zprobe_zoffset; + #define DEPLOY_PROBE() set_probe_deployed(true) + #define STOW_PROBE() set_probe_deployed(false) #endif #if ENABLED(HOST_KEEPALIVE_FEATURE) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index bdcc90365..dd4db8d53 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1983,8 +1983,6 @@ static void clean_up_after_endstop_or_probe_move() { #endif #endif - #define DEPLOY_PROBE() set_probe_deployed(true) - #define STOW_PROBE() set_probe_deployed(false) #if ENABLED(BLTOUCH) void bltouch_command(int angle) { diff --git a/Marlin/_Bootscreen.h b/Marlin/_Bootscreen.h new file mode 100644 index 000000000..0e1f559c5 --- /dev/null +++ b/Marlin/_Bootscreen.h @@ -0,0 +1,110 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Custom Bitmap for splashscreen + * + * You may use one of the following tools to generate the C++ bitmap array from + * a black and white image: + * + * - http://www.marlinfw.org/tools/u8glib/converter.html + * - http://www.digole.com/tools/PicturetoC_Hex_converter.php + */ +//custom screen can be up to 112 wide and 64 high + +#include + +#define CUSTOM_BOOTSCREEN_TIMEOUT 2500 +#define CUSTOM_BOOTSCREEN_BMPWIDTH 112 +#define CUSTOM_BOOTSCREEN_BMPHEIGHT 64 + +// Width: 112, Height: 64 +const unsigned char custom_start_bmp[896] PROGMEM = { + 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x01, 0xf9, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x01, 0xc0, 0x01, + 0x80, 0x00, 0x00, 0x06, 0x4d, 0x00, 0x00, 0x07, 0x38, 0x00, 0x00, 0x01, 0xc0, 0x01, + 0x80, 0x00, 0x00, 0x0c, 0x26, 0x00, 0x0e, 0xe7, 0x39, 0xd3, 0xe1, 0xf3, 0xe7, 0xc1, + 0x80, 0x00, 0x00, 0x19, 0x12, 0x00, 0x0f, 0xe7, 0x39, 0xf7, 0xf3, 0xfb, 0xef, 0xe1, + 0x80, 0x00, 0x00, 0x37, 0xce, 0x00, 0x0e, 0xe7, 0x01, 0xf7, 0x73, 0xb9, 0xce, 0xe1, + 0x80, 0x00, 0x00, 0x64, 0x66, 0x00, 0x0e, 0xe7, 0x01, 0xc7, 0xf3, 0xb9, 0xcf, 0xe1, + 0x80, 0x00, 0x00, 0x4b, 0xa6, 0x00, 0x0e, 0xe7, 0x39, 0xc7, 0xf0, 0xf9, 0xcf, 0xe1, + 0x80, 0x00, 0x00, 0xca, 0xb4, 0x00, 0x0f, 0xe7, 0x39, 0xc7, 0x03, 0xf9, 0xce, 0x01, + 0x80, 0x00, 0x00, 0xcd, 0xa4, 0x00, 0x06, 0xe7, 0x39, 0xc7, 0x73, 0xb9, 0xce, 0xe1, + 0x80, 0x00, 0x03, 0xa6, 0x6c, 0x00, 0x00, 0xe7, 0x39, 0xc7, 0x73, 0xb9, 0xce, 0xe1, + 0x80, 0x00, 0xff, 0x13, 0xd8, 0x00, 0x0e, 0xe3, 0xf1, 0xc7, 0xf3, 0xf9, 0xef, 0xe1, + 0x80, 0x01, 0x21, 0x88, 0x18, 0x00, 0x0f, 0xe1, 0xe1, 0xc3, 0xe1, 0xb9, 0xe7, 0xc1, + 0x80, 0x06, 0x61, 0x16, 0x30, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x04, 0x41, 0x23, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x04, 0xfe, 0x41, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x0b, 0x86, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x1f, 0x80, 0x00, 0x00, 0x01, + 0x80, 0x1e, 0x01, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x1f, 0x80, 0x00, 0x00, 0x01, + 0x80, 0x1c, 0x07, 0x22, 0x00, 0x00, 0x07, 0xbc, 0x3f, 0x9f, 0x81, 0xf8, 0xf1, 0xe1, + 0x80, 0x08, 0x1f, 0xe2, 0x00, 0x00, 0x0f, 0xfc, 0x3f, 0xbf, 0x87, 0xfe, 0x71, 0xc1, + 0x80, 0x00, 0x33, 0x62, 0x00, 0x00, 0x0f, 0x3c, 0x3d, 0xb7, 0x87, 0x9e, 0x7b, 0xc1, + 0x80, 0x00, 0xc2, 0x22, 0x00, 0x00, 0x0f, 0x3c, 0x3d, 0xb7, 0x87, 0x9e, 0x7b, 0xc1, + 0x80, 0x00, 0xc2, 0x3e, 0x00, 0x00, 0x0f, 0x3c, 0x3d, 0xf7, 0x80, 0x7e, 0x3b, 0x81, + 0x80, 0x01, 0xe6, 0x1e, 0x00, 0x00, 0x0f, 0x3c, 0x3d, 0xf7, 0x83, 0xfe, 0x3f, 0x81, + 0x80, 0x01, 0x3c, 0x12, 0x00, 0x00, 0x0f, 0x3c, 0x3d, 0xf7, 0x87, 0x9e, 0x3b, 0x81, + 0x80, 0x01, 0x1c, 0x26, 0x00, 0x00, 0x0f, 0xfc, 0x3d, 0xf7, 0x87, 0x9e, 0x7b, 0xc1, + 0x80, 0x01, 0x70, 0x64, 0x00, 0x00, 0x07, 0xbc, 0x3c, 0xe7, 0x87, 0x9e, 0x7b, 0xc1, + 0x80, 0x03, 0xc0, 0x58, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0xe7, 0x87, 0xfe, 0x71, 0xc1, + 0x80, 0x0d, 0x80, 0xf0, 0x00, 0x00, 0x0f, 0x3c, 0x3c, 0xe7, 0x83, 0xde, 0xf1, 0xe1, + 0x80, 0x1a, 0x00, 0xe0, 0x00, 0x00, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x26, 0x00, 0x40, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + + 0x81, 0x06, 0x00, 0x00, 0x00, 0x00, 0x07, 0x1c, 0x03, 0xc0, 0x20, 0x10, 0x00, 0x01, + 0x83, 0x24, 0x00, 0x00, 0x00, 0x00, 0x08, 0x92, 0x02, 0x20, 0x00, 0x10, 0x00, 0x01, + 0x02, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x02, 0x23, 0x27, 0x39, 0x8c, 0xe1, + 0x06, 0x38, 0x00, 0x00, 0x00, 0x00, 0x03, 0x11, 0x03, 0xc2, 0x24, 0x92, 0x49, 0x01, + 0x04, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x02, 0x02, 0x24, 0x93, 0xc8, 0xc1, + 0x0d, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x08, 0x92, 0x02, 0x02, 0x24, 0x92, 0x08, 0x21, + 0x08, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x1c, 0x02, 0x02, 0x24, 0x99, 0xc9, 0xc1, + 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + + 0x10, 0x30, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x0f, 0xe0, 0x0f, 0x00, 0x01, + 0x30, 0x20, 0x00, 0x37, 0x00, 0x00, 0x00, 0x12, 0x24, 0x08, 0x10, 0x09, 0x00, 0x01, + 0x20, 0x30, 0x00, 0x6d, 0x80, 0x00, 0x00, 0x12, 0x24, 0x09, 0x88, 0x09, 0x00, 0x01, + 0x10, 0x18, 0x1f, 0x60, 0xc0, 0x00, 0x00, 0x12, 0x24, 0x09, 0x48, 0x09, 0x00, 0x01, + 0x30, 0x0c, 0x39, 0xe0, 0x60, 0x00, 0x00, 0x12, 0x24, 0x09, 0x90, 0x09, 0x00, 0x01, + 0x30, 0x07, 0x90, 0x70, 0x60, 0x00, 0x00, 0x12, 0x24, 0x08, 0x60, 0x09, 0x00, 0x01, + 0x10, 0x16, 0xf0, 0x18, 0x20, 0x00, 0x00, 0x12, 0x24, 0x08, 0x10, 0x09, 0x00, 0x01, + 0x1a, 0x10, 0x60, 0x08, 0x30, 0x00, 0x00, 0x12, 0x24, 0x09, 0xc8, 0x09, 0x00, 0x01, + 0x0b, 0x09, 0x80, 0x00, 0x30, 0x00, 0x00, 0x12, 0x24, 0x09, 0x24, 0x09, 0x00, 0x01, + 0x0e, 0x07, 0x80, 0x00, 0x10, 0x00, 0x00, 0x13, 0xe4, 0x89, 0xc4, 0x89, 0xf9, 0x01, + 0x06, 0x1e, 0x40, 0x10, 0x10, 0x00, 0x00, 0x10, 0x05, 0xc8, 0x09, 0xc8, 0x0b, 0x81, + 0x06, 0x00, 0x40, 0x20, 0x10, 0x00, 0x00, 0x0f, 0xf8, 0x8f, 0xf0, 0x8f, 0xf9, 0x01, + 0x03, 0x80, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x01, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +}; + + diff --git a/Marlin/least_squares_fit.cpp b/Marlin/least_squares_fit.cpp new file mode 100644 index 000000000..0dda99359 --- /dev/null +++ b/Marlin/least_squares_fit.cpp @@ -0,0 +1,134 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Least Squares Best Fit By Roxy and Ed Williams + * + * This algorythm is high speed and has a very small code footprint. + * Its results are identical to both the Iterative Least Squares published + * earlier by Roxy and the QR_SOLVE solution. If used in place of QR_SOLVE + * it saves roughly 10KB of program memory. + * + */ + +#include "MarlinConfig.h" + +#if ENABLED(AUTO_BED_LEVELING_UBL) + #include + #include "UBL.h" + #include "Marlin.h" + +double linear_fit_average(double *, int); +double linear_fit_average_squared(double *, int); +double linear_fit_average_mixed_terms(double *, double *, int ); +double linear_fit_average_product(double *matrix1, double *matrix2, int n); +void linear_fit_subtract_mean(double *matrix, double bar, int n); +double linear_fit_max_abs(double *, int); + +struct linear_fit linear_fit_results; + +struct linear_fit *lsf_linear_fit(double *x, double *y, double *z, int n) { + double xbar, ybar, zbar; + double x2bar, y2bar; + double xybar, xzbar, yzbar; + double D; + int i; + + linear_fit_results.A = 0.0; + linear_fit_results.B = 0.0; + linear_fit_results.D = 0.0; + + xbar = linear_fit_average(x, n); + ybar = linear_fit_average(y, n); + zbar = linear_fit_average(z, n); + + linear_fit_subtract_mean( x, xbar, n); + linear_fit_subtract_mean( y, ybar, n); + linear_fit_subtract_mean( z, zbar, n); + + x2bar = linear_fit_average_product( x, x, n); + y2bar = linear_fit_average_product( y, y, n); + xybar = linear_fit_average_product( x, y, n); + xzbar = linear_fit_average_product( x, z, n); + yzbar = linear_fit_average_product( y, z, n); + + D = x2bar*y2bar - xybar*xybar; + for(i=0; iA*xbar - linear_fit_results->B*ybar); + linear_fit_results.D = -(zbar + linear_fit_results.A*xbar + linear_fit_results.B*ybar); + + return &linear_fit_results; +} + + + + +double linear_fit_average(double *matrix, int n) +{ + int i; + double sum=0.0; + + for (i = 0; i < n; i++) + sum += matrix[i]; + return sum / (double) n; +} + +double linear_fit_average_product(double *matrix1, double *matrix2, int n) { + int i; + double sum = 0.0; + + for (i = 0; i < n; i++) + sum += matrix1[i] * matrix2[i]; + return sum / (double) n; +} + + + +void linear_fit_subtract_mean(double *matrix, double bar, int n) { + int i; + + for (i = 0; i < n; i++) { + matrix[i] -= bar; + } + return; +} + +double linear_fit_max_abs(double *matrix, int n) { + int i; + double max_abs = 0.0; + + for(i=0; i 0 @@ -92,15 +92,6 @@ SERIAL_PROTOCOLLNPGM("?In load_state() sanity_check() failed.\n"); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - /** - * These lines can go away in a few weeks. They are just - * to make sure people updating their firmware won't be using - * an incomplete Bed_Leveling.state structure. For speed - * we now multiply by the inverse of the Fade Height instead of - * dividing by it. Soon... all of the old structures will be - * updated, but until then, we try to ease the transition - * for our Beta testers. - */ const float recip = ubl.state.g29_correction_fade_height ? 1.0 / ubl.state.g29_correction_fade_height : 1.0; if (ubl.state.g29_fade_height_multiplier != recip) { ubl.state.g29_fade_height_multiplier = recip; @@ -181,11 +172,11 @@ } if (map0) { - serial_echo_10x_spaces(); + serial_echo_11x_spaces(); serial_echo_xy(GRID_MAX_POINTS_X - 1, GRID_MAX_POINTS_Y - 1); SERIAL_EOL; serial_echo_xy(UBL_MESH_MIN_X, UBL_MESH_MIN_Y); - serial_echo_10x_spaces(); + serial_echo_11x_spaces(); serial_echo_xy(UBL_MESH_MAX_X, UBL_MESH_MAX_Y); SERIAL_EOL; } @@ -231,12 +222,12 @@ if (map0) { serial_echo_xy(UBL_MESH_MIN_X, UBL_MESH_MIN_Y); SERIAL_ECHOPGM(" "); - serial_echo_10x_spaces(); + serial_echo_11x_spaces(); serial_echo_xy(UBL_MESH_MAX_X, UBL_MESH_MIN_Y); SERIAL_EOL; serial_echo_xy(0, 0); SERIAL_ECHOPGM(" "); - serial_echo_10x_spaces(); + serial_echo_11x_spaces(); serial_echo_xy(GRID_MAX_POINTS_X - 1, 0); SERIAL_EOL; } diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp index 9273b6e6e..d52a21067 100644 --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -40,6 +40,7 @@ bool lcd_clicked(); void lcd_implementation_clear(); void lcd_mesh_edit_setup(float initial); + void tilt_mesh_based_on_probed_grid( const bool ); float lcd_mesh_edit(); void lcd_z_offset_edit_setup(float); float lcd_z_offset_edit(); @@ -50,8 +51,7 @@ extern bool code_has_value(); extern float probe_pt(float x, float y, bool, int); extern bool set_probe_deployed(bool); - #define DEPLOY_PROBE() set_probe_deployed(true) - #define STOW_PROBE() set_probe_deployed(false) + bool ProbeStay = true; constexpr float ubl_3_point_1_X = UBL_PROBE_PT_1_X, @@ -302,7 +302,7 @@ // The simple parameter flags and values are 'static' so parameter parsing can be in a support routine. static int g29_verbose_level, phase_value = -1, repetition_cnt, - storage_slot = 0, map_type; //unlevel_value = -1; + storage_slot = 0, map_type, grid_size_G ; //unlevel_value = -1; static bool repeat_flag, c_flag, x_flag, y_flag; static float x_pos, y_pos, measured_z, card_thickness = 0.0, ubl_constant = 0.0; @@ -385,7 +385,20 @@ // return; //} } - //*/ + */ + + if (code_seen('G')) { + uint8_t grid_size_G = code_has_value() ? code_value_int() : 3; + if (grid_size_G < 2) { + SERIAL_PROTOCOLLNPGM("ERROR - grid size must be 2 or more"); + return; + } + if (grid_size_G > GRID_MAX_POINTS_X || grid_size_G > GRID_MAX_POINTS_Y ) { + SERIAL_PROTOCOLLNPGM("ERROR - grid size can NOT exceed GRID_MAX_POINTS_X nor GRID_MAX_POINTS_Y"); + return; + } + tilt_mesh_based_on_probed_grid( code_seen('O')||code_seen('M')); + } if (code_seen('P')) { phase_value = code_value_int(); @@ -488,7 +501,7 @@ SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Checking G29 has control of LCD Panel:"); KEEPALIVE_STATE(PAUSED_FOR_USER); - ubl.has_control_of_lcd_panel++; + ubl.has_control_of_lcd_panel = true; while (!ubl_lcd_clicked()) { safe_delay(250); if (ubl.encoder_diff) { @@ -630,7 +643,7 @@ save_ubl_active_state_and_disable(); //measured_z = probe_pt(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER, ProbeDeployAndStow, g29_verbose_level); - ubl.has_control_of_lcd_panel++; // Grab the LCD Hardware + ubl.has_control_of_lcd_panel = true; // Grab the LCD Hardware measured_z = 1.5; do_blocking_move_to_z(measured_z); // Get close to the bed, but leave some space so we don't damage anything // The user is not going to be locking in a new Z-Offset very often so @@ -646,7 +659,7 @@ do_blocking_move_to_z(measured_z); } while (!ubl_lcd_clicked()); - ubl.has_control_of_lcd_panel++; // There is a race condition for the Encoder Wheel getting clicked. + ubl.has_control_of_lcd_panel = true; // There is a race condition for the Encoder Wheel getting clicked. // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) // or here. So, until we are done looking for a long Encoder Wheel Press, // we need to take control of the panel @@ -744,7 +757,7 @@ void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest) { mesh_index_pair location; - ubl.has_control_of_lcd_panel++; + ubl.has_control_of_lcd_panel = true; save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe DEPLOY_PROBE(); @@ -872,7 +885,7 @@ float measure_business_card_thickness(const float &in_height) { - ubl.has_control_of_lcd_panel++; + ubl.has_control_of_lcd_panel = true; save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe SERIAL_PROTOCOLLNPGM("Place Shim Under Nozzle and Perform Measurement."); @@ -899,7 +912,7 @@ void manually_probe_remaining_mesh(const float &lx, const float &ly, const float &z_clearance, const float &card_thickness, const bool do_ubl_mesh_map) { - ubl.has_control_of_lcd_panel++; + ubl.has_control_of_lcd_panel = true; save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe do_blocking_move_to_z(z_clearance); do_blocking_move_to_xy(lx, ly); @@ -994,6 +1007,16 @@ return UBL_ERR; } + if (code_seen('G')) { + grid_size_G = 3; + if (code_has_value()) + grid_size_G = code_value_int(); + if (!WITHIN(grid_size_G, 2, 10)) { + SERIAL_PROTOCOLLNPGM("Invalid grid probe points specified.\n"); + return UBL_ERR; + } + } + x_flag = code_seen('X') && code_has_value(); x_pos = x_flag ? code_value_float() : current_position[X_AXIS]; if (!WITHIN(RAW_X_POSITION(x_pos), X_MIN_POS, X_MAX_POS)) { @@ -1053,7 +1076,6 @@ return UBL_ERR; } - /* if (code_seen('M')) { // Check if a map type was specified map_type = code_has_value() ? code_value_int() : 0; if (!WITHIN(map_type, 0, 1)) { @@ -1061,7 +1083,6 @@ return UBL_ERR; } } - //*/ return UBL_OK; } @@ -1070,6 +1091,7 @@ * This function goes away after G29 debug is complete. But for right now, it is a handy * routine to dump binary data structures. */ +/* void dump(char * const str, const float &f) { char *ptr; @@ -1087,6 +1109,7 @@ SERIAL_EOL; } +*/ static int ubl_state_at_invocation = 0, ubl_state_recursion_chk = 0; @@ -1438,4 +1461,178 @@ SERIAL_ECHOLNPGM("Done Editing Mesh"); } + + void tilt_mesh_based_on_probed_grid( const bool do_ubl_mesh_map) { + int8_t grid_G_index_to_xpos[grid_size_G]; // UBL MESH X index to be probed + int8_t grid_G_index_to_ypos[grid_size_G]; // UBL MESH Y index to be probed + int8_t i, j ,k, xCount, yCount, G_X_index, G_Y_index; // counter variables + float z_values_G[grid_size_G][grid_size_G]; + + struct linear_fit *results; + + for (G_Y_index = 0; G_Y_index < grid_size_G; G_Y_index++) + for (G_X_index = 0; G_X_index < grid_size_G; G_X_index++) + z_values_G[G_X_index][G_Y_index] = NAN; + + uint8_t x_min = GRID_MAX_POINTS_X - 1; + uint8_t x_max = 0; + uint8_t y_min = GRID_MAX_POINTS_Y - 1; + uint8_t y_max = 0; + + //find min & max probeable points in the mesh + for (xCount = 0; xCount < GRID_MAX_POINTS_X ; xCount++) { + for (yCount = 0; yCount < GRID_MAX_POINTS_Y ; yCount++) { + if (WITHIN(ubl.mesh_index_to_xpos[xCount], MIN_PROBE_X, MAX_PROBE_X) && WITHIN(ubl.mesh_index_to_ypos[yCount], MIN_PROBE_Y, MAX_PROBE_Y)) { + if (x_min > xCount) x_min = xCount; + if (x_max < xCount) x_max = xCount; + if (y_min > yCount) y_min = yCount; + if (y_max < yCount) y_max = yCount; + } + } + } + + if ((x_max - x_min + 1) < (grid_size_G) || (y_max - y_min + 1) < (grid_size_G)) { + SERIAL_PROTOCOLPAIR("ERROR - probeable UBL MESH smaller than grid - X points: ", x_max - x_min + 1); + SERIAL_PROTOCOLPAIR(" Y points: ", y_max - y_min + 1); + SERIAL_PROTOCOLLNPAIR(" grid: ", grid_size_G); + return; + } + + // populate X matrix + for (G_X_index = 0; G_X_index < grid_size_G; G_X_index++) { + grid_G_index_to_xpos[G_X_index] = x_min + G_X_index * (x_max - x_min)/(grid_size_G - 1); + if (G_X_index > 0 && grid_G_index_to_xpos[G_X_index - 1] == grid_G_index_to_xpos[G_X_index] ) { + grid_G_index_to_xpos[G_X_index] = grid_G_index_to_xpos[G_X_index - 1] + 1; + } + } + + // populate Y matrix + for (G_Y_index = 0; G_Y_index < grid_size_G; G_Y_index++) { + grid_G_index_to_ypos[G_Y_index] = y_min + G_Y_index * (y_max - y_min)/(grid_size_G - 1); + if (G_Y_index > 0 && grid_G_index_to_ypos[G_Y_index -1] == grid_G_index_to_ypos[G_Y_index] ) { + grid_G_index_to_ypos[G_Y_index] = grid_G_index_to_ypos[G_Y_index - 1] + 1; + } + } + + ubl.has_control_of_lcd_panel = true; + save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe + + DEPLOY_PROBE(); + + // this is a copy of the G29 AUTO_BED_LEVELING_BILINEAR method/code + #undef PROBE_Y_FIRST + #if ENABLED(PROBE_Y_FIRST) + #define PR_OUTER_VAR xCount + #define PR_OUTER_NUM grid_size_G + #define PR_INNER_VAR yCount + #define PR_INNER_NUM grid_size_G + #else + #define PR_OUTER_VAR yCount + #define PR_OUTER_NUM grid_size_G + #define PR_INNER_VAR xCount + #define PR_INNER_NUM grid_size_G + #endif + + bool zig = PR_OUTER_NUM & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION + + // Outer loop is Y with PROBE_Y_FIRST disabled + for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_NUM; PR_OUTER_VAR++) { + + int8_t inStart, inStop, inInc; + +SERIAL_PROTOCOLPAIR("\nPR_OUTER_VAR: ", PR_OUTER_VAR); + + if (zig) { // away from origin + inStart = 0; + inStop = PR_INNER_NUM; + inInc = 1; + } + else { // towards origin + inStart = PR_INNER_NUM - 1; + inStop = -1; + inInc = -1; + } + + zig = !zig; // zag + + // Inner loop is Y with PROBE_Y_FIRST enabled + for (PR_INNER_VAR = inStart; PR_INNER_VAR != inStop; PR_INNER_VAR += inInc) { +SERIAL_PROTOCOLPAIR("\nPR_INNER_VAR: ", PR_INNER_VAR); + +SERIAL_PROTOCOLPAIR("\nCheckpoint: ", 1); + + // end of G29 AUTO_BED_LEVELING_BILINEAR method/code + if (ubl_lcd_clicked()) { +SERIAL_PROTOCOLPAIR("\nCheckpoint: ", 2); + SERIAL_PROTOCOLLNPGM("\nGrid only partially populated.\n"); + lcd_quick_feedback(); + STOW_PROBE(); +SERIAL_PROTOCOLPAIR("\nCheckpoint: ", 3); + while (ubl_lcd_clicked()) idle(); +SERIAL_PROTOCOLPAIR("\nCheckpoint: ", 4); + ubl.has_control_of_lcd_panel = false; + restore_ubl_active_state_and_leave(); + safe_delay(50); // Debounce the Encoder wheel + return; + } +SERIAL_PROTOCOLPAIR("\nCheckpoint: ", 5); + + const float probeX = ubl.mesh_index_to_xpos[grid_G_index_to_xpos[xCount]], //where we want the probe to be + probeY = ubl.mesh_index_to_ypos[grid_G_index_to_ypos[yCount]]; +SERIAL_PROTOCOLPAIR("\nCheckpoint: ", 6); + + const float measured_z = probe_pt(LOGICAL_X_POSITION(probeX), LOGICAL_Y_POSITION(probeY), code_seen('E'), (code_seen('V') && code_has_value()) ? code_value_int() : 0 ); // takes into account the offsets + +SERIAL_PROTOCOLPAIR("\nmeasured_z: ", measured_z ); + + z_values_G[xCount][yCount] = measured_z; +//SERIAL_PROTOCOLLNPGM("\nFine Tuning of Mesh Stopped."); + } + } + +SERIAL_PROTOCOL("\nDone probing...\n"); + + STOW_PROBE(); + restore_ubl_active_state_and_leave(); + +// ?? ubl.has_control_of_lcd_panel = true; +// do_blocking_move_to_xy(ubl.mesh_index_to_xpos[grid_G_index_to_xpos[0]], ubl.mesh_index_to_ypos[grid_G_index_to_ypos[0]]); + + // least squares code +double xxx9[] = { 0,50,100,150,200, 20,70,120,165,195, 0,50,100,150,200, 0,55,100,150,200, 0,65,100,150,205 }; +double yyy9[] = { 0, 1, 2, 3, 4, 50, 51, 52, 53, 54, 100, 101,102,103,104, 150,151,152,153,154, 200,201,202,203,204 }; +double zzz9[] = { 0.01,.002,-.01,-.02,0, 0.01,.002,-.01,-.02,0, 0.01,.002,-.01,-.02,0, 0.01,.002,-.01,-.02,0, 0.01,.002,-.01,-.012,0.01}; +int nine_size = sizeof(xxx9) / sizeof(double); + +double xxx0[] = { 0.0, 0.0, 1.0 }; // Expect [0,0,0.1,0] +double yyy0[] = { 0.0, 1.0, 0.0 }; +double zzz0[] = { 0.1, 0.1, 0.1 }; +int zero_size = sizeof(xxx0) / sizeof(double); + +double xxx[] = { 0.0, 0.0, 1.0, 1.0 }; // Expect [0.1,0,0.05,0] +double yyy[] = { 0.0, 1.0, 0.0, 1.0 }; +double zzz[] = { 0.05, 0.05, 0.15, 0.15 }; +int three_size = sizeof(xxx) / sizeof(double); + + results = lsf_linear_fit(xxx9, yyy9, zzz9, nine_size); +SERIAL_PROTOCOLPAIR("\nxxx9->A =", results->A); +SERIAL_PROTOCOLPAIR("\nxxx9->B =", results->B); +SERIAL_PROTOCOLPAIR("\nxxx9->D =", results->D); +SERIAL_PROTOCOL("\n"); + + results = lsf_linear_fit(xxx0, yyy0, zzz0, zero_size); +SERIAL_PROTOCOLPAIR("\nxxx0->A =", results->A); +SERIAL_PROTOCOLPAIR("\nxxx0->B =", results->B); +SERIAL_PROTOCOLPAIR("\nxxx0->D =", results->D); +SERIAL_PROTOCOL("\n"); + + results = lsf_linear_fit(xxx, yyy, zzz, three_size); +SERIAL_PROTOCOLPAIR("\nxxx->A =", results->A); +SERIAL_PROTOCOLPAIR("\nxxx->B =", results->B); +SERIAL_PROTOCOLPAIR("\nxxx->D =", results->D); +SERIAL_PROTOCOL("\n"); + + return; + } // end of tilt_mesh_based_on_probed_grid() + #endif // AUTO_BED_LEVELING_UBL diff --git a/Marlin/ubl_motion.cpp b/Marlin/ubl_motion.cpp index 4bd34dd31..9847dfea8 100644 --- a/Marlin/ubl_motion.cpp +++ b/Marlin/ubl_motion.cpp @@ -39,7 +39,7 @@ SERIAL_ECHO_F(destination[X_AXIS], 6); } - void debug_current_and_destination(char *title) { + void debug_current_and_destination(const char *title) { // if the title message starts with a '!' it is so important, we are going to // ignore the status of the g26_debug_flag @@ -85,12 +85,6 @@ SERIAL_ECHO(title); SERIAL_EOL; - SET_INPUT_PULLUP(66); // Roxy's Left Switch is on pin 66. Right Switch is on pin 65 - - //if (been_to_2_6) { - //while ((digitalRead(66) & 0x01) != 0) - // idle(); - //} } void ubl_line_to_destination(const float &feed_rate, uint8_t extruder) { @@ -124,7 +118,7 @@ SERIAL_ECHOPAIR(", ee=", end[E_AXIS]); SERIAL_CHAR(')'); SERIAL_EOL; - debug_current_and_destination((char*)"Start of ubl_line_to_destination()"); + debug_current_and_destination(PSTR("Start of ubl_line_to_destination()")); } if (cell_start_xi == cell_dest_xi && cell_start_yi == cell_dest_yi) { // if the whole move is within the same cell, @@ -144,7 +138,7 @@ set_current_to_destination(); if (ubl.g26_debug_flag) - debug_current_and_destination((char*)"out of bounds in ubl_line_to_destination()"); + debug_current_and_destination(PSTR("out of bounds in ubl_line_to_destination()")); return; } @@ -181,7 +175,7 @@ z_optimized = z0; z0 = ubl.get_z_correction(end[X_AXIS], end[Y_AXIS]); if (fabs(z_optimized - z0) > .01 || isnan(z0) || isnan(z_optimized)) { - debug_current_and_destination((char*)"FINAL_MOVE: z_correction()"); + debug_current_and_destination(PSTR("FINAL_MOVE: z_correction()")); if (isnan(z0)) SERIAL_ECHO(" z0==NAN "); if (isnan(z_optimized)) SERIAL_ECHO(" z_optimized==NAN "); SERIAL_ECHOPAIR(" end[X_AXIS]=", end[X_AXIS]); @@ -191,7 +185,8 @@ SERIAL_ECHOPAIR(" err=",fabs(z_optimized - z0)); SERIAL_EOL; } - //*/ + */ + z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]); /** @@ -206,7 +201,7 @@ planner.buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z0 + ubl.state.z_offset, end[E_AXIS], feed_rate, extruder); if (ubl.g26_debug_flag) - debug_current_and_destination((char*)"FINAL_MOVE in ubl_line_to_destination()"); + debug_current_and_destination(PSTR("FINAL_MOVE in ubl_line_to_destination()")); set_current_to_destination(); return; @@ -286,7 +281,7 @@ z_optimized = z0; z0 = ubl.get_z_correction(x, next_mesh_line_y); if (fabs(z_optimized - z0) > .01 || isnan(z0) || isnan(z_optimized)) { - debug_current_and_destination((char*)"VERTICAL z_correction()"); + debug_current_and_destination(PSTR("VERTICAL z_correction()")); if (isnan(z0)) SERIAL_ECHO(" z0==NAN "); if (isnan(z_optimized)) SERIAL_ECHO(" z_optimized==NAN "); SERIAL_ECHOPAIR(" x=", x); @@ -296,7 +291,7 @@ SERIAL_ECHOPAIR(" err=",fabs(z_optimized-z0)); SERIAL_ECHO("\n"); } - //*/ + */ z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]); @@ -333,7 +328,7 @@ } if (ubl.g26_debug_flag) - debug_current_and_destination((char*)"vertical move done in ubl_line_to_destination()"); + debug_current_and_destination(PSTR("vertical move done in ubl_line_to_destination()")); // // Check if we are at the final destination. Usually, we won't be, but if it is on a Y Mesh Line, we are done. @@ -371,7 +366,7 @@ z_optimized = z0; z0 = ubl.get_z_correction(next_mesh_line_x, y); if (fabs(z_optimized - z0) > .01 || isnan(z0) || isnan(z_optimized)) { - debug_current_and_destination((char*)"HORIZONTAL z_correction()"); + debug_current_and_destination(PSTR("HORIZONTAL z_correction()")); if (isnan(z0)) SERIAL_ECHO(" z0==NAN "); if (isnan(z_optimized)) SERIAL_ECHO(" z_optimized==NAN "); SERIAL_ECHOPAIR(" next_mesh_line_x=", next_mesh_line_x); @@ -381,7 +376,7 @@ SERIAL_ECHOPAIR(" err=",fabs(z_optimized-z0)); SERIAL_ECHO("\n"); } - //*/ + */ z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]); @@ -418,7 +413,7 @@ } if (ubl.g26_debug_flag) - debug_current_and_destination((char*)"horizontal move done in ubl_line_to_destination()"); + debug_current_and_destination(PSTR("horizontal move done in ubl_line_to_destination()")); if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS]) goto FINAL_MOVE; @@ -466,7 +461,7 @@ z_optimized = z0; z0 = ubl.get_z_correction(x, next_mesh_line_y); if (fabs(z_optimized - z0) > .01 || isnan(z0) || isnan(z_optimized)) { - debug_current_and_destination((char*)"General_1: z_correction()"); + debug_current_and_destination(PSTR("General_1: z_correction()")); if (isnan(z0)) SERIAL_ECHO(" z0==NAN "); if (isnan(z_optimized)) SERIAL_ECHO(" z_optimized==NAN "); { SERIAL_ECHOPAIR(" x=", x); @@ -477,7 +472,7 @@ SERIAL_ECHOPAIR(" err=",fabs(z_optimized-z0)); SERIAL_ECHO("\n"); } - //*/ + */ z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]); @@ -517,7 +512,7 @@ z_optimized = z0; z0 = ubl.get_z_correction(next_mesh_line_x, y); if (fabs(z_optimized - z0) > .01 || isnan(z0) || isnan(z_optimized)) { - debug_current_and_destination((char*)"General_2: z_correction()"); + debug_current_and_destination(PSTR("General_2: z_correction()")); if (isnan(z0)) SERIAL_ECHO(" z0==NAN "); if (isnan(z_optimized)) SERIAL_ECHO(" z_optimized==NAN "); SERIAL_ECHOPAIR(" next_mesh_line_x=", next_mesh_line_x); @@ -527,7 +522,7 @@ SERIAL_ECHOPAIR(" err=",fabs(z_optimized-z0)); SERIAL_ECHO("\n"); } - //*/ + */ z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]); @@ -557,7 +552,7 @@ } if (ubl.g26_debug_flag) - debug_current_and_destination((char*)"generic move done in ubl_line_to_destination()"); + debug_current_and_destination(PSTR("generic move done in ubl_line_to_destination()")); if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS]) goto FINAL_MOVE;