From 7ef03a761bc528f5bb8bfac01178bd45d7e89e77 Mon Sep 17 00:00:00 2001 From: qwewer0 <57561110+qwewer0@users.noreply.github.com> Date: Sat, 2 Jan 2021 09:33:31 +0100 Subject: [PATCH] Assisted Tramming improvements (#20298) --- Marlin/Configuration_adv.h | 4 +- Marlin/src/feature/tramming.cpp | 63 +++++++++++++++++++++++++++ Marlin/src/feature/tramming.h | 9 +++- Marlin/src/gcode/bedlevel/G35.cpp | 27 ++---------- Marlin/src/inc/SanityCheck.h | 2 + Marlin/src/lcd/menu/menu_motion.cpp | 2 - Marlin/src/lcd/menu/menu_tramming.cpp | 15 ++----- buildroot/tests/DUE-tests | 3 +- platformio.ini | 3 +- 9 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 Marlin/src/feature/tramming.cpp diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 0a64764cae..0a51c795dc 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -813,8 +813,8 @@ #define RESTORE_LEVELING_AFTER_G35 // Enable to restore leveling setup after operation //#define REPORT_TRAMMING_MM // Report Z deviation (mm) for each point relative to the first - //#define ASSISTED_TRAMMING_MENU_ITEM // Add a menu item to run G35 Assisted Tramming (MarlinUI) - //#define ASSISTED_TRAMMING_WIZARD // Make the menu item open a Tramming Wizard sub-menu + //#define ASSISTED_TRAMMING_WIZARD // Add a Tramming Wizard to the LCD menu + //#define ASSISTED_TRAMMING_WAIT_POSITION { X_CENTER, Y_CENTER, 30 } // Move the nozzle out of the way for adjustment /** diff --git a/Marlin/src/feature/tramming.cpp b/Marlin/src/feature/tramming.cpp new file mode 100644 index 0000000000..b04995f40a --- /dev/null +++ b/Marlin/src/feature/tramming.cpp @@ -0,0 +1,63 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ + +#include "../inc/MarlinConfigPre.h" + +#if ENABLED(ASSISTED_TRAMMING) + +#include "tramming.h" + +#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) +#include "../core/debug_out.h" + +PGMSTR(point_name_1, TRAMMING_POINT_NAME_1); +PGMSTR(point_name_2, TRAMMING_POINT_NAME_2); +PGMSTR(point_name_3, TRAMMING_POINT_NAME_3); +#ifdef TRAMMING_POINT_NAME_4 + PGMSTR(point_name_4, TRAMMING_POINT_NAME_4); + #ifdef TRAMMING_POINT_NAME_5 + PGMSTR(point_name_5, TRAMMING_POINT_NAME_5); + #endif +#endif + +PGM_P const tramming_point_name[] PROGMEM = { + point_name_1, point_name_2, point_name_3 + #ifdef TRAMMING_POINT_NAME_4 + , point_name_4 + #ifdef TRAMMING_POINT_NAME_5 + , point_name_5 + #endif + #endif +}; + +#ifdef ASSISTED_TRAMMING_WAIT_POSITION + + // Move to the defined wait position + void move_to_tramming_wait_pos() { + constexpr xyz_pos_t wait_pos = ASSISTED_TRAMMING_WAIT_POSITION; + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Moving away"); + do_blocking_move_to(wait_pos, XY_PROBE_FEEDRATE_MM_S); + } + +#endif + +#endif // ASSISTED_TRAMMING diff --git a/Marlin/src/feature/tramming.h b/Marlin/src/feature/tramming.h index e97fb2fde6..57b677ae30 100644 --- a/Marlin/src/feature/tramming.h +++ b/Marlin/src/feature/tramming.h @@ -19,8 +19,9 @@ * along with this program. If not, see . * */ +#pragma once -#include "../inc/MarlinConfigPre.h" +#include "../inc/MarlinConfig.h" #include "../module/probe.h" #if !WITHIN(TRAMMING_SCREW_THREAD, 30, 51) || TRAMMING_SCREW_THREAD % 10 > 1 @@ -62,3 +63,9 @@ static_assert(_NR_TRAM_NAMES >= G35_PROBE_COUNT, "Define enough TRAMMING_POINT_N #undef _NR_TRAM_NAMES extern PGM_P const tramming_point_name[]; + +#ifdef ASSISTED_TRAMMING_WAIT_POSITION + void move_to_tramming_wait_pos(); +#else + inline void move_to_tramming_wait_pos() {} +#endif diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 789d8bcf19..46f75f2590 100755 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -40,27 +40,7 @@ // Define tramming point names. // -#include "../../feature/tramming.h" // Validate - -PGMSTR(point_name_1, TRAMMING_POINT_NAME_1); -PGMSTR(point_name_2, TRAMMING_POINT_NAME_2); -PGMSTR(point_name_3, TRAMMING_POINT_NAME_3); -#ifdef TRAMMING_POINT_NAME_4 - PGMSTR(point_name_4, TRAMMING_POINT_NAME_4); - #ifdef TRAMMING_POINT_NAME_5 - PGMSTR(point_name_5, TRAMMING_POINT_NAME_5); - #endif -#endif - -PGM_P const tramming_point_name[] PROGMEM = { - point_name_1, point_name_2, point_name_3 - #ifdef TRAMMING_POINT_NAME_4 - , point_name_4 - #ifdef TRAMMING_POINT_NAME_5 - , point_name_5 - #endif - #endif -}; +#include "../../feature/tramming.h" /** * G35: Read bed corners to help adjust bed screws @@ -178,11 +158,10 @@ void GcodeSuite::G35() { // the probe deployed if it was successful. probe.stow(); + move_to_tramming_wait_pos(); + // After this operation the Z position needs correction set_axis_never_homed(Z_AXIS); - - // Home Z after the alignment procedure - process_subcommands_now_P(PSTR("G28Z")); } #endif // ASSISTED_TRAMMING diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index de5960df4c..7ebb9168f6 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -541,6 +541,8 @@ #else #error "FIL_RUNOUT_INVERTING false is now FIL_RUNOUT_STATE LOW." #endif +#elif defined(ASSISTED_TRAMMING_MENU_ITEM) + #error "ASSISTED_TRAMMING_MENU_ITEM is deprecated and should be removed." #endif /** diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 627d8565ed..f849d20eca 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -365,8 +365,6 @@ void menu_motion() { // #if ENABLED(ASSISTED_TRAMMING_WIZARD) SUBMENU(MSG_TRAMMING_WIZARD, goto_tramming_wizard); - #elif ENABLED(ASSISTED_TRAMMING_MENU_ITEM) - GCODES_ITEM(MSG_ASSISTED_TRAMMING, PSTR("G35")); #endif // diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index e51cd0a318..a77709e108 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -42,24 +42,18 @@ float z_measured[G35_PROBE_COUNT] = { 0 }; static uint8_t tram_index = 0; -bool probe_single_point() { +static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[tram_index], TERN(BLTOUCH_HS_MODE, PROBE_PT_STOW, PROBE_PT_RAISE), 0, true); DEBUG_ECHOLNPAIR("probe_single_point: ", z_probed_height, "mm"); z_measured[tram_index] = z_probed_height; - - #ifdef ASSISTED_TRAMMING_WAIT_POSITION - // Move XY to safe position - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Moving away"); - const xyz_pos_t wait_pos = ASSISTED_TRAMMING_WAIT_POSITION; - do_blocking_move_to(wait_pos, XY_PROBE_FEEDRATE_MM_S); - #endif + move_to_tramming_wait_pos(); return !isnan(z_probed_height); } -void _menu_single_probe(const uint8_t point) { +static void _menu_single_probe(const uint8_t point) { tram_index = point; DEBUG_ECHOLNPAIR("Screen: single probe screen Arg:", point); START_MENU(); @@ -70,7 +64,7 @@ void _menu_single_probe(const uint8_t point) { END_MENU(); } -void tramming_wizard_menu() { +static void tramming_wizard_menu() { DEBUG_ECHOLNPAIR("Screen: tramming_wizard_menu"); START_MENU(); STATIC_ITEM(MSG_SELECT_ORIGIN); @@ -91,7 +85,6 @@ void goto_tramming_wizard() { DEBUG_ECHOLNPAIR("Screen: goto_tramming_wizard", 1); tram_index = 0; ui.defer_status_screen(); - //probe_single_point(); // Probe first point to get differences // Inject G28, wait for homing to complete, set_all_unhomed(); diff --git a/buildroot/tests/DUE-tests b/buildroot/tests/DUE-tests index 009688ce21..d4c49a3185 100755 --- a/buildroot/tests/DUE-tests +++ b/buildroot/tests/DUE-tests @@ -14,7 +14,8 @@ opt_set TEMP_SENSOR_BED 2 opt_set GRID_MAX_POINTS_X 16 opt_set FANMUX0_PIN 53 opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ - FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD \ + FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING \ + ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \ EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \ BLINKM PCA9533 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 \ diff --git a/platformio.ini b/platformio.ini index 3e87968eef..daeaee4021 100644 --- a/platformio.ini +++ b/platformio.ini @@ -106,6 +106,7 @@ default_src_filter = + - - + - - - - - - + - - - - @@ -323,7 +324,7 @@ MECHANICAL_GANTRY_CAL.+ = src_filter=+ Z_MULTI_ENDSTOPS = src_filter=+ Z_STEPPER_AUTO_ALIGN = src_filter=+ + G26_MESH_VALIDATION = src_filter=+ -ASSISTED_TRAMMING = src_filter=+ +ASSISTED_TRAMMING = src_filter=+ + HAS_MESH = src_filter=+ HAS_LEVELING = src_filter=+ DELTA_AUTO_CALIBRATION = src_filter=+