瀏覽代碼

Z Probe Offset Wizard (#18866)

Mathew Winters 4 年之前
父節點
當前提交
343441d746
No account linked to committer's email address

+ 8
- 0
Marlin/Configuration_adv.h 查看文件

@@ -1048,6 +1048,14 @@
1048 1048
 
1049 1049
 #if HAS_LCD_MENU
1050 1050
 
1051
+  // Add Probe Z Offset calibration to the Bed Leveling menu
1052
+  #if HAS_BED_PROBE
1053
+    //#define PROBE_OFFSET_WIZARD
1054
+    #if ENABLED(PROBE_OFFSET_WIZARD)
1055
+      #define PROBE_OFFSET_START -4.0   // Estimated nozzle-to-probe Z offset, plus a little extra
1056
+    #endif
1057
+  #endif
1058
+
1051 1059
   // Include a page of printer information in the LCD Main Menu
1052 1060
   //#define LCD_INFO_MENU
1053 1061
   #if ENABLED(LCD_INFO_MENU)

+ 3
- 0
Marlin/src/lcd/language/language_en.h 查看文件

@@ -445,6 +445,7 @@ namespace Language_en {
445 445
   PROGMEM Language_Str MSG_ZPROBE_XOFFSET                  = _UxGT("Probe X Offset");
446 446
   PROGMEM Language_Str MSG_ZPROBE_YOFFSET                  = _UxGT("Probe Y Offset");
447 447
   PROGMEM Language_Str MSG_ZPROBE_ZOFFSET                  = _UxGT("Probe Z Offset");
448
+  PROGMEM Language_Str MSG_MOVE_NOZZLE_TO_BED              = _UxGT("Move Nozzle to Bed");
448 449
   PROGMEM Language_Str MSG_BABYSTEP_X                      = _UxGT("Babystep X");
449 450
   PROGMEM Language_Str MSG_BABYSTEP_Y                      = _UxGT("Babystep Y");
450 451
   PROGMEM Language_Str MSG_BABYSTEP_Z                      = _UxGT("Babystep Z");
@@ -653,6 +654,8 @@ namespace Language_en {
653 654
   #endif
654 655
   PROGMEM Language_Str MSG_REHEAT                          = _UxGT("Reheat");
655 656
   PROGMEM Language_Str MSG_REHEATING                       = _UxGT("Reheating...");
657
+
658
+  PROGMEM Language_Str MSG_PROBE_WIZARD                    = _UxGT("Z Probe Wizard");
656 659
 }
657 660
 
658 661
 #if FAN_COUNT == 1

+ 4
- 0
Marlin/src/lcd/menu/menu.h 查看文件

@@ -219,6 +219,10 @@ void _lcd_draw_homing();
219 219
   void _lcd_zoffset_overlay_gfx(const float zvalue);
220 220
 #endif
221 221
 
222
+#if ENABLED(PROBE_OFFSET_WIZARD)
223
+  void goto_probe_offset_wizard();
224
+#endif
225
+
222 226
 #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
223 227
   void _lcd_toggle_bed_leveling();
224 228
 #endif

+ 4
- 0
Marlin/src/lcd/menu/menu_bed_leveling.cpp 查看文件

@@ -283,6 +283,10 @@ void menu_bed_leveling() {
283 283
     EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
284 284
   #endif
285 285
 
286
+  #if ENABLED(PROBE_OFFSET_WIZARD)
287
+    SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard);
288
+  #endif
289
+
286 290
   #if ENABLED(LEVEL_BED_CORNERS)
287 291
     SUBMENU(MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
288 292
   #endif

+ 142
- 0
Marlin/src/lcd/menu/menu_probe_offset.cpp 查看文件

@@ -0,0 +1,142 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+//
24
+// Calibrate Probe offset menu.
25
+//
26
+
27
+#include "../../inc/MarlinConfigPre.h"
28
+
29
+#if ENABLED(PROBE_OFFSET_WIZARD)
30
+
31
+#ifndef PROBE_OFFSET_START
32
+  #error "PROBE_OFFSET_WIZARD requires a PROBE_OFFSET_START with a negative value."
33
+#else
34
+  static_assert(PROBE_OFFSET_START < 0, "PROBE_OFFSET_START must be < 0. Please update your configuration.");
35
+#endif
36
+
37
+#include "menu_item.h"
38
+#include "menu_addon.h"
39
+#include "../../module/motion.h"
40
+#include "../../module/planner.h"
41
+#include "../../module/probe.h"
42
+
43
+#if HAS_LEVELING
44
+  #include "../../feature/bedlevel/bedlevel.h"
45
+#endif
46
+
47
+// Global storage
48
+float z_offset_backup, calculated_z_offset;
49
+
50
+TERN_(HAS_LEVELING, bool leveling_was_active);
51
+TERN_(HAS_SOFTWARE_ENDSTOPS, bool store_soft_endstops_enabled);
52
+
53
+void prepare_for_calibration() {
54
+  z_offset_backup = probe.offset.z;
55
+
56
+  // Disable soft endstops for free Z movement
57
+  #if HAS_SOFTWARE_ENDSTOPS
58
+    store_soft_endstops_enabled = soft_endstops_enabled;
59
+    soft_endstops_enabled = false;
60
+  #endif
61
+
62
+  // Disable leveling for raw planner motion
63
+  #if HAS_LEVELING
64
+    leveling_was_active = planner.leveling_active;
65
+    set_bed_leveling_enabled(false);
66
+  #endif
67
+}
68
+
69
+void set_offset_and_go_back(const float &z) {
70
+  probe.offset.z = z;
71
+  TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = store_soft_endstops_enabled);
72
+  TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active));
73
+  ui.goto_previous_screen_no_defer();
74
+}
75
+
76
+void _goto_manual_move_z(const float scale) {
77
+  ui.manual_move.menu_scale = scale;
78
+  ui.goto_screen(lcd_move_z);
79
+}
80
+
81
+void probe_offset_wizard_menu() {
82
+  START_MENU();
83
+  calculated_z_offset = probe.offset.z + current_position.z;
84
+
85
+  if (LCD_HEIGHT >= 4)
86
+    STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT);
87
+
88
+  STATIC_ITEM_P(PSTR("Z="), SS_CENTER, ftostr42_52(current_position.z));
89
+  STATIC_ITEM(MSG_ZPROBE_ZOFFSET, SS_LEFT, ftostr42_52(calculated_z_offset));
90
+
91
+  SUBMENU(MSG_MOVE_1MM,  []{ _goto_manual_move_z( 1);    });
92
+  SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move_z( 0.1f); });
93
+
94
+  if ((SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) {
95
+    extern const char NUL_STR[];
96
+    SUBMENU_P(NUL_STR, []{ _goto_manual_move_z(float(SHORT_MANUAL_Z_MOVE)); });
97
+    MENU_ITEM_ADDON_START(0 + ENABLED(HAS_CHARACTER_LCD));
98
+      char tmp[20], numstr[10];
99
+      // Determine digits needed right of decimal
100
+      const uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
101
+                           !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) *  100 - int((SHORT_MANUAL_Z_MOVE) *  100)) ? 3 : 2;
102
+      sprintf_P(tmp, GET_TEXT(MSG_MOVE_Z_DIST), dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
103
+      lcd_put_u8str(tmp);
104
+    MENU_ITEM_ADDON_END();
105
+  }
106
+
107
+  ACTION_ITEM(MSG_BUTTON_DONE, []{
108
+    set_offset_and_go_back(calculated_z_offset);
109
+    do_z_clearance(20.0
110
+      #ifdef Z_AFTER_HOMING
111
+        - 20.0 + Z_AFTER_HOMING
112
+      #endif
113
+    );
114
+  });
115
+
116
+  ACTION_ITEM(MSG_BUTTON_CANCEL, []{
117
+    set_offset_and_go_back(z_offset_backup);
118
+  });
119
+
120
+  END_MENU();
121
+}
122
+
123
+void goto_probe_offset_wizard() {
124
+  ui.defer_status_screen();
125
+
126
+  prepare_for_calibration();
127
+
128
+  probe.offset.z = PROBE_OFFSET_START;
129
+
130
+  set_all_unhomed();
131
+  queue.inject_P(G28_STR);
132
+
133
+  ui.goto_screen([]{
134
+    _lcd_draw_homing();
135
+    if (all_axes_homed()) {
136
+      ui.goto_screen(probe_offset_wizard_menu);
137
+      ui.defer_status_screen();
138
+    }
139
+  });
140
+}
141
+
142
+#endif // PROBE_OFFSET_WIZARD

+ 1
- 1
buildroot/tests/mega2560-tests 查看文件

@@ -139,7 +139,7 @@ opt_enable COREYX USE_XMAX_PLUG MIXING_EXTRUDER GRADIENT_MIX \
139 139
            BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY \
140 140
            REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER MENU_ADDAUTOSTART SDSUPPORT SDCARD_SORT_ALPHA \
141 141
            ENDSTOP_NOISE_THRESHOLD FAN_SOFT_PWM \
142
-           FIX_MOUNTED_PROBE AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE FILAMENT_WIDTH_SENSOR \
142
+           FIX_MOUNTED_PROBE AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE FILAMENT_WIDTH_SENSOR PROBE_OFFSET_WIZARD \
143 143
            Z_SAFE_HOMING SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER \
144 144
            SD_ABORT_ON_ENDSTOP_HIT HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT ADVANCED_OK M114_DETAIL \
145 145
            VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS EXTRA_FAN_SPEED FWRETRACT \

Loading…
取消
儲存