|
@@ -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
|