From 2822c0890a041038b9a32eeff5212cbc709a347d Mon Sep 17 00:00:00 2001 From: Robert Stein Date: Thu, 30 Jan 2020 20:17:15 +0100 Subject: [PATCH 01/22] Set up DIAG endstops for BTT SKR 1.4 / 1.4 Turbo (#16727) --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 55 ++++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index 8e2a0cec231a..90b5edca88a0 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -37,12 +37,53 @@ // #define SERVO0_PIN P2_00 +// +// TMC StallGuard DIAG pins +// +#define X_DIAG_PIN P1_29 // X-STOP +#define Y_DIAG_PIN P1_28 // Y-STOP +#define Z_DIAG_PIN P1_27 // Z-STOP +#define E0_DIAG_PIN P1_26 // E0DET +#define E1_DIAG_PIN P1_25 // E1DET + // // Limit Switches // -#define X_STOP_PIN P1_29 -#define Y_STOP_PIN P1_28 -#define Z_STOP_PIN P1_27 +#if X_STALL_SENSITIVITY + #if X_HOME_DIR < 0 + #define X_MIN_PIN X_DIAG_PIN + #define X_MAX_PIN P1_26 // E0DET + #else + #define X_MAX_PIN X_DIAG_PIN + #define X_MIN_PIN P1_26 // E0DET + #endif +#else + #define X_STOP_PIN P1_29 // X-STOP +#endif + +#if Y_STALL_SENSITIVITY + #if Y_HOME_DIR < 0 + #define Y_MIN_PIN Y_DIAG_PIN + #define Y_MAX_PIN P1_25 // E1DET + #else + #define Y_MAX_PIN Y_DIAG_PIN + #define Y_MIN_PIN P1_25 // E1DET + #endif +#else + #define Y_STOP_PIN P1_28 // Y-STOP +#endif + +#if Z_STALL_SENSITIVITY + #if Z_HOME_DIR < 0 + #define Z_MIN_PIN Z_DIAG_PIN + #define Z_MAX_PIN P1_24 // PWRDET + #else + #define Z_MAX_PIN Z_DIAG_PIN + #define Z_MIN_PIN P1_24 // PWRDET + #endif +#else + #define Z_STOP_PIN P1_27 // Z-STOP +#endif // // Z Probe (when not Z_MIN_PIN) @@ -54,21 +95,21 @@ // // Filament Runout Sensor // -#define FIL_RUNOUT_PIN P1_26 -#define FIL_RUNOUT2_PIN P1_25 +#define FIL_RUNOUT_PIN P1_26 // E0DET +#define FIL_RUNOUT2_PIN P1_25 // E1DET // // Power Supply Control // #ifndef PS_ON_PIN - #define PS_ON_PIN P1_00 + #define PS_ON_PIN P1_00 // PWRDET #endif // // Power Loss Detection // #ifndef POWER_LOSS_PIN - #define POWER_LOSS_PIN P1_00 + #define POWER_LOSS_PIN P1_00 // PWRDET #endif // From e8e25b80d1d3a78f3e5358e8992bd4a4900d6c1c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 30 Jan 2020 13:29:08 -0600 Subject: [PATCH 02/22] Extend RX/TX pins for up to 8 extruders --- Marlin/src/pins/linux/pins_RAMPS_LINUX.h | 18 ++++++++++++++++++ Marlin/src/pins/ramps/pins_RAMPS.h | 18 ++++++++++++++++++ Marlin/src/pins/ramps/pins_TT_OSCAR.h | 3 +++ Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h | 18 ++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 2cb6fb597b54..d21c487e579b 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -363,6 +363,24 @@ #ifndef E4_SERIAL_RX_PIN #define E4_SERIAL_RX_PIN -1 #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif #endif ////////////////////////// diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index f6ccff24f67e..b7e9df475904 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -390,6 +390,24 @@ #ifndef E4_SERIAL_RX_PIN #define E4_SERIAL_RX_PIN -1 #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif #endif // diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index 1c40729a8788..145817b48496 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -147,6 +147,9 @@ #define E3_SERIAL_RX_PIN -1 #define E4_SERIAL_TX_PIN -1 #define E4_SERIAL_RX_PIN -1 + #define E5_SERIAL_RX_PIN -1 + #define E6_SERIAL_RX_PIN -1 + #define E7_SERIAL_RX_PIN -1 #endif // diff --git a/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h b/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h index 8545dc488acf..d94f5e44cb3c 100644 --- a/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h +++ b/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h @@ -285,4 +285,22 @@ #ifndef E4_SERIAL_RX_PIN #define E4_SERIAL_RX_PIN -1 #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif #endif From 62f52ebb3a0ef69b166407d1f6b0e8ed9627397f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 30 Jan 2020 14:09:33 -0600 Subject: [PATCH 03/22] Fix up, improve endstop pin auto-assignment Followup for #16723 --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 12 ++--- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 9 ++-- Marlin/src/pins/pins.h | 50 +++++++++++++++------ 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h index 2b6595cd74e0..4889e4d3c3cd 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -36,11 +36,10 @@ * Limit Switches */ #if X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN #if X_HOME_DIR < 0 - #define X_MIN_PIN X_DIAG_PIN #define X_MAX_PIN P1_28 // X+ #else - #define X_MAX_PIN X_DIAG_PIN #define X_MIN_PIN P1_28 // X+ #endif #else @@ -49,11 +48,10 @@ #endif #if Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN #if Y_HOME_DIR < 0 - #define Y_MIN_PIN Y_DIAG_PIN #define Y_MAX_PIN P1_26 // Y+ #else - #define Y_MAX_PIN Y_DIAG_PIN #define Y_MIN_PIN P1_26 // Y+ #endif #else @@ -62,11 +60,10 @@ #endif #if Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN #if Z_HOME_DIR < 0 - #define Z_MIN_PIN Z_DIAG_PIN #define Z_MAX_PIN P1_24 // Z+ #else - #define Z_MAX_PIN Z_DIAG_PIN #define Z_MIN_PIN P1_24 // Z+ #endif #else @@ -184,9 +181,6 @@ #define E1_SERIAL_TX_PIN P1_04 #define E1_SERIAL_RX_PIN P1_01 - #define Z2_SERIAL_TX_PIN P1_04 - #define Z2_SERIAL_RX_PIN P1_01 - // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 #endif diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index 90b5edca88a0..d0dcd5008a90 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -50,11 +50,10 @@ // Limit Switches // #if X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN #if X_HOME_DIR < 0 - #define X_MIN_PIN X_DIAG_PIN #define X_MAX_PIN P1_26 // E0DET #else - #define X_MAX_PIN X_DIAG_PIN #define X_MIN_PIN P1_26 // E0DET #endif #else @@ -62,11 +61,10 @@ #endif #if Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN #if Y_HOME_DIR < 0 - #define Y_MIN_PIN Y_DIAG_PIN #define Y_MAX_PIN P1_25 // E1DET #else - #define Y_MAX_PIN Y_DIAG_PIN #define Y_MIN_PIN P1_25 // E1DET #endif #else @@ -74,11 +72,10 @@ #endif #if Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN #if Z_HOME_DIR < 0 - #define Z_MIN_PIN Z_DIAG_PIN #define Z_MAX_PIN P1_24 // PWRDET #else - #define Z_MAX_PIN Z_DIAG_PIN #define Z_MIN_PIN P1_24 // PWRDET #endif #else diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 736dbdace0c3..4df871a50ce1 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -1026,10 +1026,14 @@ #ifdef X_STOP_PIN #if X_HOME_DIR < 0 #define X_MIN_PIN X_STOP_PIN - #define X_MAX_PIN -1 + #ifndef X_MAX_PIN + #define X_MAX_PIN -1 + #endif #else - #define X_MIN_PIN -1 #define X_MAX_PIN X_STOP_PIN + #ifndef X_MIN_PIN + #define X_MIN_PIN -1 + #endif #endif #elif X_HOME_DIR < 0 #define X_STOP_PIN X_MIN_PIN @@ -1040,10 +1044,14 @@ #ifdef Y_STOP_PIN #if Y_HOME_DIR < 0 #define Y_MIN_PIN Y_STOP_PIN - #define Y_MAX_PIN -1 + #ifndef Y_MAX_PIN + #define Y_MAX_PIN -1 + #endif #else - #define Y_MIN_PIN -1 #define Y_MAX_PIN Y_STOP_PIN + #ifndef Y_MIN_PIN + #define Y_MIN_PIN -1 + #endif #endif #elif Y_HOME_DIR < 0 #define Y_STOP_PIN Y_MIN_PIN @@ -1054,10 +1062,14 @@ #ifdef Z_STOP_PIN #if Z_HOME_DIR < 0 #define Z_MIN_PIN Z_STOP_PIN - #define Z_MAX_PIN -1 + #ifndef Z_MAX_PIN + #define Z_MAX_PIN -1 + #endif #else - #define Z_MIN_PIN -1 #define Z_MAX_PIN Z_STOP_PIN + #ifndef Z_MIN_PIN + #define Z_MIN_PIN -1 + #endif #endif #elif Z_HOME_DIR < 0 #define Z_STOP_PIN Z_MIN_PIN @@ -1127,9 +1139,11 @@ * overridden in Configuration.h or Configuration_adv.h. */ +#define __PEXI(p,q) PIN_EXISTS(E##p##_##q) +#define _PEXI(p,q) __PEXI(p,q) #define __EPIN(p,q) E##p##_##q##_PIN #define _EPIN(p,q) __EPIN(p,q) -#define DIAG_REMAPPED(P,Q) (PIN_EXISTS(Q) && (P##_DIAG_PIN == Q##_PIN)) +#define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN) // The X2 axis, if any, should be the next open extruder port #define X2_E_INDEX E_STEPPERS @@ -1167,7 +1181,8 @@ // // Auto-assign pins for stallGuard sensorless homing // - #if X2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(X2_E_INDEX, DIAG) > 0 + #if X2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG) + #define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG) #if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file... #define X2_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(X2, Y_MIN) @@ -1184,6 +1199,7 @@ #define _X2_USE_ENDSTOP(P) _E##P##_DIAG_ #define X2_USE_ENDSTOP _X2_USE_ENDSTOP(X2_E_INDEX) #endif + #undef X2_DIAG_PIN #endif #define Y2_E_INDEX INCREMENT(X2_E_INDEX) @@ -1234,7 +1250,8 @@ #define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX) #endif #endif - #if Y2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Y2_E_INDEX, DIAG) > 0 + #if Y2_STALL_SENSITIVITY && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG) + #define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG) #if DIAG_REMAPPED(Y2, X_MIN) #define Y2_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(Y2, Y_MIN) @@ -1251,6 +1268,7 @@ #define _Y2_USE_ENDSTOP(P) _E##P##_DIAG_ #define Y2_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX) #endif + #undef Y2_DIAG_PIN #endif #define Z2_E_INDEX INCREMENT(Y2_E_INDEX) #else @@ -1300,7 +1318,8 @@ #define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX) #endif #endif - #if Z2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z2_E_INDEX, DIAG) > 0 + #if Z2_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 2 && _PEXI(Z2_E_INDEX, DIAG) + #define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG) #if DIAG_REMAPPED(Z2, X_MIN) #define Z2_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(Z2, Y_MIN) @@ -1317,6 +1336,7 @@ #define _Z2_USE_ENDSTOP(P) _E##P##_DIAG_ #define Z2_USE_ENDSTOP _Z2_USE_ENDSTOP(Z2_E_INDEX) #endif + #undef Z2_DIAG_PIN #endif #define Z3_E_INDEX INCREMENT(Z2_E_INDEX) #else @@ -1367,7 +1387,8 @@ #define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX) #endif #endif - #if Z3_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z3_E_INDEX, DIAG) > 0 + #if Z3_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && _PEXI(Z3_E_INDEX, DIAG) + #define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG) #if DIAG_REMAPPED(Z3, X_MIN) #define Z3_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(Z3, Y_MIN) @@ -1382,8 +1403,9 @@ #define Z3_USE_ENDSTOP _ZMAX_ #else #define _Z3_USE_ENDSTOP(P) _E##P##_DIAG_ - #define Z3_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX) + #define Z3_USE_ENDSTOP _Z3_USE_ENDSTOP(Z3_E_INDEX) #endif + #undef Z3_DIAG_PIN #endif #define Z4_E_INDEX INCREMENT(Z3_E_INDEX) #endif @@ -1432,7 +1454,8 @@ #define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX) #endif #endif - #if Z4_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z4_E_INDEX, DIAG) > 0 + #if Z4_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && _PEXI(Z4_E_INDEX, DIAG) + #define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG) #if DIAG_REMAPPED(Z4, X_MIN) #define Z4_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(Z4, Y_MIN) @@ -1449,6 +1472,7 @@ #define _Z4_USE_ENDSTOP(P) _E##P##_DIAG_ #define Z4_USE_ENDSTOP _Z4_USE_ENDSTOP(Z4_E_INDEX) #endif + #undef Z4_DIAG_PIN #endif #endif From e4679c1b787887c466fa607b7408f69e420f4b90 Mon Sep 17 00:00:00 2001 From: Artur Petrzak Date: Fri, 31 Jan 2020 01:00:37 +0100 Subject: [PATCH 04/22] (21) PT100 for MCUs with 3.3v logic (#16731) --- Marlin/Configuration.h | 3 +- Marlin/src/lcd/thermistornames.h | 4 +- Marlin/src/module/thermistor/thermistor_21.h | 77 ++++++++++++++++++++ Marlin/src/module/thermistor/thermistors.h | 6 +- 4 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 Marlin/src/module/thermistor/thermistor_21.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 7f242dce7967..550ea354676f 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -379,7 +379,8 @@ * 13 : 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" * 15 : 100k thermistor calibration for JGAurora A5 hotend * 18 : ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327 - * 20 : Pt100 with circuit in the Ultimainboard V2.x + * 20 : Pt100 with circuit in the Ultimainboard V2.x with 5v excitation (AVR) + * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v excitation (STM32 \ LPC176x....) * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x * 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 * 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index 17772d788045..9cfb80fba3d8 100644 --- a/Marlin/src/lcd/thermistornames.h +++ b/Marlin/src/lcd/thermistornames.h @@ -85,7 +85,9 @@ #elif THERMISTOR_ID == 18 #define THERMISTOR_NAME "ATC Semitec 204GT-2" #elif THERMISTOR_ID == 20 - #define THERMISTOR_NAME "Pt100 UltiMB" + #define THERMISTOR_NAME "Pt100 UltiMB 5v" +#elif THERMISTOR_ID == 21 + #define THERMISTOR_NAME "Pt100 UltiMB 3.3v" #elif THERMISTOR_ID == 201 #define THERMISTOR_NAME "Pt100 OverLord" #elif THERMISTOR_ID == 60 diff --git a/Marlin/src/module/thermistor/thermistor_21.h b/Marlin/src/module/thermistor/thermistor_21.h new file mode 100644 index 000000000000..e65f90b75dca --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_21.h @@ -0,0 +1,77 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2019 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 . + * + */ +#pragma once + +#define REVERSE_TEMP_SENSOR_RANGE + +#undef OV_SCALE +#define OV_SCALE(N) (float((N) * 5) / 3.3f) + +// Pt100 with INA826 amp with 3.3v excitation based on "Pt100 with INA826 amp on Ultimaker v2.0 electronics" +const short temptable_21[][2] PROGMEM = { + { OV( 0), 0 }, + { OV(227), 1 }, + { OV(236), 10 }, + { OV(245), 20 }, + { OV(253), 30 }, + { OV(262), 40 }, + { OV(270), 50 }, + { OV(279), 60 }, + { OV(287), 70 }, + { OV(295), 80 }, + { OV(304), 90 }, + { OV(312), 100 }, + { OV(320), 110 }, + { OV(329), 120 }, + { OV(337), 130 }, + { OV(345), 140 }, + { OV(353), 150 }, + { OV(361), 160 }, + { OV(369), 170 }, + { OV(377), 180 }, + { OV(385), 190 }, + { OV(393), 200 }, + { OV(401), 210 }, + { OV(409), 220 }, + { OV(417), 230 }, + { OV(424), 240 }, + { OV(432), 250 }, + { OV(440), 260 }, + { OV(447), 270 }, + { OV(455), 280 }, + { OV(463), 290 }, + { OV(470), 300 }, + { OV(478), 310 }, + { OV(485), 320 }, + { OV(493), 330 }, + { OV(500), 340 }, + { OV(507), 350 }, + { OV(515), 360 }, + { OV(522), 370 }, + { OV(529), 380 }, + { OV(537), 390 }, + { OV(544), 400 }, + { OV(614), 500 } +}; + +#undef OV_SCALE +#define OV_SCALE(N) (N) diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 875f742ccb28..58e1ef115f25 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -37,7 +37,8 @@ #error "MAX_RAW_THERMISTOR_VALUE is too large for int16_t. Reduce OVERSAMPLENR or HAL_ADC_RESOLUTION." #endif -#define OV(N) int16_t((N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) +#define OV_SCALE(N) (N) +#define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) #define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTOR_HEATER_6 == n || THERMISTOR_HEATER_7 == n || THERMISTORBED == n || THERMISTORCHAMBER == n || THERMISTORPROBE == n) @@ -105,6 +106,9 @@ #if ANY_THERMISTOR_IS(20) // Pt100 with INA826 amp on Ultimaker v2.0 electronics #include "thermistor_20.h" #endif +#if ANY_THERMISTOR_IS(21) // Pt100 with INA826 amp with 3.3v excitation based on "Pt100 with INA826 amp on Ultimaker v2.0 electronics" + #include "thermistor_21.h" +#endif #if ANY_THERMISTOR_IS(51) // beta25 = 4092 K, R25 = 100 kOhm, Pull-up = 1 kOhm, "EPCOS" #include "thermistor_51.h" #endif From dabf3939209fd8ea7f6a6327d764c16743aa22aa Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 31 Jan 2020 00:06:46 +0000 Subject: [PATCH 05/22] [cron] Bump distribution date (2020-01-31) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 4b933d032791..89b5d02c6352 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-01-30" + #define STRING_DISTRIBUTION_DATE "2020-01-31" #endif /** From 02f61832c02dd7cb0287ed0dd498c0e003561bd4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 30 Jan 2020 23:24:34 -0600 Subject: [PATCH 06/22] Add sanity-check for new Advanced Pause option Followup to #16372 --- Marlin/src/inc/SanityCheck.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a91131e083f9..ea66232ff2e3 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -718,14 +718,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(ADVANCED_PAUSE_FEATURE) #if !HAS_RESUME_CONTINUE #error "ADVANCED_PAUSE_FEATURE currently requires an LCD controller or EMERGENCY_PARSER." + #elif DISABLED(NOZZLE_PARK_FEATURE) + #error "ADVANCED_PAUSE_FEATURE requires NOZZLE_PARK_FEATURE." + #elif !defined(FILAMENT_UNLOAD_PURGE_FEEDRATE) + #error "ADVANCED_PAUSE_FEATURE requires FILAMENT_UNLOAD_PURGE_FEEDRATE. Please add it to Configuration_adv.h." #elif ENABLED(EXTRUDER_RUNOUT_PREVENT) #error "EXTRUDER_RUNOUT_PREVENT is incompatible with ADVANCED_PAUSE_FEATURE." #elif ENABLED(PARK_HEAD_ON_PAUSE) && NONE(SDSUPPORT, NEWPANEL, EMERGENCY_PARSER) #error "PARK_HEAD_ON_PAUSE requires SDSUPPORT, EMERGENCY_PARSER, or an LCD controller." #elif ENABLED(HOME_BEFORE_FILAMENT_CHANGE) && DISABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT) #error "HOME_BEFORE_FILAMENT_CHANGE requires PAUSE_PARK_NO_STEPPER_TIMEOUT." - #elif DISABLED(NOZZLE_PARK_FEATURE) - #error "ADVANCED_PAUSE_FEATURE requires NOZZLE_PARK_FEATURE." #elif ENABLED(PREVENT_LENGTHY_EXTRUDE) && FILAMENT_CHANGE_UNLOAD_LENGTH > EXTRUDE_MAXLENGTH #error "FILAMENT_CHANGE_UNLOAD_LENGTH must be less than or equal to EXTRUDE_MAXLENGTH." #elif ENABLED(PREVENT_LENGTHY_EXTRUDE) && FILAMENT_CHANGE_SLOW_LOAD_LENGTH > EXTRUDE_MAXLENGTH From c4df5cf9a6c14f5527abc5ce3551b05733f326f1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 31 Jan 2020 04:40:33 -0600 Subject: [PATCH 07/22] Include macros for delta ABC --- Marlin/src/module/delta.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index 3f61907e5171..a506eade1ae3 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -26,6 +26,7 @@ */ #include "../core/types.h" +#include "../core/macros.h" extern float delta_height; extern abc_float_t delta_endstop_adj; From 0a6ae664bd3f01eab1caacd63c3dcdc043333d92 Mon Sep 17 00:00:00 2001 From: Acenotass <44540957+Acenotass@users.noreply.github.com> Date: Sat, 1 Feb 2020 09:43:44 +0600 Subject: [PATCH 08/22] Update Russian language (#16745) --- Marlin/src/lcd/language/language_ru.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index d7e4de5dd203..f86a0bcfc494 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -332,9 +332,9 @@ namespace Language_ru { PROGMEM Language_Str MSG_HOME_FIRST = _UxGT("Паркуй %s%s%s сначала"); PROGMEM Language_Str MSG_ZPROBE_OFFSETS = _UxGT("Отступы Z-датчика"); - PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("Смещение по X"); - PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Смещение по Y"); - PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Смещение по Z"); + PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("Смещение X"); + PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Смещение Y"); + PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Смещение Z"); PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Микрошаг X"); PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Микрошаг Y"); PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Микрошаг Z"); From 300b81bfcb50e8d5b832570be65a4c3b8baa9ff2 Mon Sep 17 00:00:00 2001 From: rebel1 <453277+rebel1@users.noreply.github.com> Date: Sat, 1 Feb 2020 04:46:02 +0100 Subject: [PATCH 09/22] Fix BTT SKR 1.4 extra endstop pins (#16738) --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index d0dcd5008a90..13bd2b951f89 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -74,9 +74,9 @@ #if Z_STALL_SENSITIVITY #define Z_STOP_PIN Z_DIAG_PIN #if Z_HOME_DIR < 0 - #define Z_MAX_PIN P1_24 // PWRDET + #define Z_MAX_PIN P1_00 // PWRDET #else - #define Z_MIN_PIN P1_24 // PWRDET + #define Z_MIN_PIN P1_00 // PWRDET #endif #else #define Z_STOP_PIN P1_27 // Z-STOP From 5b3d968634d817c310e751bd59e1274295459218 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Fri, 31 Jan 2020 19:51:59 -0800 Subject: [PATCH 10/22] Option for Trigorilla 1.4 with add-on endstops board (#16737) --- Marlin/src/pins/ramps/pins_TRIGORILLA_14.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index 987d2a07561c..f3155fdb0997 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -38,10 +38,13 @@ #endif // -// Limit Switches +// Custom Limit Switches // -#define X_MAX_PIN 43 -#define Y_MIN_PIN 19 +//#define ANYCUBIC_4_MAX_PRO_ENDSTOPS +#if ENABLED(ANYCUBIC_4_MAX_PRO_ENDSTOPS) + #define X_MAX_PIN 43 + #define Y_MIN_PIN 19 +#endif // Labeled pins #define TRIGORILLA_HEATER_BED_PIN 8 From 9a8de23858b3ec1b19542db4fd6c5e5419e6ee98 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Fri, 31 Jan 2020 21:08:37 -0800 Subject: [PATCH 11/22] Consistent M112 with Emergency Parser (#16747) --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 61ed04aaea46..702f82e7708a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1050,7 +1050,7 @@ void Temperature::manage_heater() { #endif #if ENABLED(EMERGENCY_PARSER) - if (emergency_parser.killed_by_M112) kill(); + if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true); #endif if (!raw_temps_ready) return; From 1af05797d7e571cf619f5672fb9b2fb9fc5442d2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Feb 2020 00:27:11 -0600 Subject: [PATCH 12/22] Improve mfadd helper script - Use the original branch name if none is supplied - Set the remote tracking to the source - Accept User/Branch or User:Branch syntax --- buildroot/share/git/mfadd | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/buildroot/share/git/mfadd b/buildroot/share/git/mfadd index 92b2e0063ec6..30be1ec0f748 100755 --- a/buildroot/share/git/mfadd +++ b/buildroot/share/git/mfadd @@ -1,20 +1,24 @@ #!/usr/bin/env bash # -# mfadd (user|ref) [copyname] +# mfadd user[:branch] [copyname] # # Add a remote and fetch it. Optionally copy a branch. # -# Example: mfadd myfork:patch-1 copy_of_patch-1 +# Examples: +# mfadd thefork +# mfadd thefork:patch-1 +# mfadd thefork:patch-1 the_patch_12345 # -[[ $# > 0 && $# < 3 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` (user|ref) [copyname]" 1>&2 ; exit 1; } +[[ $# > 0 && $# < 3 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` user[:branch] [copyname]" 1>&2 ; exit 1; } -# If a colon is included, split the parts -if [[ $1 =~ ":" ]]; then - IFS=':' read -a DATA <<< "$1" +# If a colon or slash is included, split the parts +if [[ $1 =~ ":" || $1 =~ "/" ]]; then + [[ $1 =~ ":" ]] && IFS=':' || IFS="/" + read -a DATA <<< "$1" USER=${DATA[0]} BRANCH=${DATA[1]} - NAME=$2 + NAME=${2:-$BRANCH} else USER=$1 fi @@ -29,4 +33,4 @@ echo "Adding and fetching $USER..." git remote add "$USER" "git@github.com:$USER/$REPO.git" >/dev/null 2>&1 || echo "Remote exists." git fetch "$USER" -[[ ! -z "$BRANCH" && ! -z "$NAME" ]] && git checkout $USER/$BRANCH -b $NAME +[[ ! -z "$BRANCH" && ! -z "$NAME" ]] && git checkout -b "$NAME" --track "$USER/$BRANCH" From e64b7a3ab27dd1f0dc56e227b42295e5c931df62 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Feb 2020 00:57:14 -0600 Subject: [PATCH 13/22] Clean up i2c encoder, sanitize serial --- Marlin/src/feature/I2CPositionEncoder.cpp | 40 +++++++++++---------- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 4 +-- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Marlin/src/feature/I2CPositionEncoder.cpp b/Marlin/src/feature/I2CPositionEncoder.cpp index c3b182c72a0f..07f3aa21415d 100644 --- a/Marlin/src/feature/I2CPositionEncoder.cpp +++ b/Marlin/src/feature/I2CPositionEncoder.cpp @@ -162,15 +162,17 @@ void I2CPositionEncoder::update() { if (errIdx == 0) { // In order to correct for "error" but avoid correcting for noise and non-skips // it must be > threshold and have a difference average of < 10 and be < 2000 steps - if (ABS(error) > threshold * planner.settings.axis_steps_per_mm[encoderAxis] && - diffSum < 10 * (I2CPE_ERR_ARRAY_SIZE - 1) && ABS(error) < 2000) { // Check for persistent error (skip) + if (ABS(error) > threshold * planner.settings.axis_steps_per_mm[encoderAxis] + && diffSum < 10 * (I2CPE_ERR_ARRAY_SIZE - 1) + && ABS(error) < 2000 + ) { // Check for persistent error (skip) errPrst[errPrstIdx++] = error; // Error must persist for I2CPE_ERR_PRST_ARRAY_SIZE error cycles. This also serves to improve the average accuracy if (errPrstIdx >= I2CPE_ERR_PRST_ARRAY_SIZE) { float sumP = 0; LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i]; const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE)); SERIAL_ECHO(axis_codes[encoderAxis]); - SERIAL_ECHOLNPAIR(" - err detected: ", errorP * planner.steps_to_mm[encoderAxis], "mm; correcting!"); + SERIAL_ECHOLNPAIR(" : CORRECT ERR ", errorP * planner.steps_to_mm[encoderAxis], "mm"); babystep.add_steps(encoderAxis, -LROUND(errorP)); errPrstIdx = 0; } @@ -189,7 +191,8 @@ void I2CPositionEncoder::update() { if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.settings.axis_steps_per_mm[encoderAxis]) { const millis_t ms = millis(); if (ELAPSED(ms, nextErrorCountTime)) { - SERIAL_ECHOLNPAIR("Large error on ", axis_codes[encoderAxis], " axis. error: ", (int)error, "; diffSum: ", diffSum); + SERIAL_ECHO(axis_codes[encoderAxis]); + SERIAL_ECHOLNPAIR(" : LARGE ERR ", int(error), "; diffSum=", diffSum); errorCount++; nextErrorCountTime = ms + I2CPE_ERR_CNT_DEBOUNCE_MS; } @@ -243,17 +246,14 @@ bool I2CPositionEncoder::passes_test(const bool report) { } float I2CPositionEncoder::get_axis_error_mm(const bool report) { - float target, actual, error; - - target = planner.get_axis_position_mm(encoderAxis); - actual = mm_from_count(position); - error = actual - target; - - if (ABS(error) > 10000) error = 0; // ? + const float target = planner.get_axis_position_mm(encoderAxis), + actual = mm_from_count(position), + diff = actual - target, + error = ABS(diff) > 10000 ? 0 : diff; // Huge error is a bad reading if (report) { SERIAL_ECHO(axis_codes[encoderAxis]); - SERIAL_ECHOLNPAIR(" axis target: ", target, ", actual: ", actual, ", error : ",error); + SERIAL_ECHOLNPAIR(" axis target=", target, "mm; actual=", actual, "mm; err=", error, "mm"); } return error; @@ -278,21 +278,25 @@ int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) { //convert both 'ticks' into same units / base encoderCountInStepperTicksScaled = LROUND((stepperTicksPerUnit * encoderTicks) / encoderTicksPerUnit); - int32_t target = stepper.position(encoderAxis), - error = (encoderCountInStepperTicksScaled - target); + const int32_t target = stepper.position(encoderAxis); + int32_t error = encoderCountInStepperTicksScaled - target; //suppress discontinuities (might be caused by bad I2C readings...?) const bool suppressOutput = (ABS(error - errorPrev) > 100); + errorPrev = error; + if (report) { SERIAL_ECHO(axis_codes[encoderAxis]); - SERIAL_ECHOLNPAIR(" axis target: ", target, ", actual: ", encoderCountInStepperTicksScaled, ", error : ", error); - if (suppressOutput) SERIAL_ECHOLNPGM("Discontinuity detected, suppressing error."); + SERIAL_ECHOLNPAIR(" axis target=", target, "; actual=", encoderCountInStepperTicksScaled, "; err=", error); } - errorPrev = error; + if (suppressOutput) { + if (report) SERIAL_ECHOLNPGM("!Discontinuity. Suppressing error."); + error = 0; + } - return (suppressOutput ? 0 : error); + return error; } int32_t I2CPositionEncoder::get_raw_count() { diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 203d7c715076..c8f3b45b0d95 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -1629,7 +1629,7 @@ auto debug_pt = [](PGM_P const pre, const xy_pos_t &pos, const float &zadd) { d_from(); serialprintPGM(pre); DEBUG_ECHO_F(normed(pos, zadd), 6); - DEBUG_ECHOLNPAIR_F(" Z error: ", zadd - get_z_correction(pos), 6); + DEBUG_ECHOLNPAIR_F(" Z error = ", zadd - get_z_correction(pos), 6); }; debug_pt(PSTR("1st point: "), probe_pt[0], normal.z * z1); debug_pt(PSTR("2nd point: "), probe_pt[1], normal.z * z2); @@ -1638,7 +1638,7 @@ DEBUG_ECHOLNPAIR_F("0 : ", normed(safe_homing_xy, 0), 6); d_from(); DEBUG_ECHOPGM("safe home with Z="); DEBUG_ECHOLNPAIR_F("mesh value ", normed(safe_homing_xy, get_z_correction(safe_homing_xy)), 6); - DEBUG_ECHOPAIR(" Z error: (", Z_SAFE_HOMING_X_POINT, ",", Z_SAFE_HOMING_Y_POINT); + DEBUG_ECHOPAIR(" Z error = (", Z_SAFE_HOMING_X_POINT, ",", Z_SAFE_HOMING_Y_POINT); DEBUG_ECHOLNPAIR_F(") = ", get_z_correction(safe_homing_xy), 6); #endif } // DEBUGGING(LEVELING) From 43d3463d5d612a300789bdc7a845eb2e8a37786d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Feb 2020 03:50:26 -0600 Subject: [PATCH 14/22] Misc cleanup, whitespace --- Marlin/src/feature/baricuda.cpp | 2 +- Marlin/src/module/stepper.cpp | 6 +++--- Marlin/src/module/temperature.cpp | 5 ++--- Marlin/src/pins/sam/pins_CNCONTROLS_15D.h | 6 +++--- Marlin/src/sd/SdVolume.cpp | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Marlin/src/feature/baricuda.cpp b/Marlin/src/feature/baricuda.cpp index 82e0a5f14f50..354e8482a562 100644 --- a/Marlin/src/feature/baricuda.cpp +++ b/Marlin/src/feature/baricuda.cpp @@ -20,7 +20,7 @@ * */ -#include "../inc/MarlinConfig.h" +#include "../inc/MarlinConfigPre.h" #if ENABLED(BARICUDA) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 4e46ea56cd4c..90848c99d177 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2460,10 +2460,10 @@ void Stepper::report_positions() { #define BABYSTEP_AXIS(AXIS, INVERT, DIR) { \ const uint8_t old_dir = _READ_DIR(AXIS); \ - _ENABLE_AXIS(AXIS); \ - DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY); \ + _ENABLE_AXIS(AXIS); \ + DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY); \ _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^DIR^INVERT); \ - DELAY_NS(MINIMUM_STEPPER_POST_DIR_DELAY); \ + DELAY_NS(MINIMUM_STEPPER_POST_DIR_DELAY); \ _SAVE_START; \ _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \ _PULSE_WAIT; \ diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 702f82e7708a..d90a2123d163 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2608,9 +2608,8 @@ void Temperature::tick() { #if ENABLED(FAN_SOFT_PWM) #define _FAN_PWM(N) do{ \ - uint8_t &spcf = soft_pwm_count_fan[N]; \ - spcf = (spcf & pwm_mask) + (soft_pwm_amount_fan[N] >> 1); \ - WRITE_FAN(N, spcf > pwm_mask ? HIGH : LOW); \ + const uint8_t spcf = (soft_pwm_count_fan[N] & pwm_mask) + (soft_pwm_amount_fan[N] >> 1); \ + WRITE_FAN(N, (spcf > pwm_mask)); \ }while(0) #if HAS_FAN0 _FAN_PWM(0); diff --git a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h index fe9bfb9afd08..6238b8258849 100644 --- a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h +++ b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h @@ -52,11 +52,11 @@ // Analog Inputs // #define TEMP_0_PIN 1 -#define TEMP_1_PIN 2 -#define TEMP_BED_PIN 4 +#define TEMP_1_PIN 2 +#define TEMP_BED_PIN 4 #ifndef TEMP_CHAMBER_PIN - #define TEMP_CHAMBER_PIN 5 + #define TEMP_CHAMBER_PIN 5 #endif // diff --git a/Marlin/src/sd/SdVolume.cpp b/Marlin/src/sd/SdVolume.cpp index 70dfa52e300c..1db562a80aa8 100644 --- a/Marlin/src/sd/SdVolume.cpp +++ b/Marlin/src/sd/SdVolume.cpp @@ -292,7 +292,7 @@ int32_t SdVolume::freeClusterCount() { if (cacheBuffer_.fat32[i] == 0) free++; } #ifdef ESP32 - // Needed to reset the idle task watchdog timer on ESP32 as reading the complete FAT may easily + // Needed to reset the idle task watchdog timer on ESP32 as reading the complete FAT may easily // block for 10+ seconds. yield() is insufficient since it blocks lower prio tasks (e.g., idle). static millis_t nextTaskTime = 0; const millis_t ms = millis(); From 90b6324563b806ea7dc24ddf299f055dc4854341 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Feb 2020 04:21:36 -0600 Subject: [PATCH 15/22] Encapsulate probe as singleton class (#16751) --- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/core/utility.cpp | 20 +- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 4 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 52 ++-- Marlin/src/gcode/bedlevel/G42.cpp | 6 +- Marlin/src/gcode/bedlevel/M420.cpp | 4 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 20 +- Marlin/src/gcode/calibrate/G28.cpp | 4 +- Marlin/src/gcode/calibrate/G33.cpp | 4 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 12 +- Marlin/src/gcode/calibrate/G76_M871.cpp | 16 +- Marlin/src/gcode/calibrate/M48.cpp | 12 +- Marlin/src/gcode/config/M304.cpp | 7 + Marlin/src/gcode/motion/M290.cpp | 6 +- Marlin/src/gcode/probe/G30.cpp | 8 +- Marlin/src/gcode/probe/G31_G32.cpp | 4 +- Marlin/src/gcode/probe/M401_M402.cpp | 6 +- Marlin/src/gcode/probe/M851.cpp | 8 +- .../lib/dgus/DGUSDisplayDefinitionFYSETC.cpp | 2 +- .../lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp | 2 +- .../lib/dgus/DGUSDisplayDefinitionOrigin.cpp | 2 +- Marlin/src/lcd/extensible_ui/ui_api.cpp | 6 +- Marlin/src/lcd/menu/menu.cpp | 8 +- Marlin/src/lcd/menu/menu_advanced.cpp | 8 +- Marlin/src/lcd/menu/menu_bed_leveling.cpp | 2 +- Marlin/src/lcd/menu/menu_configuration.cpp | 5 +- Marlin/src/module/configuration_store.cpp | 35 +-- Marlin/src/module/delta.cpp | 4 +- Marlin/src/module/motion.cpp | 20 +- Marlin/src/module/motion.h | 8 +- Marlin/src/module/planner.cpp | 4 +- Marlin/src/module/probe.cpp | 105 ++++---- Marlin/src/module/probe.h | 232 ++++++++++-------- 33 files changed, 338 insertions(+), 300 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 6d78190218b1..141494f20c83 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -977,7 +977,7 @@ void setup() { #endif #if HAS_Z_SERVO_PROBE - servo_probe_init(); + probe.servo_probe_init(); #endif #if HAS_PHOTOGRAPH diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 16d0ea17c148..14f7aa708324 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -83,42 +83,42 @@ void safe_delay(millis_t ms) { #if HAS_BED_PROBE #if !HAS_PROBE_XY_OFFSET - SERIAL_ECHOPAIR("Probe Offset X0 Y0 Z", probe_offset.z, " ("); + SERIAL_ECHOPAIR("Probe Offset X0 Y0 Z", probe.offset.z, " ("); #else - SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z); - if (probe_offset.x > 0) + SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR, probe.offset.z); + if (probe.offset_xy.x > 0) SERIAL_ECHOPGM(" (Right"); - else if (probe_offset.x < 0) + else if (probe.offset_xy.x < 0) SERIAL_ECHOPGM(" (Left"); - else if (probe_offset.y != 0) + else if (probe.offset_xy.y != 0) SERIAL_ECHOPGM(" (Middle"); else SERIAL_ECHOPGM(" (Aligned With"); - if (probe_offset.y > 0) { + if (probe.offset_xy.y > 0) { #if IS_SCARA SERIAL_ECHOPGM("-Distal"); #else SERIAL_ECHOPGM("-Back"); #endif } - else if (probe_offset.y < 0) { + else if (probe.offset_xy.y < 0) { #if IS_SCARA SERIAL_ECHOPGM("-Proximal"); #else SERIAL_ECHOPGM("-Front"); #endif } - else if (probe_offset.x != 0) + else if (probe.offset_xy.x != 0) SERIAL_ECHOPGM("-Center"); SERIAL_ECHOPGM(" & "); #endif - if (probe_offset.z < 0) + if (probe.offset.z < 0) SERIAL_ECHOPGM("Below"); - else if (probe_offset.z > 0) + else if (probe.offset.z > 0) SERIAL_ECHOPGM("Above"); else SERIAL_ECHOPGM("Same Z as"); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index adafc6a1946c..8327b468a7e3 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -173,10 +173,10 @@ serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n")); } - // Add XY probe offset from extruder because probe_at_point() subtracts them when + // Add XY probe offset from extruder because probe.probe_at_point() subtracts them when // moving to the XY position to be measured. This ensures better agreement between // the current Z position after G28 and the mesh values. - const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe_offset_xy); + const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe.offset_xy); if (!lcd) SERIAL_EOL(); for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) { diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index c8f3b45b0d95..693a4b9b2389 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -450,7 +450,7 @@ SERIAL_ECHO(g29_pos.y); SERIAL_ECHOLNPGM(").\n"); } - const xy_pos_t near = g29_pos + probe_offset_xy; + const xy_pos_t near = g29_pos + probe.offset_xy; probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U')); report_current_position(); @@ -480,8 +480,8 @@ #if IS_KINEMATIC X_HOME_POS, Y_HOME_POS #else - probe_offset_xy.x > 0 ? X_BED_SIZE : 0, - probe_offset_xy.y < 0 ? Y_BED_SIZE : 0 + probe.offset_xy.x > 0 ? X_BED_SIZE : 0, + probe.offset_xy.y < 0 ? Y_BED_SIZE : 0 #endif ); } @@ -742,7 +742,7 @@ * This attempts to fill in locations closest to the nozzle's start location first. */ void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) { - DEPLOY_PROBE(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW + probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW #if HAS_LCD_MENU ui.capture(); @@ -768,7 +768,7 @@ ui.wait_for_release(); ui.quick_feedback(); ui.release(); - STOW_PROBE(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW + probe.stow(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW return restore_ubl_active_state_and_leave(); } #endif @@ -778,7 +778,7 @@ : find_closest_mesh_point_of_type(INVALID, near, true); if (best.pos.x >= 0) { // mesh point found and is reachable by probe - const float measured_z = probe_at_point( + const float measured_z = probe.probe_at_point( best.meshpos(), stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level ); @@ -794,20 +794,20 @@ #if HAS_LCD_MENU ui.release(); #endif - STOW_PROBE(); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW + probe.stow(); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW #if HAS_LCD_MENU ui.capture(); #endif #ifdef Z_AFTER_PROBING - move_z_after_probing(); + probe.move_z_after_probing(); #endif restore_ubl_active_state_and_leave(); do_blocking_move_to_xy( - constrain(near.x - probe_offset_xy.x, MESH_MIN_X, MESH_MAX_X), - constrain(near.y - probe_offset_xy.y, MESH_MIN_Y, MESH_MAX_Y) + constrain(near.x - probe.offset_xy.x, MESH_MIN_X, MESH_MAX_X), + constrain(near.y - probe.offset_xy.y, MESH_MIN_Y, MESH_MAX_Y) ); } @@ -907,7 +907,7 @@ ui.return_to_status(); mesh_index_pair location; - xy_int8_t &lpos = location.pos; + const xy_int8_t &lpos = location.pos; do { location = find_closest_mesh_point_of_type(INVALID, pos); // It doesn't matter if the probe can't reach the NAN location. This is a manual probe. @@ -1006,7 +1006,7 @@ #endif MeshFlags done_flags{0}; - xy_int8_t &lpos = location.pos; + const xy_int8_t &lpos = location.pos; do { location = find_closest_mesh_point_of_type(SET_IN_BITMAP, pos, false, &done_flags); @@ -1294,7 +1294,7 @@ closest.distance = -99999.9f; // Get the reference position, either nozzle or probe - const xy_pos_t ref = probe_relative ? pos + probe_offset_xy : pos; + const xy_pos_t ref = probe_relative ? pos + probe.offset_xy : pos; float best_so_far = 99999.99f; @@ -1393,13 +1393,13 @@ #include "../../../libs/vector_3.h" void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) { - const float x_min = probe_min_x(), x_max = probe_max_x(), - y_min = probe_min_y(), y_max = probe_max_y(), + const float x_min = probe.min_x(), x_max = probe.max_x(), + y_min = probe.min_y(), y_max = probe.max_y(), dx = (x_max - x_min) / (g29_grid_size - 1), dy = (y_max - y_min) / (g29_grid_size - 1); xy_float_t points[3]; - get_three_probe_points(points); + probe.get_three_points(points); float measured_z; bool abort_flag = false; @@ -1417,7 +1417,7 @@ ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)); #endif - measured_z = probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level); + measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level); if (isnan(measured_z)) abort_flag = true; else { @@ -1438,7 +1438,7 @@ ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)); #endif - measured_z = probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level); + measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level); #ifdef VALIDATE_MESH_TILT z2 = measured_z; #endif @@ -1460,7 +1460,7 @@ ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)); #endif - measured_z = probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level); + measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level); #ifdef VALIDATE_MESH_TILT z3 = measured_z; #endif @@ -1476,9 +1476,9 @@ } } - STOW_PROBE(); + probe.stow(); #ifdef Z_AFTER_PROBING - move_z_after_probing(); + probe.move_z_after_probing(); #endif if (abort_flag) { @@ -1504,7 +1504,7 @@ ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points); #endif - measured_z = probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling + measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling abort_flag = isnan(measured_z); @@ -1523,7 +1523,7 @@ } #endif - measured_z -= get_z_correction(rpos) /* + probe_offset.z */ ; + measured_z -= get_z_correction(rpos) /* + probe.offset.z */ ; if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F(" final >>>---> ", measured_z, 7); @@ -1540,9 +1540,9 @@ zig_zag ^= true; } } - STOW_PROBE(); + probe.stow(); #ifdef Z_AFTER_PROBING - move_z_after_probing(); + probe.move_z_after_probing(); #endif if (abort_flag || finish_incremental_LSF(&lsf_results)) { @@ -1728,7 +1728,7 @@ adjust_mesh_to_mean(g29_c_flag, g29_constant); #if HAS_BED_PROBE - SERIAL_ECHOLNPAIR_F("Probe Offset M851 Z", probe_offset.z, 7); + SERIAL_ECHOLNPAIR_F("Probe Offset M851 Z", probe.offset.z, 7); #endif SERIAL_ECHOLNPAIR("MESH_MIN_X " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); serial_delay(50); diff --git a/Marlin/src/gcode/bedlevel/G42.cpp b/Marlin/src/gcode/bedlevel/G42.cpp index 28752cab8d5a..bd6715e29d93 100644 --- a/Marlin/src/gcode/bedlevel/G42.cpp +++ b/Marlin/src/gcode/bedlevel/G42.cpp @@ -27,7 +27,7 @@ #include "../gcode.h" #include "../../MarlinCore.h" // for IsRunning() #include "../../module/motion.h" -#include "../../module/probe.h" // for probe_offset +#include "../../module/probe.h" // for probe.offset #include "../../feature/bedlevel/bedlevel.h" /** @@ -53,8 +53,8 @@ void GcodeSuite::G42() { #if HAS_PROBE_XY_OFFSET if (parser.boolval('P')) { - if (hasI) destination.x -= probe_offset_xy.x; - if (hasJ) destination.y -= probe_offset_xy.y; + if (hasI) destination.x -= probe.offset_xy.x; + if (hasJ) destination.y -= probe.offset_xy.y; } #endif diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index 9e96b456e352..70f80465e3f4 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -64,8 +64,8 @@ void GcodeSuite::M420() { #if ENABLED(MARLIN_DEV_MODE) if (parser.intval('S') == 2) { - const float x_min = probe_min_x(), x_max = probe_max_x(), - y_min = probe_min_y(), y_max = probe_max_y(); + const float x_min = probe.min_x(), x_max = probe.max_x(), + y_min = probe.min_y(), y_max = probe.max_y(); #if ENABLED(AUTO_BED_LEVELING_BILINEAR) bilinear_start.set(x_min, y_min); bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1), diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 7cbaefbf23e9..ff0581886a70 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -269,7 +269,7 @@ G29_TYPE GcodeSuite::G29() { #endif vector_3 points[3]; - get_three_probe_points(points); + probe.get_three_points(points); #endif // AUTO_BED_LEVELING_3POINT @@ -392,8 +392,8 @@ G29_TYPE GcodeSuite::G29() { xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_SPEED)); - const float x_min = probe_min_x(), x_max = probe_max_x(), - y_min = probe_min_y(), y_max = probe_max_y(); + const float x_min = probe.min_x(), x_max = probe.max_x(), + y_min = probe.min_y(), y_max = probe.max_y(); if (parser.seen('H')) { const int16_t size = (int16_t)parser.value_linear_units(); @@ -452,7 +452,7 @@ G29_TYPE GcodeSuite::G29() { #if HAS_BED_PROBE // Deploy the probe. Probe will raise if needed. - if (DEPLOY_PROBE()) { + if (probe.deploy()) { set_bed_leveling_enabled(abl_should_enable); G29_RETURN(false); } @@ -712,7 +712,7 @@ G29_TYPE GcodeSuite::G29() { ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS)); #endif - measured_z = faux ? 0.001f * random(-100, 101) : probe_at_point(probePos, raise_after, verbose_level); + measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level); if (isnan(measured_z)) { set_bed_leveling_enabled(abl_should_enable); @@ -764,7 +764,7 @@ G29_TYPE GcodeSuite::G29() { // Retain the last probe position probePos = points[i]; - measured_z = faux ? 0.001 * random(-100, 101) : probe_at_point(probePos, raise_after, verbose_level); + measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level); if (isnan(measured_z)) { set_bed_leveling_enabled(abl_should_enable); break; @@ -788,7 +788,7 @@ G29_TYPE GcodeSuite::G29() { #endif // Stow the probe. No raise for FIX_MOUNTED_PROBE. - if (STOW_PROBE()) { + if (probe.stow()) { set_bed_leveling_enabled(abl_should_enable); measured_z = NAN; } @@ -923,8 +923,8 @@ G29_TYPE GcodeSuite::G29() { planner.force_unapply_leveling(converted); // use conversion machinery // Use the last measured distance to the bed, if possible - if ( NEAR(current_position.x, probePos.x - probe_offset_xy.x) - && NEAR(current_position.y, probePos.y - probe_offset_xy.y) + if ( NEAR(current_position.x, probePos.x - probe.offset_xy.x) + && NEAR(current_position.y, probePos.y - probe.offset_xy.y) ) { const float simple_z = current_position.z - measured_z; if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, " Matrix Z", converted.z, " Discrepancy ", simple_z - converted.z); @@ -964,7 +964,7 @@ G29_TYPE GcodeSuite::G29() { sync_plan_position(); #if HAS_BED_PROBE && defined(Z_AFTER_PROBING) - move_z_after_probing(); + probe.move_z_after_probing(); #endif #ifdef Z_PROBE_END_SCRIPT diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 6d87e6f9326d..0b29fbc4d6bb 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -133,7 +133,7 @@ destination.set(safe_homing_xy, current_position.z); #if HOMING_Z_WITH_PROBE - destination -= probe_offset_xy; + destination -= probe.offset_xy; #endif if (position_is_reachable(destination)) { @@ -416,7 +416,7 @@ void GcodeSuite::G28(const bool always_home_all) { #endif #if HOMING_Z_WITH_PROBE && defined(Z_AFTER_PROBING) - move_z_after_probing(); + probe.move_z_after_probing(); #endif } // doZ diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 2ce45359d36a..bfcf9153ea1c 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -100,7 +100,7 @@ void ac_cleanup( do_blocking_move_to_z(delta_clip_start_height); #endif #if HAS_BED_PROBE - STOW_PROBE(); + probe.stow(); #endif restore_feedrate_and_scaling(); #if HOTENDS > 1 @@ -190,7 +190,7 @@ static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool */ static float calibration_probe(const xy_pos_t &xy, const bool stow) { #if HAS_BED_PROBE - return probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); + return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); #else UNUSED(stow); return lcd_probe_pt(xy); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 2c284de6810d..a35b3faef743 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -133,8 +133,8 @@ void GcodeSuite::G34() { do { // break out on error - #if NUM_Z_STEPPER_DRIVERS == 4 - SERIAL_ECHOLNPGM("Quad Z Stepper Leveling not Yet Supported"); + #if NUM_Z_STEPPER_DRIVERS >= 4 + SERIAL_ECHOLNPGM("Alignment not supported for over 3 steppers"); break; #endif @@ -240,7 +240,7 @@ void GcodeSuite::G34() { if (iteration == 0 || i > 0) do_blocking_move_to_z(z_probe); // Probe a Z height for each stepper. - const float z_probed_height = probe_at_point(z_stepper_align_pos[iprobe], raise_after, 0, true); + const float z_probed_height = probe.probe_at_point(z_stepper_align_pos[iprobe], raise_after, 0, true); if (isnan(z_probed_height)) { SERIAL_ECHOLNPGM("Probing failed."); err_break = true; @@ -314,7 +314,7 @@ void GcodeSuite::G34() { #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) // Optimize one iteration's correction based on the first measurements - if (z_align_abs > 0.0f) amplification = iteration == 1 ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification; + if (z_align_abs) amplification = (iteration == 1) ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification; #endif // Check for less accuracy compared to last move @@ -379,9 +379,9 @@ void GcodeSuite::G34() { // After this operation the z position needs correction set_axis_is_not_at_home(Z_AXIS); - // Stow the probe, as the last call to probe_at_point(...) left + // Stow the probe, as the last call to probe.probe_at_point(...) left // the probe deployed if it was successful. - STOW_PROBE(); + probe.stow(); // Home Z after the alignment procedure process_subcommands_now_P(PSTR("G28 Z")); diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 479f13d50c69..b94b56fd93f2 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -113,8 +113,8 @@ void GcodeSuite::G76() { } // Ensure probe position is reachable destination.set( - temp_comp.measure_point_x - probe_offset.x, - temp_comp.measure_point_y - probe_offset.y + temp_comp.measure_point_x - probe.offset_xy.x, + temp_comp.measure_point_y - probe.offset_xy.y ); if (!position_is_reachable_by_probe(destination)) { SERIAL_ECHOLNPGM("!Probe position unreachable - aborting."); @@ -209,9 +209,9 @@ void GcodeSuite::G76() { // Do a single probe remember_feedrate_scaling_off(); - const float measured_z = probe_at_point( - destination.x + probe_offset.x, - destination.y + probe_offset.y, + const float measured_z = probe.probe_at_point( + destination.x + probe.offset_xy.x, + destination.y + probe.offset_xy.y, PROBE_PT_NONE ); restore_feedrate_and_scaling(); @@ -318,9 +318,9 @@ void GcodeSuite::G76() { // Do a single probe remember_feedrate_scaling_off(); - const float measured_z = probe_at_point( - destination.x + probe_offset.x, - destination.y + probe_offset.y, + const float measured_z = probe.probe_at_point( + destination.x + probe.offset_xy.x, + destination.y + probe.offset_xy.y, PROBE_PT_NONE ); restore_feedrate_and_scaling(); diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 75c5ed9a818c..707a37fc235e 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -80,8 +80,8 @@ void GcodeSuite::M48() { xy_float_t next_pos = current_position; const xy_pos_t probe_pos = { - parser.linearval('X', next_pos.x + probe_offset_xy.x), - parser.linearval('Y', next_pos.y + probe_offset_xy.y) + parser.linearval('X', next_pos.x + probe.offset_xy.x), + parser.linearval('Y', next_pos.y + probe.offset_xy.y) }; if (!position_is_reachable_by_probe(probe_pos)) { @@ -120,7 +120,7 @@ void GcodeSuite::M48() { float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples]; // Move to the first point, deploy, and probe - const float t = probe_at_point(probe_pos, raise_after, verbose_level); + const float t = probe.probe_at_point(probe_pos, raise_after, verbose_level); bool probing_good = !isnan(t); if (probing_good) { @@ -169,7 +169,7 @@ void GcodeSuite::M48() { while (angle < 0.0) angle += 360.0; // outside of this range. It looks like they behave correctly with // numbers outside of the range, but just to be safe we clamp them. - const xy_pos_t noz_pos = probe_pos - probe_offset_xy; + const xy_pos_t noz_pos = probe_pos - probe.offset_xy; next_pos.set(noz_pos.x + cos(RADIANS(angle)) * radius, noz_pos.y + sin(RADIANS(angle)) * radius); @@ -194,7 +194,7 @@ void GcodeSuite::M48() { } // n_legs // Probe a single point - sample_set[n] = probe_at_point(probe_pos, raise_after, 0); + sample_set[n] = probe.probe_at_point(probe_pos, raise_after, 0); // Break the loop if the probe fails probing_good = !isnan(sample_set[n]); @@ -238,7 +238,7 @@ void GcodeSuite::M48() { } // n_samples loop } - STOW_PROBE(); + probe.stow(); if (probing_good) { SERIAL_ECHOLNPGM("Finished!"); diff --git a/Marlin/src/gcode/config/M304.cpp b/Marlin/src/gcode/config/M304.cpp index 3048c228d5e8..6510bc03f6ec 100644 --- a/Marlin/src/gcode/config/M304.cpp +++ b/Marlin/src/gcode/config/M304.cpp @@ -27,6 +27,13 @@ #include "../gcode.h" #include "../../module/temperature.h" +/** + * M304 - Set and/or Report the current Bed PID values + * + * P - Set the P value + * I - Set the I value + * D - Set the D value + */ void GcodeSuite::M304() { if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float(); if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float()); diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index e5b5b7e76d7e..7d66ae655537 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -46,9 +46,9 @@ && active_extruder == 0 #endif ) { - probe_offset.z += offs; + probe.offset.z += offs; SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET MSG_Z ": ", probe_offset.z); + SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET MSG_Z ": ", probe.offset.z); } else { #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) @@ -98,7 +98,7 @@ void GcodeSuite::M290() { SERIAL_ECHO_START(); #if ENABLED(BABYSTEP_ZPROBE_OFFSET) - SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " " MSG_Z, probe_offset.z); + SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " " MSG_Z, probe.offset.z); #endif #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index a236ce3edf8c..e31f1fb272bd 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -40,8 +40,8 @@ */ void GcodeSuite::G30() { - const xy_pos_t pos = { parser.linearval('X', current_position.x + probe_offset_xy.x), - parser.linearval('Y', current_position.y + probe_offset_xy.y) }; + const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x), + parser.linearval('Y', current_position.y + probe.offset_xy.y) }; if (!position_is_reachable_by_probe(pos)) return; @@ -53,14 +53,14 @@ void GcodeSuite::G30() { remember_feedrate_scaling_off(); const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; - const float measured_z = probe_at_point(pos, raise_after, 1); + const float measured_z = probe.probe_at_point(pos, raise_after, 1); if (!isnan(measured_z)) SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z)); restore_feedrate_and_scaling(); #ifdef Z_AFTER_PROBING - if (raise_after == PROBE_PT_STOW) move_z_after_probing(); + if (raise_after == PROBE_PT_STOW) probe.move_z_after_probing(); #endif report_current_position(); diff --git a/Marlin/src/gcode/probe/G31_G32.cpp b/Marlin/src/gcode/probe/G31_G32.cpp index 06c3c3adf1a1..cd71f28d732a 100644 --- a/Marlin/src/gcode/probe/G31_G32.cpp +++ b/Marlin/src/gcode/probe/G31_G32.cpp @@ -30,11 +30,11 @@ /** * G31: Deploy the Z probe */ -void GcodeSuite::G31() { DEPLOY_PROBE(); } +void GcodeSuite::G31() { probe.deploy(); } /** * G32: Stow the Z probe */ -void GcodeSuite::G32() { STOW_PROBE(); } +void GcodeSuite::G32() { probe.stow(); } #endif // Z_PROBE_SLED diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index aa63a7ea7138..55851f3046bb 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -32,7 +32,7 @@ * M401: Deploy and activate the Z probe */ void GcodeSuite::M401() { - DEPLOY_PROBE(); + probe.deploy(); report_current_position(); } @@ -40,9 +40,9 @@ void GcodeSuite::M401() { * M402: Deactivate and stow the Z probe */ void GcodeSuite::M402() { - STOW_PROBE(); + probe.stow(); #ifdef Z_AFTER_PROBING - move_z_after_probing(); + probe.move_z_after_probing(); #endif report_current_position(); } diff --git a/Marlin/src/gcode/probe/M851.cpp b/Marlin/src/gcode/probe/M851.cpp index b0a63041fed1..2c26ebd2a62a 100644 --- a/Marlin/src/gcode/probe/M851.cpp +++ b/Marlin/src/gcode/probe/M851.cpp @@ -39,17 +39,17 @@ void GcodeSuite::M851() { if (!parser.seen("XYZ")) { SERIAL_ECHOLNPAIR_P( #if HAS_PROBE_XY_OFFSET - PSTR(MSG_PROBE_OFFSET " X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR + PSTR(MSG_PROBE_OFFSET " X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR #else PSTR(MSG_PROBE_OFFSET " X0 Y0 Z") #endif - , probe_offset.z + , probe.offset.z ); return; } // Start with current offsets and modify - xyz_pos_t offs = probe_offset; + xyz_pos_t offs = probe.offset; // Assume no errors bool ok = true; @@ -93,7 +93,7 @@ void GcodeSuite::M851() { } // Save the new offsets - if (ok) probe_offset = offs; + if (ok) probe.offset = offs; } #endif // HAS_BED_PROBE diff --git a/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionFYSETC.cpp b/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionFYSETC.cpp index 4d953b88c894..4522617d801e 100644 --- a/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionFYSETC.cpp +++ b/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionFYSETC.cpp @@ -453,7 +453,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr), #if HAS_BED_PROBE - VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe_offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), #if ENABLED(BABYSTEPPING) VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr), #endif diff --git a/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp b/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp index 0c25f64b6a72..0a6d9933c601 100644 --- a/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp +++ b/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp @@ -453,7 +453,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr), #if HAS_BED_PROBE - VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe_offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), #if ENABLED(BABYSTEPPING) VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr), #endif diff --git a/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionOrigin.cpp b/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionOrigin.cpp index ca56052829a7..4d877b6b7244 100644 --- a/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionOrigin.cpp +++ b/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionOrigin.cpp @@ -285,7 +285,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr), #if HAS_BED_PROBE - VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe_offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), #if ENABLED(BABYSTEPPING) VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr), #endif diff --git a/Marlin/src/lcd/extensible_ui/ui_api.cpp b/Marlin/src/lcd/extensible_ui/ui_api.cpp index 5e053b670a73..0e0a1171ab9d 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -733,7 +733,7 @@ namespace ExtUI { #if EXTRUDERS > 1 && (linked_nozzles || active_extruder == 0) #endif - ) probe_offset.z += mm; + ) probe.offset.z += mm; #else UNUSED(mm); #endif @@ -771,7 +771,7 @@ namespace ExtUI { float getZOffset_mm() { #if HAS_BED_PROBE - return probe_offset.z; + return probe.offset.z; #elif ENABLED(BABYSTEP_DISPLAY_TOTAL) return (planner.steps_to_mm[Z_AXIS] * babystep.axis_total[BS_TODO_AXIS(Z_AXIS)]); #else @@ -782,7 +782,7 @@ namespace ExtUI { void setZOffset_mm(const float value) { #if HAS_BED_PROBE if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) - probe_offset.z = value; + probe.offset.z = value; #elif ENABLED(BABYSTEP_DISPLAY_TOTAL) babystep.add_mm(Z_AXIS, (value - getZOffset_mm())); #else diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 2bae1258e942..9c3cf057d6b3 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -406,7 +406,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { ui.encoderPosition = 0; const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment, - new_probe_offset = probe_offset.z + diff, + new_probe_offset = probe.offset.z + diff, new_offs = #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff @@ -418,7 +418,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { babystep.add_steps(Z_AXIS, babystep_increment); - if (do_probe) probe_offset.z = new_offs; + if (do_probe) probe.offset.z = new_offs; #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) else hotend_offset[active_extruder].z = new_offs; #endif @@ -432,10 +432,10 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), LCD_Z_OFFSET_FUNC(hotend_offset[active_extruder].z)); else #endif - MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), LCD_Z_OFFSET_FUNC(probe_offset.z)); + MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), LCD_Z_OFFSET_FUNC(probe.offset.z)); #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY) - if (do_probe) _lcd_zoffset_overlay_gfx(probe_offset.z); + if (do_probe) _lcd_zoffset_overlay_gfx(probe.offset.z); #endif } } diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index ec03a0066cbf..471d1eeb9cef 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -497,9 +497,11 @@ void menu_cancelobject(); void menu_probe_offsets() { START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); - EDIT_ITEM(float51sign, MSG_ZPROBE_XOFFSET, &probe_offset.x, -(X_BED_SIZE), X_BED_SIZE); - EDIT_ITEM(float51sign, MSG_ZPROBE_YOFFSET, &probe_offset.y, -(Y_BED_SIZE), Y_BED_SIZE); - EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + #if HAS_PROBE_XY_OFFSET + EDIT_ITEM(float51sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, -(X_BED_SIZE), X_BED_SIZE); + EDIT_ITEM(float51sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, -(Y_BED_SIZE), Y_BED_SIZE); + #endif + EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); END_MENU(); } #endif diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 6cc40cab6ca4..d16d4670a808 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -279,7 +279,7 @@ void menu_bed_leveling() { #if ENABLED(BABYSTEP_ZPROBE_OFFSET) SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset); #elif HAS_BED_PROBE - EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); #endif #if ENABLED(LEVEL_BED_CORNERS) diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index c23017c3e91c..31d46816e9b9 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -317,14 +317,11 @@ void menu_configuration() { #if ENABLED(BABYSTEP_ZPROBE_OFFSET) SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset); #elif HAS_BED_PROBE - EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); #endif const bool busy = printer_busy(); if (!busy) { - // - // Delta Calibration - // #if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) SUBMENU(MSG_DELTA_CALIBRATE, menu_delta_calibrate); #endif diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 85b0b850b0f2..05b67c984ca2 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -587,12 +587,12 @@ void MarlinSettings::postprocess() { #if HAS_FILAMENT_SENSOR const bool &runout_sensor_enabled = runout.enabled; #else - const bool runout_sensor_enabled = true; + constexpr bool runout_sensor_enabled = true; #endif #if HAS_FILAMENT_SENSOR && defined(FILAMENT_RUNOUT_DISTANCE_MM) const float &runout_distance_mm = runout.runout_distance(); #else - const float runout_distance_mm = 0; + constexpr float runout_distance_mm = 0; #endif _FIELD_TEST(runout_sensor_enabled); EEPROM_WRITE(runout_sensor_enabled); @@ -643,7 +643,12 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(probe_offset); - EEPROM_WRITE(probe_offset); + #if HAS_BED_PROBE + const xyz_pos_t &zpo = probe.offset; + #else + constexpr xyz_pos_t zpo{0}; + #endif + EEPROM_WRITE(zpo); } // @@ -1458,7 +1463,7 @@ void MarlinSettings::postprocess() { // { #if HAS_FILAMENT_SENSOR - bool &runout_sensor_enabled = runout.enabled; + const bool &runout_sensor_enabled = runout.enabled; #else bool runout_sensor_enabled; #endif @@ -1515,7 +1520,7 @@ void MarlinSettings::postprocess() { { _FIELD_TEST(probe_offset); #if HAS_BED_PROBE - xyz_pos_t &zpo = probe_offset; + const xyz_pos_t &zpo = probe.offset; #else xyz_pos_t zpo; #endif @@ -1609,7 +1614,7 @@ void MarlinSettings::postprocess() { { _FIELD_TEST(bltouch_last_written_mode); #if ENABLED(BLTOUCH) - bool &bltouch_last_written_mode = bltouch.last_written_mode; + const bool &bltouch_last_written_mode = bltouch.last_written_mode; #else bool bltouch_last_written_mode; #endif @@ -2120,14 +2125,14 @@ void MarlinSettings::postprocess() { // { #if ENABLED(BACKLASH_GCODE) - xyz_float_t &backlash_distance_mm = backlash.distance_mm; - uint8_t &backlash_correction = backlash.correction; + const xyz_float_t &backlash_distance_mm = backlash.distance_mm; + const uint8_t &backlash_correction = backlash.correction; #else float backlash_distance_mm[XYZ]; uint8_t backlash_correction; #endif #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - float &backlash_smoothing_mm = backlash.smoothing_mm; + const float &backlash_smoothing_mm = backlash.smoothing_mm; #else float backlash_smoothing_mm; #endif @@ -2461,10 +2466,10 @@ void MarlinSettings::reset() { constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET; static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z."); #if HAS_PROBE_XY_OFFSET - LOOP_XYZ(a) probe_offset[a] = dpo[a]; + LOOP_XYZ(a) probe.offset[a] = dpo[a]; #else - probe_offset.x = probe_offset.y = 0; - probe_offset.z = dpo[Z_AXIS]; + probe.offset.x = probe.offset.y = 0; + probe.offset.z = dpo[Z_AXIS]; #endif #endif @@ -3216,13 +3221,13 @@ void MarlinSettings::reset() { CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( #if HAS_PROBE_XY_OFFSET - PSTR(" M851 X"), LINEAR_UNIT(probe_offset_xy.x), - SP_Y_STR, LINEAR_UNIT(probe_offset_xy.y), + PSTR(" M851 X"), LINEAR_UNIT(probe.offset_xy.x), + SP_Y_STR, LINEAR_UNIT(probe.offset_xy.y), SP_Z_STR #else PSTR(" M851 X0 Y0 Z") #endif - , LINEAR_UNIT(probe_offset.z) + , LINEAR_UNIT(probe.offset.z) ); #endif diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index bed5cd24cf48..cb2d432e30b8 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -95,7 +95,7 @@ void recalc_delta_settings() { float delta_calibration_radius() { return calibration_radius_factor * ( #if HAS_BED_PROBE - FLOOR((DELTA_PRINTABLE_RADIUS) - _MAX(HYPOT(probe_offset_xy.x, probe_offset_xy.y), MIN_PROBE_EDGE)) + FLOOR((DELTA_PRINTABLE_RADIUS) - _MAX(HYPOT(probe.offset_xy.x, probe.offset_xy.y), MIN_PROBE_EDGE)) #else DELTA_PRINTABLE_RADIUS #endif @@ -251,7 +251,7 @@ void home_delta() { // Move all carriages together linearly until an endstop is hit. current_position.z = (delta_height + 10 #if HAS_BED_PROBE - - probe_offset.z + - probe.offset.z #endif ); line_to_current_position(homing_feedrate(Z_AXIS)); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 50092406c5e7..f63555d28c4f 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -280,7 +280,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { , true #endif ); - xyze_pos_t &cartes = pos; + const xyze_pos_t &cartes = pos; #endif if (axis == ALL_AXES) current_position = cartes; @@ -547,7 +547,7 @@ void restore_feedrate_and_scaling() { soft_endstop.min[axis] = base_min_pos(axis); soft_endstop.max[axis] = (axis == Z_AXIS ? delta_height #if HAS_BED_PROBE - - probe_offset.z + - probe.offset.z #endif : base_max_pos(axis)); @@ -1281,7 +1281,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t #if HOMING_Z_WITH_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) // Wait for bed to heat back up between probing points if (axis == Z_AXIS && distance < 0 && thermalManager.isHeatingBed()) { - serialprintPGM(msg_wait_for_bed_heating); + serialprintPGM(probe.msg_wait_for_bed_heating); #if HAS_DISPLAY LCD_MESSAGEPGM(MSG_BED_HEATING); #endif @@ -1307,7 +1307,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t if (is_home_dir) { #if HOMING_Z_WITH_PROBE && QUIET_PROBING - if (axis == Z_AXIS) probing_pause(true); + if (axis == Z_AXIS) probe.set_probing_paused(true); #endif // Disable stealthChop if used. Enable diag1 pin on driver. @@ -1347,7 +1347,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t if (is_home_dir) { #if HOMING_Z_WITH_PROBE && QUIET_PROBING - if (axis == Z_AXIS) probing_pause(false); + if (axis == Z_AXIS) probe.set_probing_paused(false); #endif endstops.validate_homing_move(); @@ -1397,7 +1397,7 @@ void set_axis_is_at_home(const AxisEnum axis) { #elif ENABLED(DELTA) current_position[axis] = (axis == Z_AXIS ? delta_height #if HAS_BED_PROBE - - probe_offset.z + - probe.offset.z #endif : base_home_pos(axis)); #else @@ -1411,9 +1411,9 @@ void set_axis_is_at_home(const AxisEnum axis) { if (axis == Z_AXIS) { #if HOMING_Z_WITH_PROBE - current_position.z -= probe_offset.z; + current_position.z -= probe.offset.z; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe_offset.z = ", probe_offset.z); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe.offset.z = ", probe.offset.z); #else @@ -1509,7 +1509,7 @@ void homeaxis(const AxisEnum axis) { // Homing Z towards the bed? Deploy the Z probe or endstop. #if HOMING_Z_WITH_PROBE - if (axis == Z_AXIS && DEPLOY_PROBE()) return; + if (axis == Z_AXIS && probe.deploy()) return; #endif // Set flags for X, Y, Z motor locking @@ -1751,7 +1751,7 @@ void homeaxis(const AxisEnum axis) { // Put away the Z probe #if HOMING_Z_WITH_PROBE - if (axis == Z_AXIS && STOW_PROBE()) return; + if (axis == Z_AXIS && probe.stow()) return; #endif #if DISABLED(DELTA) && defined(HOMING_BACKOFF_MM) diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index eafa5ca8492a..a159bdd4bfa8 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -329,7 +329,7 @@ void homeaxis(const AxisEnum axis); // Return true if the both nozzle and the probe can reach the given point. // Note: This won't work on SCARA since the probe offset rotates with the arm. inline bool position_is_reachable_by_probe(const float &rx, const float &ry) { - return position_is_reachable(rx - probe_offset.x, ry - probe_offset.y) + return position_is_reachable(rx - probe.offset_xy.x, ry - probe.offset_xy.y) && position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE)); } @@ -369,9 +369,9 @@ void homeaxis(const AxisEnum axis); * nozzle must be be able to reach +10,-10. */ inline bool position_is_reachable_by_probe(const float &rx, const float &ry) { - return position_is_reachable(rx - probe_offset_xy.x, ry - probe_offset_xy.y) - && WITHIN(rx, probe_min_x() - slop, probe_max_x() + slop) - && WITHIN(ry, probe_min_y() - slop, probe_max_y() + slop); + return position_is_reachable(rx - probe.offset_xy.x, ry - probe.offset_xy.y) + && WITHIN(rx, probe.min_x() - slop, probe.max_x() + slop) + && WITHIN(ry, probe.min_y() - slop, probe.max_y() + slop); } #endif // HAS_BED_PROBE diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 351b089895e8..9f5a5c5c5e04 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2779,7 +2779,7 @@ void Planner::set_max_acceleration(const uint8_t axis, float targetValue) { const xyze_float_t &max_acc_edit_scaled = max_accel_edit; #else constexpr xyze_float_t max_accel_edit = DEFAULT_MAX_ACCELERATION; - const xyze_float_t max_acc_edit_scaled = max_accel_edit * 2; + constexpr xyze_float_t max_acc_edit_scaled = max_accel_edit * 2; #endif limit_and_warn(targetValue, axis, PSTR("Acceleration"), max_acc_edit_scaled); #endif @@ -2796,7 +2796,7 @@ void Planner::set_max_feedrate(const uint8_t axis, float targetValue) { const xyze_float_t &max_fr_edit_scaled = max_fr_edit; #else constexpr xyze_float_t max_fr_edit = DEFAULT_MAX_FEEDRATE; - const xyze_float_t max_fr_edit_scaled = max_fr_edit * 2; + constexpr xyze_float_t max_fr_edit_scaled = max_fr_edit * 2; #endif limit_and_warn(targetValue, axis, PSTR("Feedrate"), max_fr_edit_scaled); #endif diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 5710614e007d..ef11a52122be 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -21,7 +21,7 @@ */ /** - * probe.cpp + * module/probe.cpp */ #include "../inc/MarlinConfig.h" @@ -84,14 +84,14 @@ #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../core/debug_out.h" +Probe probe; -xyz_pos_t probe_offset; // Initialized by settings.load() +xyz_pos_t Probe::offset; // Initialized by settings.load() #if HAS_PROBE_XY_OFFSET - xyz_pos_t &probe_offset_xy = probe_offset; + const xyz_pos_t &Probe::offset_xy = probe.offset; #endif - #if ENABLED(Z_PROBE_SLED) #ifndef SLED_DOCKING_OFFSET @@ -104,7 +104,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load() * stow[in] If false, move to MAX_X and engage the solenoid * If true, move to MAX_X and release the solenoid */ - static void dock_sled(bool stow) { + static void dock_sled(const bool stow) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("dock_sled(", stow, ")"); // Dock sled a bit closer to ensure proper capturing @@ -118,7 +118,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load() #elif ENABLED(TOUCH_MI_PROBE) // Move to the magnet to unlock the probe - void run_deploy_moves_script() { + inline void run_deploy_moves_script() { #ifndef TOUCH_MI_DEPLOY_XPOS #define TOUCH_MI_DEPLOY_XPOS X_MIN_POS #elif TOUCH_MI_DEPLOY_XPOS > X_MAX_BED @@ -153,7 +153,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load() } // Move down to the bed to stow the probe - void run_stow_moves_script() { + inline void run_stow_moves_script() { const xyz_pos_t oldpos = current_position; endstops.enable_z_probe(false); do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, MMM_TO_MMS(HOMING_FEEDRATE_Z)); @@ -162,7 +162,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load() #elif ENABLED(Z_PROBE_ALLEN_KEY) - void run_deploy_moves_script() { + inline void run_deploy_moves_script() { #ifdef Z_PROBE_ALLEN_KEY_DEPLOY_1 #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE 0.0 @@ -200,7 +200,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load() #endif } - void run_stow_moves_script() { + inline void run_stow_moves_script() { #ifdef Z_PROBE_ALLEN_KEY_STOW_1 #ifndef Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE 0.0 @@ -241,7 +241,8 @@ xyz_pos_t probe_offset; // Initialized by settings.load() #endif // Z_PROBE_ALLEN_KEY #if QUIET_PROBING - void probing_pause(const bool p) { + + void Probe::set_probing_paused(const bool p) { #if ENABLED(PROBING_HEATERS_OFF) thermalManager.pause(p); #endif @@ -262,16 +263,17 @@ xyz_pos_t probe_offset; // Initialized by settings.load() #endif ); } + #endif // QUIET_PROBING /** * Raise Z to a minimum height to make room for a probe to move */ -inline void do_probe_raise(const float z_raise) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("do_probe_raise(", z_raise, ")"); +void Probe::do_z_raise(const float z_raise) { + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probe::move_z(", z_raise, ")"); float z_dest = z_raise; - if (probe_offset.z < 0) z_dest -= probe_offset.z; + if (offset.z < 0) z_dest -= offset.z; NOMORE(z_dest, Z_MAX_POS); @@ -351,11 +353,15 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #endif } -// returns false for ok and true for failure -bool set_probe_deployed(const bool deploy) { +/** + * Attempt to deploy or stow the probe + * + * Return TRUE if the probe could not be deployed/stowed + */ +bool Probe::set_deployed(const bool deploy) { if (DEBUGGING(LEVELING)) { - DEBUG_POS("set_probe_deployed", current_position); + DEBUG_POS("Probe::set_deployed", current_position); DEBUG_ECHOLNPAIR("deploy: ", deploy); } @@ -378,7 +384,7 @@ bool set_probe_deployed(const bool deploy) { #endif if (deploy_stow_condition && unknown_condition) - do_probe_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE)); + do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE)); #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY) if (axis_unhomed_error( @@ -433,7 +439,7 @@ bool set_probe_deployed(const bool deploy) { #ifdef Z_AFTER_PROBING // After probing move to a preferred Z position - void move_z_after_probing() { + void Probe::move_z_after_probing() { if (current_position.z != Z_AFTER_PROBING) { do_blocking_move_to_z(Z_AFTER_PROBING); current_position.z = Z_AFTER_PROBING; @@ -450,11 +456,11 @@ bool set_probe_deployed(const bool deploy) { */ #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) - const char msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n"; + PGM_P Probe::msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n"; #endif -static bool do_probe_move(const float z, const feedRate_t fr_mm_s) { - if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position); +bool Probe::move_to_z(const float z, const feedRate_t fr_mm_s) { + if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::move_to_z", current_position); #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) // Wait for bed to heat back up between probing points @@ -482,7 +488,7 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) { #endif #if QUIET_PROBING - probing_pause(true); + set_probing_paused(true); #endif // Move down until the probe is triggered @@ -504,7 +510,7 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) { ; #if QUIET_PROBING - probing_pause(false); + set_probing_paused(false); #endif // Re-enable stealthChop if used. Disable diag1 pin on driver. @@ -530,7 +536,7 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) { // Tell the planner where we actually are sync_plan_position(); - if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position); + if (DEBUGGING(LEVELING)) DEBUG_POS("<<< Probe::move_to_z", current_position); return !probe_triggered; } @@ -543,19 +549,19 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) { * * @return The Z position of the bed at the current XY or NAN on error. */ -static float run_z_probe() { +float Probe::run_z_probe() { - if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position); + if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::run_z_probe", current_position); // Stop the probe before it goes too low to prevent damage. // If Z isn't known then probe to -10mm. - const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -probe_offset.z + Z_PROBE_LOW_POINT : -10.0; + const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -offset.z + Z_PROBE_LOW_POINT : -10.0; // Double-probing does a fast probe followed by a slow probe #if TOTAL_PROBING == 2 // Do a first probe at the fast speed - if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) { + if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM("FAST Probe fail!"); DEBUG_POS("<<< run_z_probe", current_position); @@ -574,10 +580,10 @@ static float run_z_probe() { // If the nozzle is well over the travel height then // move down quickly before doing the slow probe - const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (probe_offset.z < 0 ? -probe_offset.z : 0); + const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (offset.z < 0 ? -offset.z : 0); if (current_position.z > z) { // Probe down fast. If the probe never triggered, raise for probe clearance - if (!do_probe_move(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) + if (!move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST)); } #endif @@ -587,7 +593,7 @@ static float run_z_probe() { #endif #if TOTAL_PROBING > 2 - float probes_total = 0; + float probes_z_sum = 0; for ( #if EXTRA_PROBING uint8_t p = 0; p < TOTAL_PROBING; p++ @@ -598,7 +604,7 @@ static float run_z_probe() { #endif { // Probe downward slowly to find the bed - if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) { + if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM("SLOW Probe fail!"); DEBUG_POS("<<< run_z_probe", current_position); @@ -622,7 +628,7 @@ static float run_z_probe() { } } #elif TOTAL_PROBING > 2 - probes_total += z; + probes_z_sum += z; #else UNUSED(z); #endif @@ -653,11 +659,11 @@ static float run_z_probe() { // Return the average value of all remaining probes. for (uint8_t i = min_avg_idx; i <= max_avg_idx; i++) - probes_total += probes[i]; + probes_z_sum += probes[i]; #endif - const float measured_z = probes_total * RECIPROCAL(MULTIPLE_PROBING); + const float measured_z = probes_z_sum * RECIPROCAL(MULTIPLE_PROBING); #elif TOTAL_PROBING == 2 @@ -689,10 +695,10 @@ static float run_z_probe() { * - Raise to the BETWEEN height * - Return the probed Z position */ -float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) { +float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR( - ">>> probe_at_point(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry), + ">>> Probe::probe_at_point(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry), ", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none", ", ", int(verbose_level), ", ", probe_relative ? "probe" : "nozzle", "_relative)" @@ -702,9 +708,12 @@ float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_ // TODO: Adapt for SCARA, where the offset rotates xyz_pos_t npos = { rx, ry }; - if (probe_relative) { - if (!position_is_reachable_by_probe(npos)) return NAN; // The given position is in terms of the probe - npos -= probe_offset_xy; // Get the nozzle position + if (probe_relative) { // The given position is in terms of the probe + if (!position_is_reachable_by_probe(npos)) { + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable"); + return NAN; + } + npos -= offset_xy; // Get the nozzle position } else if (!position_is_reachable(npos)) return NAN; // The given position is in terms of the nozzle @@ -724,38 +733,38 @@ float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_ do_blocking_move_to(npos); float measured_z = NAN; - if (!DEPLOY_PROBE()) { - measured_z = run_z_probe() + probe_offset.z; + if (!deploy()) { + measured_z = run_z_probe() + offset.z; const bool big_raise = raise_after == PROBE_PT_BIG_RAISE; if (big_raise || raise_after == PROBE_PT_RAISE) do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), MMM_TO_MMS(Z_PROBE_SPEED_FAST)); else if (raise_after == PROBE_PT_STOW) - if (STOW_PROBE()) measured_z = NAN; + if (stow()) measured_z = NAN; } if (verbose_level > 2) { SERIAL_ECHOPAIR_F("Bed X: ", LOGICAL_X_POSITION(rx), 3); - SERIAL_ECHOPAIR_F(" Y: ", LOGICAL_Y_POSITION(ry), 3); - SERIAL_ECHOLNPAIR_F(" Z: ", measured_z, 3); + SERIAL_ECHOPAIR_F( " Y: ", LOGICAL_Y_POSITION(ry), 3); + SERIAL_ECHOLNPAIR_F( " Z: ", measured_z, 3); } feedrate_mm_s = old_feedrate_mm_s; if (isnan(measured_z)) { - STOW_PROBE(); + stow(); LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); SERIAL_ERROR_MSG(MSG_ERR_PROBING_FAILED); } - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< probe_at_point"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< Probe::probe_at_point"); return measured_z; } #if HAS_Z_SERVO_PROBE - void servo_probe_init() { + void Probe::servo_probe_init() { /** * Set position of Z Servo Endstop * diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index a6e8bf4eab22..5cf0ecc2546c 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -22,132 +22,150 @@ #pragma once /** - * probe.h - Move, deploy, enable, etc. + * module/probe.h - Move, deploy, enable, etc. */ #include "../inc/MarlinConfig.h" #if HAS_BED_PROBE - - extern xyz_pos_t probe_offset; - - #if HAS_PROBE_XY_OFFSET - extern xyz_pos_t &probe_offset_xy; - #else - constexpr xy_pos_t probe_offset_xy{0}; - #endif - - bool set_probe_deployed(const bool deploy); - #ifdef Z_AFTER_PROBING - void move_z_after_probing(); - #endif - enum ProbePtRaise : unsigned char { - PROBE_PT_NONE, // No raise or stow after run_z_probe - PROBE_PT_STOW, // Do a complete stow after run_z_probe - PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe + enum ProbePtRaise : uint8_t { + PROBE_PT_NONE, // No raise or stow after run_z_probe + PROBE_PT_STOW, // Do a complete stow after run_z_probe + PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe PROBE_PT_BIG_RAISE // Raise to big clearance after run_z_probe }; - float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true); - inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true) { - return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative); - } - #define DEPLOY_PROBE() set_probe_deployed(true) - #define STOW_PROBE() set_probe_deployed(false) - #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) - extern const char msg_wait_for_bed_heating[25]; - #endif +#endif -#else +class Probe { +public: - constexpr xyz_pos_t probe_offset{0}; - constexpr xy_pos_t probe_offset_xy{0}; + #if HAS_BED_PROBE - #define DEPLOY_PROBE() - #define STOW_PROBE() + static xyz_pos_t offset; -#endif + // Use offset_xy for read only access + // More optimal the XY offset is known to always be zero. + #if HAS_PROBE_XY_OFFSET + static const xyz_pos_t &offset_xy; + #else + static constexpr xy_pos_t offset_xy{0}; + #endif -#if HAS_BED_PROBE || HAS_LEVELING - #if IS_KINEMATIC - constexpr float printable_radius = ( - #if ENABLED(DELTA) - DELTA_PRINTABLE_RADIUS - #elif IS_SCARA - SCARA_PRINTABLE_RADIUS - #endif - ); - - inline float probe_radius() { - return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(probe_offset_xy.x, probe_offset_xy.y)); + static bool set_deployed(const bool deploy); + + #ifdef Z_AFTER_PROBING + static void move_z_after_probing(); + #endif + static float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true); + static inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true) { + return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative); } + #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) + static PGM_P msg_wait_for_bed_heating[25]; + #endif + + #else + + static constexpr xyz_pos_t offset{0}; + static constexpr xy_pos_t offset_xy{0}; + + static bool set_deployed(const bool) { return false; } + #endif - inline float probe_min_x() { - return ( - #if IS_KINEMATIC - (X_CENTER) - probe_radius() - #else - _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset_xy.x) - #endif - ); - } - inline float probe_max_x() { - return ( - #if IS_KINEMATIC - (X_CENTER) + probe_radius() - #else - _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset_xy.x) - #endif - ); - } - inline float probe_min_y() { - return ( - #if IS_KINEMATIC - (Y_CENTER) - probe_radius() - #else - _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset_xy.y) - #endif - ); - } - inline float probe_max_y() { - return ( - #if IS_KINEMATIC - (Y_CENTER) + probe_radius() - #else - _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset_xy.y) - #endif - ); - } - - #if NEEDS_THREE_PROBE_POINTS - // Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used. - template - inline void get_three_probe_points(T points[3]) { - #if ENABLED(HAS_FIXED_3POINT) - points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y); - points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y); - points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y); - #else + static inline bool deploy() { return set_deployed(true); } + static inline bool stow() { return set_deployed(false); } + + #if HAS_BED_PROBE || HAS_LEVELING + #if IS_KINEMATIC + static constexpr float printable_radius = ( + #if ENABLED(DELTA) + DELTA_PRINTABLE_RADIUS + #elif IS_SCARA + SCARA_PRINTABLE_RADIUS + #endif + ); + + static inline float probe_radius() { + return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(offset_xy.x, offset_xy.y)); + } + #endif + + static inline float min_x() { + return ( #if IS_KINEMATIC - constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025, - COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5; - points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0); - points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120); - points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240); + (X_CENTER) - probe_radius() #else - points[0].set(probe_min_x(), probe_min_y()); - points[1].set(probe_max_x(), probe_min_y()); - points[2].set((probe_max_x() - probe_min_x()) / 2, probe_max_y()); + _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + offset_xy.x) #endif - #endif + ); } + static inline float max_x() { + return ( + #if IS_KINEMATIC + (X_CENTER) + probe_radius() + #else + _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + offset_xy.x) + #endif + ); + } + static inline float min_y() { + return ( + #if IS_KINEMATIC + (Y_CENTER) - probe_radius() + #else + _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + offset_xy.y) + #endif + ); + } + static inline float max_y() { + return ( + #if IS_KINEMATIC + (Y_CENTER) + probe_radius() + #else + _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + offset_xy.y) + #endif + ); + } + + #if NEEDS_THREE_PROBE_POINTS + // Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used. + template + static inline void get_three_points(T points[3]) { + #if ENABLED(HAS_FIXED_3POINT) + points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y); + points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y); + points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y); + #else + #if IS_KINEMATIC + constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025, + COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5; + points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0); + points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120); + points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240); + #else + points[0].set(min_x(), min_y()); + points[1].set(max_x(), min_y()); + points[2].set((max_x() - min_x()) / 2, max_y()); + #endif + #endif + } + #endif + + #endif // HAS_BED_PROBE + + #if HAS_Z_SERVO_PROBE + static void servo_probe_init(); #endif -#endif -#if HAS_Z_SERVO_PROBE - void servo_probe_init(); -#endif + #if QUIET_PROBING + static void set_probing_paused(const bool p); + #endif -#if QUIET_PROBING - void probing_pause(const bool p); -#endif +private: + static bool move_to_z(const float z, const feedRate_t fr_mm_s); + static void do_z_raise(const float z_raise); + static float run_z_probe(); +}; + +extern Probe probe; From e58d1bf97405f89d0a720c90a63ad677ca0624b5 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sat, 1 Feb 2020 05:50:44 -0500 Subject: [PATCH 16/22] G34 automatic point assignment (#16473) --- Marlin/Configuration_adv.h | 53 ++++++--- Marlin/src/feature/z_stepper_align.cpp | 137 ++++++++++++++++++++++ Marlin/src/feature/z_stepper_align.h | 41 +++++++ Marlin/src/gcode/bedlevel/G26.cpp | 2 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 132 ++++++++------------- Marlin/src/module/configuration_store.cpp | 38 +++++- 6 files changed, 298 insertions(+), 105 deletions(-) create mode 100644 Marlin/src/feature/z_stepper_align.cpp create mode 100644 Marlin/src/feature/z_stepper_align.h diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e2bda3f8055d..9a979f2528f7 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -668,11 +668,37 @@ */ //#define Z_STEPPER_AUTO_ALIGN #if ENABLED(Z_STEPPER_AUTO_ALIGN) - // Define probe X and Y positions for Z1, Z2 [, Z3] - #define Z_STEPPER_ALIGN_XY { { 10, 190 }, { 100, 10 }, { 190, 190 } } + // Define probe X and Y positions for Z1, Z2 [, Z3 [, Z4]] + // If not defined, probe limits will be used. + // Override with 'M422 S X Y' + //#define Z_STEPPER_ALIGN_XY { { 10, 190 }, { 100, 10 }, { 190, 190 } } + + /** + * Orientation for the automatically-calculated probe positions. + * Override Z stepper align points with 'M422 S X Y' + * + * 2 Steppers: (0) (1) + * | | 2 | + * | 1 2 | | + * | | 1 | + * + * 3 Steppers: (0) (1) (2) (3) + * | 3 | 1 | 2 1 | 2 | + * | | 3 | | 3 | + * | 1 2 | 2 | 3 | 1 | + * + * 4 Steppers: (0) (1) (2) (3) + * | 4 3 | 1 4 | 2 1 | 3 2 | + * | | | | | + * | 1 2 | 2 3 | 3 4 | 4 1 | + * + */ + #ifndef Z_STEPPER_ALIGN_XY + //#define Z_STEPPERS_ORIENTATION 0 + #endif // Provide Z stepper positions for more rapid convergence in bed alignment. - // Currently requires triple stepper drivers. + // Requires triple stepper drivers (i.e., set NUM_Z_STEPPER_DRIVERS to 3) //#define Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) // Define Stepper XY positions for Z1, Z2, Z3 corresponding to @@ -680,23 +706,16 @@ // Define one position per Z stepper in stepper driver order. #define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } } #else - // Amplification factor. Used to scale the correction step up or down. - // In case the stepper (spindle) position is further out than the test point. - // Use a value > 1. NOTE: This may cause instability - #define Z_STEPPER_ALIGN_AMP 1.0 + // Amplification factor. Used to scale the correction step up or down in case + // the stepper (spindle) position is farther out than the test point. + #define Z_STEPPER_ALIGN_AMP 1.0 // Use a value > 1.0 NOTE: This may cause instability! #endif - // Set number of iterations to align - #define Z_STEPPER_ALIGN_ITERATIONS 3 - - // Enable to restore leveling setup after operation - #define RESTORE_LEVELING_AFTER_G34 - // On a 300mm bed a 5% grade would give a misalignment of ~1.5cm - #define G34_MAX_GRADE 5 // (%) Maximum incline G34 will handle - - // Stop criterion. If the accuracy is better than this stop iterating early - #define Z_STEPPER_ALIGN_ACC 0.02 + #define G34_MAX_GRADE 5 // (%) Maximum incline that G34 will handle + #define Z_STEPPER_ALIGN_ITERATIONS 5 // Number of iterations to apply during alignment + #define Z_STEPPER_ALIGN_ACC 0.02 // Stop iterating early if the accuracy is better than this + #define RESTORE_LEVELING_AFTER_G34 // Restore leveling after G34 is done? #endif // @section motion diff --git a/Marlin/src/feature/z_stepper_align.cpp b/Marlin/src/feature/z_stepper_align.cpp new file mode 100644 index 000000000000..0e2b7cef2ada --- /dev/null +++ b/Marlin/src/feature/z_stepper_align.cpp @@ -0,0 +1,137 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2019 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 . + * + */ + +/** + * feature/z_stepper_align.cpp + */ + +#include "../inc/MarlinConfigPre.h" + +#if ENABLED(Z_STEPPER_AUTO_ALIGN) + +#include "z_stepper_align.h" +#include "../module/probe.h" + +ZStepperAlign z_stepper_align; + +xy_pos_t ZStepperAlign::xy[NUM_Z_STEPPER_DRIVERS]; + +#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPER_DRIVERS]; +#endif + +void ZStepperAlign::reset_to_default() { + #ifdef Z_STEPPER_ALIGN_XY + + constexpr xy_pos_t xy_init[] = Z_STEPPER_ALIGN_XY; + static_assert(COUNT(xy_init) == NUM_Z_STEPPER_DRIVERS, + "Z_STEPPER_ALIGN_XY requires " + #if NUM_Z_STEPPER_DRIVERS == 4 + "four {X,Y} entries (Z, Z2, Z3, and Z4)." + #elif NUM_Z_STEPPER_DRIVERS == 3 + "three {X,Y} entries (Z, Z2, and Z3)." + #else + "two {X,Y} entries (Z and Z2)." + #endif + ); + + constexpr xyz_pos_t dpo = NOZZLE_TO_PROBE_OFFSET; + + #define LTEST(N) (xy_init[N].x >= _MAX(X_MIN_BED + MIN_PROBE_EDGE_LEFT, X_MIN_POS + dpo.x) - 0.00001f) + #define RTEST(N) (xy_init[N].x <= _MIN(X_MAX_BED - MIN_PROBE_EDGE_RIGHT, X_MAX_POS + dpo.x) + 0.00001f) + #define FTEST(N) (xy_init[N].y >= _MAX(Y_MIN_BED + MIN_PROBE_EDGE_FRONT, Y_MIN_POS + dpo.y) - 0.00001f) + #define BTEST(N) (xy_init[N].y <= _MIN(Y_MAX_BED - MIN_PROBE_EDGE_BACK, Y_MAX_POS + dpo.y) + 0.00001f) + + static_assert(LTEST(0) && RTEST(0), "The 1st Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); + static_assert(FTEST(0) && BTEST(0), "The 1st Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); + static_assert(LTEST(1) && RTEST(1), "The 2nd Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); + static_assert(FTEST(1) && BTEST(1), "The 2nd Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); + #if NUM_Z_STEPPER_DRIVERS >= 3 + static_assert(LTEST(2) && RTEST(2), "The 3rd Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); + static_assert(FTEST(2) && BTEST(2), "The 3rd Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); + #if NUM_Z_STEPPER_DRIVERS >= 4 + static_assert(LTEST(3) && RTEST(3), "The 4th Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); + static_assert(FTEST(3) && BTEST(3), "The 4th Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); + #endif + #endif + + #else // !defined(Z_STEPPER_ALIGN_XY) + + const xy_pos_t xy_init[] = { + #if NUM_Z_STEPPER_DRIVERS >= 3 // First probe point... + #if !Z_STEPPERS_ORIENTATION + { probe.min_x(), probe.min_y() }, // SW + #elif Z_STEPPERS_ORIENTATION == 1 + { probe.min_x(), probe.max_y() }, // NW + #elif Z_STEPPERS_ORIENTATION == 2 + { probe.max_x(), probe.max_y() }, // NE + #elif Z_STEPPERS_ORIENTATION == 3 + { probe.max_x(), probe.min_y() }, // SE + #else + #error "Z_STEPPERS_ORIENTATION must be from 0 to 3 (first point SW, NW, NE, SE)." + #endif + #if NUM_Z_STEPPER_DRIVERS == 4 // 3 more points... + #if !Z_STEPPERS_ORIENTATION + { probe.min_x(), probe.max_y() }, { probe.max_x(), probe.max_y() }, { probe.max_x(), probe.min_y() } // SW + #elif Z_STEPPERS_ORIENTATION == 1 + { probe.max_x(), probe.max_y() }, { probe.max_x(), probe.min_y() }, { probe.min_x(), probe.min_y() } // NW + #elif Z_STEPPERS_ORIENTATION == 2 + { probe.max_x(), probe.min_y() }, { probe.min_x(), probe.min_y() }, { probe.min_x(), probe.max_y() } // NE + #elif Z_STEPPERS_ORIENTATION == 3 + { probe.min_x(), probe.min_y() }, { probe.min_x(), probe.max_y() }, { probe.max_x(), probe.max_y() } // SE + #endif + #elif !Z_STEPPERS_ORIENTATION // or 2 more points... + { probe.max_x(), probe.min_y() }, { X_CENTER, probe.max_y() } // SW + #elif Z_STEPPERS_ORIENTATION == 1 + { probe.min_x(), probe.min_y() }, { probe.max_x(), Y_CENTER } // NW + #elif Z_STEPPERS_ORIENTATION == 2 + { probe.min_x(), probe.max_y() }, { X_CENTER, probe.min_y() } // NE + #elif Z_STEPPERS_ORIENTATION == 3 + { probe.max_x(), probe.max_y() }, { probe.min_x(), Y_CENTER } // SE + #endif + #elif Z_STEPPERS_ORIENTATION + { X_CENTER, probe.min_y() }, { X_CENTER, probe.max_y() } + #else + { probe.min_x(), Y_CENTER }, { probe.max_x(), Y_CENTER } + #endif + }; + + #endif // !defined(Z_STEPPER_ALIGN_XY) + + COPY(xy, xy_init); + + #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + constexpr xy_pos_t stepper_xy_init[] = Z_STEPPER_ALIGN_STEPPER_XY; + static_assert( + COUNT(stepper_xy_init) == NUM_Z_STEPPER_DRIVERS, + "Z_STEPPER_ALIGN_STEPPER_XY requires " + #if NUM_Z_STEPPER_DRIVERS == 4 + "four {X,Y} entries (Z, Z2, Z3, and Z4)." + #elif NUM_Z_STEPPER_DRIVERS == 3 + "three {X,Y} entries (Z, Z2, and Z3)." + #endif + ); + COPY(stepper_xy, stepper_xy_init); + #endif +} + +#endif // Z_STEPPER_AUTO_ALIGN diff --git a/Marlin/src/feature/z_stepper_align.h b/Marlin/src/feature/z_stepper_align.h new file mode 100644 index 000000000000..8b31ac4bded9 --- /dev/null +++ b/Marlin/src/feature/z_stepper_align.h @@ -0,0 +1,41 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2019 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 . + * + */ +#pragma once + +/** + * feature/z_stepper_align.h + */ + +#include "../inc/MarlinConfig.h" + +class ZStepperAlign { + public: + static xy_pos_t xy[NUM_Z_STEPPER_DRIVERS]; + + #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + static xy_pos_t stepper_xy[NUM_Z_STEPPER_DRIVERS]; + #endif + + static void reset_to_default(); +}; + +extern ZStepperAlign z_stepper_align; diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 611538a909f3..7b580b666f1a 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -707,7 +707,7 @@ void GcodeSuite::G26() { if (location.valid()) { const xy_pos_t circle = _GET_MESH_POS(location.pos); - // If this mesh location is outside the printable_radius, skip it. + // If this mesh location is outside the printable radius, skip it. if (!position_is_reachable(circle)) continue; // Determine where to start and end the circle, diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index a35b3faef743..4532da8f8ca6 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -24,6 +24,8 @@ #if ENABLED(Z_STEPPER_AUTO_ALIGN) +#include "../../feature/z_stepper_align.h" + #include "../gcode.h" #include "../../module/planner.h" #include "../../module/stepper.h" @@ -45,68 +47,6 @@ #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" -// -// Sanity check G34 / M422 settings -// -constexpr xy_pos_t test_z_stepper_align_xy[] = Z_STEPPER_ALIGN_XY; - -#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - - static_assert(COUNT(test_z_stepper_align_xy) >= NUM_Z_STEPPER_DRIVERS, - "Z_STEPPER_ALIGN_XY requires at least three {X,Y} entries (Z, Z2, Z3, ...)." - ); - - constexpr float test_z_stepper_align_stepper_xy[][XY] = Z_STEPPER_ALIGN_STEPPER_XY; - static_assert( - COUNT(test_z_stepper_align_stepper_xy) == NUM_Z_STEPPER_DRIVERS, - "Z_STEPPER_ALIGN_STEPPER_XY requires three {X,Y} entries (one per Z stepper)." - ); - -#else - - static_assert(COUNT(test_z_stepper_align_xy) == NUM_Z_STEPPER_DRIVERS, - #if NUM_Z_STEPPER_DRIVERS == 4 - "Z_STEPPER_ALIGN_XY requires four {X,Y} entries (Z, Z2, Z3, and Z4)." - #elif NUM_Z_STEPPER_DRIVERS == 3 - "Z_STEPPER_ALIGN_XY requires three {X,Y} entries (Z, Z2, and Z3)." - #else - "Z_STEPPER_ALIGN_XY requires two {X,Y} entries (Z and Z2)." - #endif - ); - -#endif - -constexpr xyz_pos_t dpo = NOZZLE_TO_PROBE_OFFSET; - -#define LTEST(N) (test_z_stepper_align_xy[N].x >= _MAX(X_MIN_BED + MIN_PROBE_EDGE_LEFT, X_MIN_POS + dpo.x) - 0.00001f) -#define RTEST(N) (test_z_stepper_align_xy[N].x <= _MIN(X_MAX_BED - MIN_PROBE_EDGE_RIGHT, X_MAX_POS + dpo.x) + 0.00001f) -#define FTEST(N) (test_z_stepper_align_xy[N].y >= _MAX(Y_MIN_BED + MIN_PROBE_EDGE_FRONT, Y_MIN_POS + dpo.y) - 0.00001f) -#define BTEST(N) (test_z_stepper_align_xy[N].y <= _MIN(Y_MAX_BED - MIN_PROBE_EDGE_BACK, Y_MAX_POS + dpo.y) + 0.00001f) - -static_assert(LTEST(0) && RTEST(0), "The 1st Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); -static_assert(FTEST(0) && BTEST(0), "The 1st Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); -static_assert(LTEST(1) && RTEST(1), "The 2nd Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); -static_assert(FTEST(1) && BTEST(1), "The 2nd Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); -#if NUM_Z_STEPPER_DRIVERS >= 3 - static_assert(LTEST(2) && RTEST(2), "The 3rd Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); - static_assert(FTEST(2) && BTEST(2), "The 3rd Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); - #if NUM_Z_STEPPER_DRIVERS >= 4 - static_assert(LTEST(3) && RTEST(3), "The 4th Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); - static_assert(FTEST(3) && BTEST(3), "The 4th Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); - #endif -#endif - -// -// G34 / M422 shared data -// -static xy_pos_t z_stepper_align_pos[] = Z_STEPPER_ALIGN_XY; - -#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - static xy_pos_t z_stepper_align_stepper_pos[] = Z_STEPPER_ALIGN_STEPPER_XY; -#endif - -#define G34_PROBE_COUNT COUNT(z_stepper_align_pos) - inline void set_all_z_lock(const bool lock) { stepper.set_z_lock(lock); stepper.set_z2_lock(lock); @@ -201,11 +141,11 @@ void GcodeSuite::G34() { // iteration this will be re-calculated based on the actual bed position float z_probe = Z_BASIC_CLEARANCE + (G34_MAX_GRADE) * 0.01f * ( #if NUM_Z_STEPPER_DRIVERS == 3 - SQRT(_MAX(HYPOT2(z_stepper_align_pos[0].x - z_stepper_align_pos[0].y, z_stepper_align_pos[1].x - z_stepper_align_pos[1].y), - HYPOT2(z_stepper_align_pos[1].x - z_stepper_align_pos[1].y, z_stepper_align_pos[2].x - z_stepper_align_pos[2].y), - HYPOT2(z_stepper_align_pos[2].x - z_stepper_align_pos[2].y, z_stepper_align_pos[0].x - z_stepper_align_pos[0].y))) + SQRT(_MAX(HYPOT2(z_stepper_align.xy[0].x - z_stepper_align.xy[0].y, z_stepper_align.xy[1].x - z_stepper_align.xy[1].y), + HYPOT2(z_stepper_align.xy[1].x - z_stepper_align.xy[1].y, z_stepper_align.xy[2].x - z_stepper_align.xy[2].y), + HYPOT2(z_stepper_align.xy[2].x - z_stepper_align.xy[2].y, z_stepper_align.xy[0].x - z_stepper_align.xy[0].y))) #else - HYPOT(z_stepper_align_pos[0].x - z_stepper_align_pos[0].y, z_stepper_align_pos[1].x - z_stepper_align_pos[1].y) + HYPOT(z_stepper_align.xy[0].x - z_stepper_align.xy[0].y, z_stepper_align.xy[1].x - z_stepper_align.xy[1].y) #endif ); @@ -216,31 +156,39 @@ void GcodeSuite::G34() { current_position.z -= z_probe * 0.5f; float last_z_align_move[NUM_Z_STEPPER_DRIVERS] = ARRAY_N(NUM_Z_STEPPER_DRIVERS, 10000.0f, 10000.0f, 10000.0f), - z_measured[G34_PROBE_COUNT] = { 0 }, + z_measured[NUM_Z_STEPPER_DRIVERS] = { 0 }, z_maxdiff = 0.0f, amplification = z_auto_align_amplification; uint8_t iteration; bool err_break = false; + + #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + bool adjustment_reverse = false; + #endif + for (iteration = 0; iteration < z_auto_align_iterations; ++iteration) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> probing all positions."); SERIAL_ECHOLNPAIR("\nITERATION: ", int(iteration + 1)); // Initialize minimum value - float z_measured_min = 100000.0f, + float z_measured_min = 100000.0f, z_measured_max = -100000.0f; // Probe all positions (one per Z-Stepper) - for (uint8_t i = 0; i < G34_PROBE_COUNT; ++i) { + for (uint8_t i = 0; i < NUM_Z_STEPPER_DRIVERS; ++i) { // iteration odd/even --> downward / upward stepper sequence - const uint8_t iprobe = (iteration & 1) ? G34_PROBE_COUNT - 1 - i : i; + const uint8_t iprobe = (iteration & 1) ? NUM_Z_STEPPER_DRIVERS - 1 - i : i; // Safe clearance even on an incline if (iteration == 0 || i > 0) do_blocking_move_to_z(z_probe); + if (DEBUGGING(LEVELING)) + DEBUG_ECHOLNPAIR_P(PSTR("Probing X"), z_stepper_align.xy[iprobe].x, SP_Y_STR, z_stepper_align.xy[iprobe].y); + // Probe a Z height for each stepper. - const float z_probed_height = probe.probe_at_point(z_stepper_align_pos[iprobe], raise_after, 0, true); + const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true); if (isnan(z_probed_height)) { SERIAL_ECHOLNPGM("Probing failed."); err_break = true; @@ -279,15 +227,15 @@ void GcodeSuite::G34() { // This allows the actual adjustment logic to be shared by both algorithms. linear_fit_data lfd; incremental_LSF_reset(&lfd); - for (uint8_t i = 0; i < G34_PROBE_COUNT; ++i) { - SERIAL_ECHOLNPAIR("PROBEPT_", int(i + 1), ": ", z_measured[i]); - incremental_LSF(&lfd, z_stepper_align_pos[i], z_measured[i]); + for (uint8_t i = 0; i < NUM_Z_STEPPER_DRIVERS; ++i) { + SERIAL_ECHOLNPAIR("PROBEPT_", i + '1', ": ", z_measured[i]); + incremental_LSF(&lfd, z_stepper_align.xy[i], z_measured[i]); } finish_incremental_LSF(&lfd); z_measured_min = 100000.0f; for (uint8_t i = 0; i < NUM_Z_STEPPER_DRIVERS; ++i) { - z_measured[i] = -(lfd.A * z_stepper_align_stepper_pos[i].x + lfd.B * z_stepper_align_stepper_pos[i].y); + z_measured[i] = -(lfd.A * z_stepper_align.stepper_xy[i].x + lfd.B * z_stepper_align.stepper_xy[i].y); z_measured_min = _MIN(z_measured_min, z_measured[i]); } @@ -309,8 +257,8 @@ void GcodeSuite::G34() { // Correct the individual stepper offsets for (uint8_t zstepper = 0; zstepper < NUM_Z_STEPPER_DRIVERS; ++zstepper) { // Calculate current stepper move - const float z_align_move = z_measured[zstepper] - z_measured_min, - z_align_abs = ABS(z_align_move); + float z_align_move = z_measured[zstepper] - z_measured_min; + const float z_align_abs = ABS(z_align_move); #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) // Optimize one iteration's correction based on the first measurements @@ -318,10 +266,14 @@ void GcodeSuite::G34() { #endif // Check for less accuracy compared to last move - if (last_z_align_move[zstepper] < z_align_abs - 1.0) { + if (last_z_align_move[zstepper] < z_align_abs * 0.7f) { SERIAL_ECHOLNPGM("Decreasing accuracy detected."); - err_break = true; - break; + #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + adjustment_reverse = !adjustment_reverse; + #else + err_break = true; + break; + #endif } // Remember the alignment for the next iteration @@ -342,6 +294,13 @@ void GcodeSuite::G34() { #endif } + #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + // Decreasing accuracy was detected so move was inverted. + // Will match reversed Z steppers on dual steppers. Triple will need more work to map. + if (adjustment_reverse) + z_align_move = -z_align_move; + #endif + // Do a move to correct part of the misalignment for the current stepper do_blocking_move_to_z(amplification * z_align_move + current_position.z); } // for (zstepper) @@ -406,12 +365,13 @@ void GcodeSuite::G34() { * Y : Y position to set (Unchanged if omitted) */ void GcodeSuite::M422() { + if (!parser.seen_any()) { - for (uint8_t i = 0; i < G34_PROBE_COUNT; ++i) - SERIAL_ECHOLNPAIR_P(PSTR("M422 S"), i + 1, SP_X_STR, z_stepper_align_pos[i].x, SP_Y_STR, z_stepper_align_pos[i].y); + for (uint8_t i = 0; i < NUM_Z_STEPPER_DRIVERS; ++i) + SERIAL_ECHOLNPAIR_P(PSTR("M422 S"), i + '1', SP_X_STR, z_stepper_align.xy[i].x, SP_Y_STR, z_stepper_align.xy[i].y); #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) for (uint8_t i = 0; i < NUM_Z_STEPPER_DRIVERS; ++i) - SERIAL_ECHOLNPAIR_P(PSTR("M422 W"), i + 1, SP_X_STR, z_stepper_align_stepper_pos[i].x, SP_Y_STR, z_stepper_align_stepper_pos[i].y); + SERIAL_ECHOLNPAIR_P(PSTR("M422 W"), i + '1', SP_X_STR, z_stepper_align.stepper_xy[i].x, SP_Y_STR, z_stepper_align.stepper_xy[i].y); #endif return; } @@ -427,9 +387,9 @@ void GcodeSuite::M422() { xy_pos_t *pos_dest = ( #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - !is_probe_point ? z_stepper_align_stepper_pos : + !is_probe_point ? z_stepper_align.stepper_xy : #endif - z_stepper_align_pos + z_stepper_align.xy ); if (!is_probe_point @@ -451,7 +411,7 @@ void GcodeSuite::M422() { int8_t position_index; if (is_probe_point) { position_index = parser.intval('S') - 1; - if (!WITHIN(position_index, 0, int8_t(G34_PROBE_COUNT) - 1)) { + if (!WITHIN(position_index, 0, int8_t(NUM_Z_STEPPER_DRIVERS) - 1)) { SERIAL_ECHOLNPGM("?(S) Z-ProbePosition index invalid."); return; } diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 05b67c984ca2..0e4e6cef305a 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -37,7 +37,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V75" +#define EEPROM_VERSION "V76" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -66,6 +66,10 @@ #include "../feature/bedlevel/bedlevel.h" #endif +#if ENABLED(Z_STEPPER_AUTO_ALIGN) + #include "../feature/z_stepper_align.h" +#endif + #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extensible_ui/ui_api.h" #endif @@ -251,6 +255,16 @@ typedef struct SettingsDataStruct { z4_endstop_adj; // M666 (S4) Z #endif + // + // Z_STEPPER_AUTO_ALIGN, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS + // + #if ENABLED(Z_STEPPER_AUTO_ALIGN) + xy_pos_t z_stepper_align_xy[NUM_Z_STEPPER_DRIVERS]; // M422 S X Y + #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + xy_pos_t z_stepper_align_stepper_xy[NUM_Z_STEPPER_DRIVERS]; // M422 W X Y + #endif + #endif + // // ULTIPANEL // @@ -801,6 +815,13 @@ void MarlinSettings::postprocess() { #endif } + #if ENABLED(Z_STEPPER_AUTO_ALIGN) + EEPROM_WRITE(z_stepper_align.xy); + #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + EEPROM_WRITE(z_stepper_align.stepper_xy); + #endif + #endif + // // LCD Preheat settings // @@ -1669,6 +1690,13 @@ void MarlinSettings::postprocess() { #endif } + #if ENABLED(Z_STEPPER_AUTO_ALIGN) + EEPROM_READ(z_stepper_align.xy); + #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + EEPROM_READ(z_stepper_align.stepper_xy); + #endif + #endif + // // LCD Preheat settings // @@ -2473,6 +2501,14 @@ void MarlinSettings::reset() { #endif #endif + // + // Z Stepper Auto-alignment points + // + + #if ENABLED(Z_STEPPER_AUTO_ALIGN) + z_stepper_align.reset_to_default(); + #endif + // // Servo Angles // From c3cab37d7eec97f871ad73d07a3abfa616bbd35c Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sat, 1 Feb 2020 02:51:57 -0800 Subject: [PATCH 17/22] Fix Temperature::over_autostart_threshold (#16749) --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index d90a2123d163..24cd138c5d69 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2143,7 +2143,7 @@ void Temperature::disable_all_heaters() { bool Temperature::over_autostart_threshold() { #if HOTENDS - HOTEND_LOOP() if (degTargetHotend(e) < (EXTRUDE_MINTEMP) / 2) return true; + HOTEND_LOOP() if (degTargetHotend(e) > (EXTRUDE_MINTEMP) / 2) return true; #endif #if HAS_HEATED_BED if (degTargetBed() > BED_MINTEMP) return true; From 832d33ce9df787a41d772b432118d31a92105512 Mon Sep 17 00:00:00 2001 From: Acenotass <44540957+Acenotass@users.noreply.github.com> Date: Sat, 1 Feb 2020 16:53:18 +0600 Subject: [PATCH 18/22] Update Russian language (#16750) --- Marlin/src/lcd/language/language_ru.h | 53 ++++++++++++++++----------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index f86a0bcfc494..51875761bd76 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -50,7 +50,7 @@ namespace Language_ru { PROGMEM Language_Str MSG_DISABLE_STEPPERS = _UxGT("Выключить двигатели"); PROGMEM Language_Str MSG_DEBUG_MENU = _UxGT("Меню отладки"); PROGMEM Language_Str MSG_PROGRESS_BAR_TEST = _UxGT("Тест индикатора"); - PROGMEM Language_Str MSG_AUTO_HOME = _UxGT("Автопарковка"); + PROGMEM Language_Str MSG_AUTO_HOME = _UxGT("Парковка XYZ"); PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("Парковка X"); PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Парковка Y"); PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Парковка Z"); @@ -63,20 +63,29 @@ namespace Language_ru { PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Коррекции применены"); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Запомнить ноль"); PROGMEM Language_Str MSG_PREHEAT_1 = _UxGT("Преднагрев ") PREHEAT_1_LABEL; - PROGMEM Language_Str MSG_PREHEAT_1_H = _UxGT("Преднагрев ") PREHEAT_1_LABEL " ~"; - PROGMEM Language_Str MSG_PREHEAT_1_END = _UxGT("Преднагрев ") PREHEAT_1_LABEL _UxGT(" сопло"); - PROGMEM Language_Str MSG_PREHEAT_1_END_E = _UxGT("Преднагрев ") PREHEAT_1_LABEL _UxGT(" сопло ~"); - PROGMEM Language_Str MSG_PREHEAT_1_ALL = _UxGT("Преднагрев ") PREHEAT_1_LABEL _UxGT(" всё"); - PROGMEM Language_Str MSG_PREHEAT_1_BEDONLY = _UxGT("Преднагрев ") PREHEAT_1_LABEL _UxGT(" стол"); - PROGMEM Language_Str MSG_PREHEAT_1_SETTINGS = _UxGT("Преднагрев ") PREHEAT_1_LABEL _UxGT(" настр."); + PROGMEM Language_Str MSG_PREHEAT_1_H = _UxGT("Нагрев ") PREHEAT_1_LABEL " ~"; + PROGMEM Language_Str MSG_PREHEAT_1_END = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" сопло"); + PROGMEM Language_Str MSG_PREHEAT_1_END_E = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" сопло ~"); + PROGMEM Language_Str MSG_PREHEAT_1_ALL = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" всё"); + PROGMEM Language_Str MSG_PREHEAT_1_BEDONLY = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" стол"); + PROGMEM Language_Str MSG_PREHEAT_1_SETTINGS = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" правка"); PROGMEM Language_Str MSG_PREHEAT_2 = _UxGT("Преднагрев ") PREHEAT_2_LABEL; - PROGMEM Language_Str MSG_PREHEAT_2_H = _UxGT("Преднагрев ") PREHEAT_2_LABEL " ~"; - PROGMEM Language_Str MSG_PREHEAT_2_END = _UxGT("Преднагрев ") PREHEAT_2_LABEL _UxGT(" сопло"); - PROGMEM Language_Str MSG_PREHEAT_2_END_E = _UxGT("Преднагрев ") PREHEAT_2_LABEL _UxGT(" сопло ~"); - PROGMEM Language_Str MSG_PREHEAT_2_ALL = _UxGT("Преднагрев ") PREHEAT_2_LABEL _UxGT(" всё"); - PROGMEM Language_Str MSG_PREHEAT_2_BEDONLY = _UxGT("Преднагрев ") PREHEAT_2_LABEL _UxGT(" стол"); - PROGMEM Language_Str MSG_PREHEAT_2_SETTINGS = _UxGT("Преднагрев ") PREHEAT_2_LABEL _UxGT(" настр."); + PROGMEM Language_Str MSG_PREHEAT_2_H = _UxGT("Нагрев ") PREHEAT_2_LABEL " ~"; + PROGMEM Language_Str MSG_PREHEAT_2_END = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" сопло"); + PROGMEM Language_Str MSG_PREHEAT_2_END_E = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" сопло ~"); + PROGMEM Language_Str MSG_PREHEAT_2_ALL = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" всё"); + PROGMEM Language_Str MSG_PREHEAT_2_BEDONLY = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" стол"); + PROGMEM Language_Str MSG_PREHEAT_2_SETTINGS = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" правка"); PROGMEM Language_Str MSG_COOLDOWN = _UxGT("Охлаждение"); + PROGMEM Language_Str MSG_LASER_MENU = _UxGT("Управление лазером"); + PROGMEM Language_Str MSG_LASER_OFF = _UxGT("Выключить лазер"); + PROGMEM Language_Str MSG_LASER_ON = _UxGT("Включить лазер"); + PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Мощность лазера"); + PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Шпиндель управление"); + PROGMEM Language_Str MSG_SPINDLE_OFF = _UxGT("Выключить шпиндель"); + PROGMEM Language_Str MSG_SPINDLE_ON = _UxGT("Включить шпиндель"); + PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Мощность шпинделя"); + PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Инверсия шпинделя"); PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Включить питание"); PROGMEM Language_Str MSG_SWITCH_PS_OFF = _UxGT("Выключить питание"); PROGMEM Language_Str MSG_EXTRUDE = _UxGT("Экструзия"); @@ -87,7 +96,7 @@ namespace Language_ru { PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Выровнять углы"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Следующий угол"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Редактировать сетку"); - PROGMEM Language_Str MSG_EDITING_STOPPED = _UxGT("Ред. сетки завершено"); + PROGMEM Language_Str MSG_EDITING_STOPPED = _UxGT("Правка сетки окончена"); PROGMEM Language_Str MSG_PROBING_MESH = _UxGT("Точка сетки:"); PROGMEM Language_Str MSG_MESH_X = _UxGT("Индекс X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Индекс Y"); @@ -108,10 +117,10 @@ namespace Language_ru { PROGMEM Language_Str MSG_UBL_DOING_G29 = _UxGT("Выполняем G29"); PROGMEM Language_Str MSG_UBL_TOOLS = _UxGT("Утилиты UBL"); PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Калибровка UBL"); - PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Постр. сетку от руки"); - PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Пост. шимм и измер."); + PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Правка сетки вручную"); + PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Z-пробник и замеры"); PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Измерение"); - PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Удал. и измер. стол"); + PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Убрать и замер стола"); PROGMEM Language_Str MSG_UBL_MOVING_TO_NEXT = _UxGT("Двигаемся дальше"); PROGMEM Language_Str MSG_UBL_ACTIVATE_MESH = _UxGT("Активировать UBL"); PROGMEM Language_Str MSG_UBL_DEACTIVATE_MESH = _UxGT("Деактивировать UBL"); @@ -128,7 +137,7 @@ namespace Language_ru { PROGMEM Language_Str MSG_UBL_BUILD_MESH_M1 = _UxGT("Построить сетку ") PREHEAT_1_LABEL; PROGMEM Language_Str MSG_UBL_BUILD_MESH_M2 = _UxGT("Построить сетку ") PREHEAT_2_LABEL; PROGMEM Language_Str MSG_UBL_BUILD_COLD_MESH = _UxGT("Построить хол. сетку"); - PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Устан. высоту сетки"); + PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Правка высоты сетки"); PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Высота"); PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Проверить сетку"); PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M1 = _UxGT("Проверить сетку ") PREHEAT_1_LABEL; @@ -220,8 +229,10 @@ namespace Language_ru { PROGMEM Language_Str MSG_MAX = " " LCD_STR_THERMOMETER _UxGT(" Макс"); PROGMEM Language_Str MSG_FACTOR = " " LCD_STR_THERMOMETER _UxGT(" Фактор"); PROGMEM Language_Str MSG_AUTOTEMP = _UxGT("Автотемпература"); - PROGMEM Language_Str MSG_LCD_ON = _UxGT("Вкл."); - PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Выкл."); + PROGMEM Language_Str MSG_LCD_ON = _UxGT("Вкл"); + PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Выкл"); + PROGMEM Language_Str MSG_PID_AUTOTUNE = _UxGT("Автонастройка"); + PROGMEM Language_Str MSG_PID_AUTOTUNE_E = _UxGT("Автонастройка *"); PROGMEM Language_Str MSG_SELECT = _UxGT("Выбор"); PROGMEM Language_Str MSG_SELECT_E = _UxGT("Выбор *"); PROGMEM Language_Str MSG_ACC = _UxGT("Ускорение"); @@ -266,7 +277,7 @@ namespace Language_ru { PROGMEM Language_Str MSG_STORE_EEPROM = _UxGT("Сохранить настройки"); PROGMEM Language_Str MSG_LOAD_EEPROM = _UxGT("Загрузить настройки"); PROGMEM Language_Str MSG_RESTORE_FAILSAFE = _UxGT("Вернуть настройки"); - PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("Инициализация EEPROM"); + PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("Изначальный EEPROM"); PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Обновление прошивки"); PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Сброс принтера"); PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT("Обновить"); From 0d342bac51a5f32d143f0dba9c65af820dfab621 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Feb 2020 06:27:17 -0600 Subject: [PATCH 19/22] Fix CURRENT_STEP_DOWN compile error --- Marlin/src/feature/tmc_util.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index 340855a6dada..84b5c2db7b79 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -281,6 +281,10 @@ } } + #else + + #define step_current_down(...) + #endif template @@ -288,7 +292,7 @@ TMC_driver_data data = get_driver_data(st); if (data.drv_status == 0xFFFFFFFF || data.drv_status == 0x0) return false; - bool did_step_down = false; + bool should_step_down = false; if (need_update_error_counters) { if (data.is_ot /* | data.s2ga | data.s2gb*/) st.error_count++; @@ -308,10 +312,8 @@ #if CURRENT_STEP_DOWN > 0 // Decrease current if is_otpw is true and driver is enabled and there's been more than 4 warnings - if (data.is_otpw && st.otpw_count > 4 && st.isEnabled()) { - step_current_down(st); - did_step_down = true; - } + if (data.is_otpw && st.otpw_count > 4 && st.isEnabled()) + should_step_down = true; #endif if (data.is_otpw) { @@ -325,7 +327,7 @@ if (need_debug_reporting) report_polled_driver_data(st, data); #endif - return did_step_down; + return should_step_down; } void monitor_tmc_drivers() { From 5296af94d22074112ed1a7ca4a7af720cc1ebe94 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Feb 2020 06:49:56 -0600 Subject: [PATCH 20/22] Drop obsolete SD special char handling See #14035 --- Marlin/src/gcode/queue.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index b1673f57f3a9..b9b4d1bd9648 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -491,8 +491,7 @@ void GCodeQueue::get_serial_commands() { * can also interrupt buffering. */ inline void GCodeQueue::get_sdcard_commands() { - static bool stop_buffering = false, - sd_comment_mode = false + static bool sd_comment_mode = false #if ENABLED(PAREN_COMMENTS) , sd_comment_paren_mode = false #endif @@ -500,29 +499,13 @@ void GCodeQueue::get_serial_commands() { if (!IS_SD_PRINTING()) return; - /** - * '#' stops reading from SD to the buffer prematurely, so procedural - * macro calls are possible. If it occurs, stop_buffering is triggered - * and the buffer is run dry; this character _can_ occur in serial com - * due to checksums, however, no checksums are used in SD printing. - */ - - if (length == 0) stop_buffering = false; - uint16_t sd_count = 0; bool card_eof = card.eof(); - while (length < BUFSIZE && !card_eof && !stop_buffering) { + while (length < BUFSIZE && !card_eof) { const int16_t n = card.get(); char sd_char = (char)n; card_eof = card.eof(); - if (card_eof || n == -1 - || sd_char == '\n' || sd_char == '\r' - || ((sd_char == '#' || sd_char == ':') && !sd_comment_mode - #if ENABLED(PAREN_COMMENTS) - && !sd_comment_paren_mode - #endif - ) - ) { + if (card_eof || n == -1 || sd_char == '\n' || sd_char == '\r') { if (card_eof) { card.printingHasFinished(); @@ -548,8 +531,6 @@ void GCodeQueue::get_serial_commands() { else if (n == -1) SERIAL_ERROR_MSG(MSG_SD_ERR_READ); - if (sd_char == '#') stop_buffering = true; - sd_comment_mode = false; // for new command #if ENABLED(PAREN_COMMENTS) sd_comment_paren_mode = false; From 995a9238b37931ea41698abc90388bbb74c0ae5f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Feb 2020 07:51:50 -0600 Subject: [PATCH 21/22] Probe singleton patch Followup to #16751 --- Marlin/src/module/probe.cpp | 4 ++-- Marlin/src/module/probe.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index ef11a52122be..35aaf93f09bb 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -455,8 +455,8 @@ bool Probe::set_deployed(const bool deploy) { * @return true to indicate an error */ -#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) - PGM_P Probe::msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n"; +#if HAS_BED_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) + const char Probe::msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n"; #endif bool Probe::move_to_z(const float z, const feedRate_t fr_mm_s) { diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 5cf0ecc2546c..af01e208cda2 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -61,7 +61,7 @@ class Probe { return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative); } #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) - static PGM_P msg_wait_for_bed_heating[25]; + static const char msg_wait_for_bed_heating[25]; #endif #else From 8367ccf6a87cc0266543dfa0a3b4ef9e946b3b31 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Feb 2020 07:55:53 -0600 Subject: [PATCH 22/22] Fix RGB / Neopixel white color bug See #16752 --- Marlin/src/feature/leds/leds.h | 2 +- Marlin/src/feature/leds/printer_event_leds.h | 2 +- buildroot/share/tests/megaatmega2560-tests | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 14a50cb06f26..c218d1358b65 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -33,7 +33,7 @@ #include "neopixel.h" #endif -#define HAS_WHITE_LED EITHER(RGBW_LED, NEOPIXEL_LED) +#define HAS_WHITE_LED (ENABLED(RGBW_LED) || (ENABLED(NEOPIXEL_LED) && !NEOPIXEL_IS_RGB)) && DISABLED(RGB_LED) /** * LEDcolor type for use with leds.set_color diff --git a/Marlin/src/feature/leds/printer_event_leds.h b/Marlin/src/feature/leds/printer_event_leds.h index f59d6c699c19..07ad653fd0f3 100644 --- a/Marlin/src/feature/leds/printer_event_leds.h +++ b/Marlin/src/feature/leds/printer_event_leds.h @@ -56,7 +56,7 @@ class PrinterEventLEDs { #endif #if HAS_TEMP_HOTEND || HAS_HEATED_BED - static inline void onHeatingDone() { leds.set_color(LEDColorWhite()); } + static inline void onHeatingDone() { leds.set_white(); } static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); } #endif diff --git a/buildroot/share/tests/megaatmega2560-tests b/buildroot/share/tests/megaatmega2560-tests index b34da5752df3..039e023e314b 100755 --- a/buildroot/share/tests/megaatmega2560-tests +++ b/buildroot/share/tests/megaatmega2560-tests @@ -31,7 +31,8 @@ opt_set GRID_MAX_POINTS_X 16 opt_set FANMUX0_PIN 53 opt_disable USE_WATCHDOG opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \ - PIDTEMPBED FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING \ + FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING PIDTEMPBED \ + PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \ EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \ BLINKM PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ NEOPIXEL_LED CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \ @@ -44,7 +45,7 @@ opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TE BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ PSU_CONTROL AUTO_POWER_CONTROL POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE \ - SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE \ + SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE \ HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL exec_test $1 $2 "RAMPS | EXTRUDERS 2 | CHAR LCD + SD | FIX Probe | ABL-Linear | Advanced Pause | PLR | LEDs ..."