|
@@ -0,0 +1,606 @@
|
|
1
|
+/**
|
|
2
|
+ * Marlin 3D Printer Firmware
|
|
3
|
+ * Copyright (C) 2016 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
|
+// Unified Bed Leveling Menus
|
|
25
|
+//
|
|
26
|
+
|
|
27
|
+#include "../../inc/MarlinConfigPre.h"
|
|
28
|
+
|
|
29
|
+#if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
|
|
30
|
+
|
|
31
|
+#include "menu.h"
|
|
32
|
+#include "../../module/planner.h"
|
|
33
|
+#include "../../module/configuration_store.h"
|
|
34
|
+#include "../../feature/bedlevel/bedlevel.h"
|
|
35
|
+
|
|
36
|
+static int16_t ubl_storage_slot = 0,
|
|
37
|
+ custom_hotend_temp = 190,
|
|
38
|
+ side_points = 3,
|
|
39
|
+ ubl_fillin_amount = 5,
|
|
40
|
+ ubl_height_amount = 1,
|
|
41
|
+ n_edit_pts = 1,
|
|
42
|
+ x_plot = 0,
|
|
43
|
+ y_plot = 0;
|
|
44
|
+
|
|
45
|
+#if HAS_HEATED_BED
|
|
46
|
+ static int16_t custom_bed_temp = 50;
|
|
47
|
+#endif
|
|
48
|
+
|
|
49
|
+float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5 decimal places. So we keep a
|
|
50
|
+ // separate value that doesn't lose precision.
|
|
51
|
+static int16_t ubl_encoderPosition = 0;
|
|
52
|
+
|
|
53
|
+static void _lcd_mesh_fine_tune(PGM_P msg) {
|
|
54
|
+ defer_return_to_status = true;
|
|
55
|
+ if (ubl.encoder_diff) {
|
|
56
|
+ ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1;
|
|
57
|
+ ubl.encoder_diff = 0;
|
|
58
|
+
|
|
59
|
+ mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005f * 0.5f;
|
|
60
|
+ mesh_edit_value = mesh_edit_accumulator;
|
|
61
|
+ encoderPosition = 0;
|
|
62
|
+ lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
|
|
63
|
+
|
|
64
|
+ const int32_t rounded = (int32_t)(mesh_edit_value * 1000);
|
|
65
|
+ mesh_edit_value = float(rounded - (rounded % 5L)) / 1000;
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ if (lcdDrawUpdate) {
|
|
69
|
+ lcd_implementation_drawedit(msg, ftostr43sign(mesh_edit_value));
|
|
70
|
+ #if ENABLED(MESH_EDIT_GFX_OVERLAY)
|
|
71
|
+ _lcd_zoffset_overlay_gfx(mesh_edit_value);
|
|
72
|
+ #endif
|
|
73
|
+ }
|
|
74
|
+}
|
|
75
|
+
|
|
76
|
+void _lcd_mesh_edit_NOP() {
|
|
77
|
+ defer_return_to_status = true;
|
|
78
|
+}
|
|
79
|
+
|
|
80
|
+float lcd_mesh_edit() {
|
|
81
|
+ lcd_goto_screen(_lcd_mesh_edit_NOP);
|
|
82
|
+ lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
|
|
83
|
+ _lcd_mesh_fine_tune(PSTR("Mesh Editor"));
|
|
84
|
+ return mesh_edit_value;
|
|
85
|
+}
|
|
86
|
+
|
|
87
|
+void lcd_mesh_edit_setup(const float &initial) {
|
|
88
|
+ mesh_edit_value = mesh_edit_accumulator = initial;
|
|
89
|
+ lcd_goto_screen(_lcd_mesh_edit_NOP);
|
|
90
|
+}
|
|
91
|
+
|
|
92
|
+void _lcd_z_offset_edit() {
|
|
93
|
+ _lcd_mesh_fine_tune(PSTR("Z-Offset: "));
|
|
94
|
+}
|
|
95
|
+
|
|
96
|
+float lcd_z_offset_edit() {
|
|
97
|
+ lcd_goto_screen(_lcd_z_offset_edit);
|
|
98
|
+ return mesh_edit_value;
|
|
99
|
+}
|
|
100
|
+
|
|
101
|
+void lcd_z_offset_edit_setup(const float &initial) {
|
|
102
|
+ mesh_edit_value = mesh_edit_accumulator = initial;
|
|
103
|
+ lcd_goto_screen(_lcd_z_offset_edit);
|
|
104
|
+}
|
|
105
|
+
|
|
106
|
+/**
|
|
107
|
+ * UBL Build Custom Mesh Command
|
|
108
|
+ */
|
|
109
|
+void _lcd_ubl_build_custom_mesh() {
|
|
110
|
+ char UBL_LCD_GCODE[20];
|
|
111
|
+ enqueue_and_echo_commands_P(PSTR("G28"));
|
|
112
|
+ #if HAS_HEATED_BED
|
|
113
|
+ sprintf_P(UBL_LCD_GCODE, PSTR("M190 S%i"), custom_bed_temp);
|
|
114
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
115
|
+ #endif
|
|
116
|
+ sprintf_P(UBL_LCD_GCODE, PSTR("M109 S%i"), custom_hotend_temp);
|
|
117
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
118
|
+ enqueue_and_echo_commands_P(PSTR("G29 P1"));
|
|
119
|
+}
|
|
120
|
+
|
|
121
|
+/**
|
|
122
|
+ * UBL Custom Mesh submenu
|
|
123
|
+ *
|
|
124
|
+ * << Build Mesh
|
|
125
|
+ * Hotend Temp: ---
|
|
126
|
+ * Bed Temp: ---
|
|
127
|
+ * Build Custom Mesh
|
|
128
|
+ */
|
|
129
|
+void _lcd_ubl_custom_mesh() {
|
|
130
|
+ START_MENU();
|
|
131
|
+ MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
|
|
132
|
+ MENU_ITEM_EDIT(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP - 10));
|
|
133
|
+ #if HAS_HEATED_BED
|
|
134
|
+ MENU_ITEM_EDIT(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP, (BED_MAXTEMP - 15));
|
|
135
|
+ #endif
|
|
136
|
+ MENU_ITEM(function, MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_build_custom_mesh);
|
|
137
|
+ END_MENU();
|
|
138
|
+}
|
|
139
|
+
|
|
140
|
+/**
|
|
141
|
+ * UBL Adjust Mesh Height Command
|
|
142
|
+ */
|
|
143
|
+void _lcd_ubl_adjust_height_cmd() {
|
|
144
|
+ char UBL_LCD_GCODE[16];
|
|
145
|
+ const int ind = ubl_height_amount > 0 ? 9 : 10;
|
|
146
|
+ strcpy_P(UBL_LCD_GCODE, PSTR("G29 P6 C -"));
|
|
147
|
+ sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), ABS(ubl_height_amount));
|
|
148
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
149
|
+}
|
|
150
|
+
|
|
151
|
+/**
|
|
152
|
+ * UBL Adjust Mesh Height submenu
|
|
153
|
+ *
|
|
154
|
+ * << Edit Mesh
|
|
155
|
+ * Height Amount: ---
|
|
156
|
+ * Adjust Mesh Height
|
|
157
|
+ * << Info Screen
|
|
158
|
+ */
|
|
159
|
+void _menu_ubl_height_adjust() {
|
|
160
|
+ START_MENU();
|
|
161
|
+ MENU_BACK(MSG_UBL_EDIT_MESH_MENU);
|
|
162
|
+ MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_MESH_HEIGHT_AMOUNT, &ubl_height_amount, -9, 9, _lcd_ubl_adjust_height_cmd);
|
|
163
|
+ MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
|
|
164
|
+ END_MENU();
|
|
165
|
+}
|
|
166
|
+
|
|
167
|
+/**
|
|
168
|
+ * UBL Edit Mesh submenu
|
|
169
|
+ *
|
|
170
|
+ * << UBL Tools
|
|
171
|
+ * Fine Tune All
|
|
172
|
+ * Fine Tune Closest
|
|
173
|
+ * - Adjust Mesh Height >>
|
|
174
|
+ * << Info Screen
|
|
175
|
+ */
|
|
176
|
+void _lcd_ubl_edit_mesh() {
|
|
177
|
+ START_MENU();
|
|
178
|
+ MENU_BACK(MSG_UBL_TOOLS);
|
|
179
|
+ MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
|
|
180
|
+ MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
|
|
181
|
+ MENU_ITEM(submenu, MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
|
|
182
|
+ MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
|
|
183
|
+ END_MENU();
|
|
184
|
+}
|
|
185
|
+
|
|
186
|
+/**
|
|
187
|
+ * UBL Validate Custom Mesh Command
|
|
188
|
+ */
|
|
189
|
+void _lcd_ubl_validate_custom_mesh() {
|
|
190
|
+ char UBL_LCD_GCODE[24];
|
|
191
|
+ const int temp =
|
|
192
|
+ #if HAS_HEATED_BED
|
|
193
|
+ custom_bed_temp
|
|
194
|
+ #else
|
|
195
|
+ 0
|
|
196
|
+ #endif
|
|
197
|
+ ;
|
|
198
|
+ sprintf_P(UBL_LCD_GCODE, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
|
|
199
|
+ lcd_enqueue_commands_P(PSTR("G28"));
|
|
200
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
201
|
+}
|
|
202
|
+
|
|
203
|
+/**
|
|
204
|
+ * UBL Validate Mesh submenu
|
|
205
|
+ *
|
|
206
|
+ * << UBL Tools
|
|
207
|
+ * Mesh Validation with Material 1
|
|
208
|
+ * Mesh Validation with Material 2
|
|
209
|
+ * Validate Custom Mesh
|
|
210
|
+ * << Info Screen
|
|
211
|
+ */
|
|
212
|
+void _lcd_ubl_validate_mesh() {
|
|
213
|
+ START_MENU();
|
|
214
|
+ MENU_BACK(MSG_UBL_TOOLS);
|
|
215
|
+ #if HAS_HEATED_BED
|
|
216
|
+ MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_1_TEMP_BED) " H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
|
|
217
|
+ MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_2_TEMP_BED) " H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
|
|
218
|
+ #else
|
|
219
|
+ MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
|
|
220
|
+ MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
|
|
221
|
+ #endif
|
|
222
|
+ MENU_ITEM(function, MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
|
|
223
|
+ MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
|
|
224
|
+ END_MENU();
|
|
225
|
+}
|
|
226
|
+
|
|
227
|
+/**
|
|
228
|
+ * UBL Grid Leveling Command
|
|
229
|
+ */
|
|
230
|
+void _lcd_ubl_grid_level_cmd() {
|
|
231
|
+ char UBL_LCD_GCODE[10];
|
|
232
|
+ sprintf_P(UBL_LCD_GCODE, PSTR("G29 J%i"), side_points);
|
|
233
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
234
|
+}
|
|
235
|
+
|
|
236
|
+/**
|
|
237
|
+ * UBL Grid Leveling submenu
|
|
238
|
+ *
|
|
239
|
+ * << UBL Tools
|
|
240
|
+ * Side points: ---
|
|
241
|
+ * Level Mesh
|
|
242
|
+ */
|
|
243
|
+void _lcd_ubl_grid_level() {
|
|
244
|
+ START_MENU();
|
|
245
|
+ MENU_BACK(MSG_UBL_TOOLS);
|
|
246
|
+ MENU_ITEM_EDIT(int3, MSG_UBL_SIDE_POINTS, &side_points, 2, 6);
|
|
247
|
+ MENU_ITEM(function, MSG_UBL_MESH_LEVEL, _lcd_ubl_grid_level_cmd);
|
|
248
|
+ END_MENU();
|
|
249
|
+}
|
|
250
|
+
|
|
251
|
+/**
|
|
252
|
+ * UBL Mesh Leveling submenu
|
|
253
|
+ *
|
|
254
|
+ * << UBL Tools
|
|
255
|
+ * 3-Point Mesh Leveling
|
|
256
|
+ * - Grid Mesh Leveling >>
|
|
257
|
+ * << Info Screen
|
|
258
|
+ */
|
|
259
|
+void _lcd_ubl_mesh_leveling() {
|
|
260
|
+ START_MENU();
|
|
261
|
+ MENU_BACK(MSG_UBL_TOOLS);
|
|
262
|
+ MENU_ITEM(gcode, MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
|
|
263
|
+ MENU_ITEM(submenu, MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
|
|
264
|
+ MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
|
|
265
|
+ END_MENU();
|
|
266
|
+}
|
|
267
|
+
|
|
268
|
+/**
|
|
269
|
+ * UBL Fill-in Amount Mesh Command
|
|
270
|
+ */
|
|
271
|
+void _lcd_ubl_fillin_amount_cmd() {
|
|
272
|
+ char UBL_LCD_GCODE[16];
|
|
273
|
+ sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
|
|
274
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
275
|
+}
|
|
276
|
+
|
|
277
|
+/**
|
|
278
|
+ * UBL Fill-in Mesh submenu
|
|
279
|
+ *
|
|
280
|
+ * << Build Mesh
|
|
281
|
+ * Fill-in Amount: ---
|
|
282
|
+ * Fill-in Mesh
|
|
283
|
+ * Smart Fill-in
|
|
284
|
+ * Manual Fill-in
|
|
285
|
+ * << Info Screen
|
|
286
|
+ */
|
|
287
|
+void _menu_ubl_fillin() {
|
|
288
|
+ START_MENU();
|
|
289
|
+ MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
|
|
290
|
+ MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
|
|
291
|
+ MENU_ITEM(gcode, MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
|
|
292
|
+ MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
|
|
293
|
+ MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
|
|
294
|
+ END_MENU();
|
|
295
|
+}
|
|
296
|
+
|
|
297
|
+void _lcd_ubl_invalidate() {
|
|
298
|
+ ubl.invalidate();
|
|
299
|
+ SERIAL_PROTOCOLLNPGM("Mesh invalidated.");
|
|
300
|
+}
|
|
301
|
+
|
|
302
|
+/**
|
|
303
|
+ * UBL Build Mesh submenu
|
|
304
|
+ *
|
|
305
|
+ * << UBL Tools
|
|
306
|
+ * Build Mesh with Material 1
|
|
307
|
+ * Build Mesh with Material 2
|
|
308
|
+ * - Build Custom Mesh >>
|
|
309
|
+ * Build Cold Mesh
|
|
310
|
+ * - Fill-in Mesh >>
|
|
311
|
+ * Continue Bed Mesh
|
|
312
|
+ * Invalidate All
|
|
313
|
+ * Invalidate Closest
|
|
314
|
+ * << Info Screen
|
|
315
|
+ */
|
|
316
|
+void _lcd_ubl_build_mesh() {
|
|
317
|
+ START_MENU();
|
|
318
|
+ MENU_BACK(MSG_UBL_TOOLS);
|
|
319
|
+ #if HAS_HEATED_BED
|
|
320
|
+ MENU_ITEM(gcode, MSG_UBL_BUILD_MESH_M1, PSTR(
|
|
321
|
+ "G28\n"
|
|
322
|
+ "M190 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\n"
|
|
323
|
+ "M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
|
|
324
|
+ "G29 P1\n"
|
|
325
|
+ "M104 S0\n"
|
|
326
|
+ "M140 S0"
|
|
327
|
+ ));
|
|
328
|
+ MENU_ITEM(gcode, MSG_UBL_BUILD_MESH_M2, PSTR(
|
|
329
|
+ "G28\n"
|
|
330
|
+ "M190 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\n"
|
|
331
|
+ "M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
|
|
332
|
+ "G29 P1\n"
|
|
333
|
+ "M104 S0\n"
|
|
334
|
+ "M140 S0"
|
|
335
|
+ ));
|
|
336
|
+ #else
|
|
337
|
+ MENU_ITEM(gcode, MSG_UBL_BUILD_MESH_M1, PSTR(
|
|
338
|
+ "G28\n"
|
|
339
|
+ "M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
|
|
340
|
+ "G29 P1\n"
|
|
341
|
+ "M104 S0"
|
|
342
|
+ ));
|
|
343
|
+ MENU_ITEM(gcode, MSG_UBL_BUILD_MESH_M2, PSTR(
|
|
344
|
+ "G28\n"
|
|
345
|
+ "M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
|
|
346
|
+ "G29 P1\n"
|
|
347
|
+ "M104 S0"
|
|
348
|
+ ));
|
|
349
|
+ #endif
|
|
350
|
+ MENU_ITEM(submenu, MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh);
|
|
351
|
+ MENU_ITEM(gcode, MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
|
|
352
|
+ MENU_ITEM(submenu, MSG_UBL_FILLIN_MESH, _menu_ubl_fillin);
|
|
353
|
+ MENU_ITEM(gcode, MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
|
|
354
|
+ MENU_ITEM(function, MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
|
|
355
|
+ MENU_ITEM(gcode, MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
|
|
356
|
+ MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
|
|
357
|
+ END_MENU();
|
|
358
|
+}
|
|
359
|
+
|
|
360
|
+/**
|
|
361
|
+ * UBL Load Mesh Command
|
|
362
|
+ */
|
|
363
|
+void _lcd_ubl_load_mesh_cmd() {
|
|
364
|
+ char UBL_LCD_GCODE[25];
|
|
365
|
+ sprintf_P(UBL_LCD_GCODE, PSTR("G29 L%i"), ubl_storage_slot);
|
|
366
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
367
|
+ sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_LOADED), ubl_storage_slot);
|
|
368
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
369
|
+}
|
|
370
|
+
|
|
371
|
+/**
|
|
372
|
+ * UBL Save Mesh Command
|
|
373
|
+ */
|
|
374
|
+void _lcd_ubl_save_mesh_cmd() {
|
|
375
|
+ char UBL_LCD_GCODE[25];
|
|
376
|
+ sprintf_P(UBL_LCD_GCODE, PSTR("G29 S%i"), ubl_storage_slot);
|
|
377
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
378
|
+ sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_SAVED), ubl_storage_slot);
|
|
379
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
380
|
+}
|
|
381
|
+
|
|
382
|
+/**
|
|
383
|
+ * UBL Mesh Storage submenu
|
|
384
|
+ *
|
|
385
|
+ * << Unified Bed Leveling
|
|
386
|
+ * Memory Slot: ---
|
|
387
|
+ * Load Bed Mesh
|
|
388
|
+ * Save Bed Mesh
|
|
389
|
+ */
|
|
390
|
+void _lcd_ubl_storage_mesh() {
|
|
391
|
+ int16_t a = settings.calc_num_meshes();
|
|
392
|
+ START_MENU();
|
|
393
|
+ MENU_BACK(MSG_UBL_LEVEL_BED);
|
|
394
|
+ if (!WITHIN(ubl_storage_slot, 0, a - 1)) {
|
|
395
|
+ STATIC_ITEM(MSG_NO_STORAGE);
|
|
396
|
+ }
|
|
397
|
+ else {
|
|
398
|
+ MENU_ITEM_EDIT(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, a - 1);
|
|
399
|
+ MENU_ITEM(function, MSG_UBL_LOAD_MESH, _lcd_ubl_load_mesh_cmd);
|
|
400
|
+ MENU_ITEM(function, MSG_UBL_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
|
|
401
|
+ }
|
|
402
|
+ END_MENU();
|
|
403
|
+}
|
|
404
|
+
|
|
405
|
+/**
|
|
406
|
+ * UBL LCD "radar" map homing
|
|
407
|
+ */
|
|
408
|
+void _lcd_ubl_output_map_lcd();
|
|
409
|
+
|
|
410
|
+void _lcd_ubl_map_homing() {
|
|
411
|
+ defer_return_to_status = true;
|
|
412
|
+ _lcd_draw_homing();
|
|
413
|
+ if (all_axes_homed()) {
|
|
414
|
+ ubl.lcd_map_control = true; // Return to the map screen
|
|
415
|
+ lcd_goto_screen(_lcd_ubl_output_map_lcd);
|
|
416
|
+ }
|
|
417
|
+}
|
|
418
|
+
|
|
419
|
+/**
|
|
420
|
+ * UBL LCD "radar" map point editing
|
|
421
|
+ */
|
|
422
|
+void _lcd_ubl_map_lcd_edit_cmd() {
|
|
423
|
+ char UBL_LCD_GCODE[50], str[10], str2[10];
|
|
424
|
+ dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str);
|
|
425
|
+ dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2);
|
|
426
|
+ snprintf_P(UBL_LCD_GCODE, sizeof(UBL_LCD_GCODE), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts);
|
|
427
|
+ lcd_enqueue_command(UBL_LCD_GCODE);
|
|
428
|
+}
|
|
429
|
+
|
|
430
|
+/**
|
|
431
|
+ * UBL LCD Map Movement
|
|
432
|
+ */
|
|
433
|
+void ubl_map_move_to_xy() {
|
|
434
|
+ current_position[X_AXIS] = pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]);
|
|
435
|
+ current_position[Y_AXIS] = pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]);
|
|
436
|
+ planner.buffer_line(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
|
|
437
|
+}
|
|
438
|
+
|
|
439
|
+/**
|
|
440
|
+ * UBL LCD "radar" map
|
|
441
|
+ */
|
|
442
|
+void set_current_from_steppers_for_axis(const AxisEnum axis);
|
|
443
|
+void sync_plan_position();
|
|
444
|
+
|
|
445
|
+void _lcd_do_nothing() {}
|
|
446
|
+void _lcd_hard_stop() {
|
|
447
|
+ const screenFunc_t old_screen = currentScreen;
|
|
448
|
+ currentScreen = _lcd_do_nothing;
|
|
449
|
+ planner.quick_stop();
|
|
450
|
+ currentScreen = old_screen;
|
|
451
|
+ set_current_from_steppers_for_axis(ALL_AXES);
|
|
452
|
+ sync_plan_position();
|
|
453
|
+}
|
|
454
|
+
|
|
455
|
+void _lcd_ubl_output_map_lcd() {
|
|
456
|
+ static int16_t step_scaler = 0;
|
|
457
|
+
|
|
458
|
+ if (use_click()) return _lcd_ubl_map_lcd_edit_cmd();
|
|
459
|
+ ENCODER_DIRECTION_NORMAL();
|
|
460
|
+
|
|
461
|
+ if (encoderPosition) {
|
|
462
|
+ step_scaler += (int32_t)encoderPosition;
|
|
463
|
+ x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
|
|
464
|
+ if (ABS(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) step_scaler = 0;
|
|
465
|
+ encoderPosition = 0;
|
|
466
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
|
467
|
+ }
|
|
468
|
+
|
|
469
|
+ // Encoder to the right (++)
|
|
470
|
+ if (x_plot >= GRID_MAX_POINTS_X) { x_plot = 0; y_plot++; }
|
|
471
|
+ if (y_plot >= GRID_MAX_POINTS_Y) y_plot = 0;
|
|
472
|
+
|
|
473
|
+ // Encoder to the left (--)
|
|
474
|
+ if (x_plot <= GRID_MAX_POINTS_X - (GRID_MAX_POINTS_X + 1)) { x_plot = GRID_MAX_POINTS_X - 1; y_plot--; }
|
|
475
|
+ if (y_plot <= GRID_MAX_POINTS_Y - (GRID_MAX_POINTS_Y + 1)) y_plot = GRID_MAX_POINTS_Y - 1;
|
|
476
|
+
|
|
477
|
+ // Prevent underrun/overrun of plot numbers
|
|
478
|
+ x_plot = constrain(x_plot, GRID_MAX_POINTS_X - (GRID_MAX_POINTS_X + 1), GRID_MAX_POINTS_X + 1);
|
|
479
|
+ y_plot = constrain(y_plot, GRID_MAX_POINTS_Y - (GRID_MAX_POINTS_Y + 1), GRID_MAX_POINTS_Y + 1);
|
|
480
|
+
|
|
481
|
+ // Determine number of points to edit
|
|
482
|
+ #if IS_KINEMATIC
|
|
483
|
+ n_edit_pts = 9; //TODO: Delta accessible edit points
|
|
484
|
+ #else
|
|
485
|
+ const bool xc = WITHIN(x_plot, 1, GRID_MAX_POINTS_X - 2),
|
|
486
|
+ yc = WITHIN(y_plot, 1, GRID_MAX_POINTS_Y - 2);
|
|
487
|
+ n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
|
|
488
|
+ #endif
|
|
489
|
+
|
|
490
|
+ if (lcdDrawUpdate) {
|
|
491
|
+ lcd_implementation_ubl_plot(x_plot, y_plot);
|
|
492
|
+
|
|
493
|
+ if (planner.movesplanned()) // If the nozzle is already moving, cancel the move.
|
|
494
|
+ _lcd_hard_stop();
|
|
495
|
+
|
|
496
|
+ ubl_map_move_to_xy(); // Move to new location
|
|
497
|
+ }
|
|
498
|
+}
|
|
499
|
+
|
|
500
|
+/**
|
|
501
|
+ * UBL Homing before LCD map
|
|
502
|
+ */
|
|
503
|
+void _lcd_ubl_output_map_lcd_cmd() {
|
|
504
|
+ if (!all_axes_known()) {
|
|
505
|
+ axis_homed = 0;
|
|
506
|
+ enqueue_and_echo_commands_P(PSTR("G28"));
|
|
507
|
+ }
|
|
508
|
+ lcd_goto_screen(_lcd_ubl_map_homing);
|
|
509
|
+}
|
|
510
|
+
|
|
511
|
+/**
|
|
512
|
+ * UBL Output map submenu
|
|
513
|
+ *
|
|
514
|
+ * << Unified Bed Leveling
|
|
515
|
+ * Output for Host
|
|
516
|
+ * Output for CSV
|
|
517
|
+ * Off Printer Backup
|
|
518
|
+ * Output Mesh Map
|
|
519
|
+ */
|
|
520
|
+void _lcd_ubl_output_map() {
|
|
521
|
+ START_MENU();
|
|
522
|
+ MENU_BACK(MSG_UBL_LEVEL_BED);
|
|
523
|
+ MENU_ITEM(gcode, MSG_UBL_OUTPUT_MAP_HOST, PSTR("G29 T0"));
|
|
524
|
+ MENU_ITEM(gcode, MSG_UBL_OUTPUT_MAP_CSV, PSTR("G29 T1"));
|
|
525
|
+ MENU_ITEM(gcode, MSG_UBL_OUTPUT_MAP_BACKUP, PSTR("G29 S-1"));
|
|
526
|
+ MENU_ITEM(function, MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map_lcd_cmd);
|
|
527
|
+ END_MENU();
|
|
528
|
+}
|
|
529
|
+
|
|
530
|
+/**
|
|
531
|
+ * UBL Tools submenu
|
|
532
|
+ *
|
|
533
|
+ * << Unified Bed Leveling
|
|
534
|
+ * - Build Mesh >>
|
|
535
|
+ * - Validate Mesh >>
|
|
536
|
+ * - Edit Mesh >>
|
|
537
|
+ * - Mesh Leveling >>
|
|
538
|
+ */
|
|
539
|
+void _menu_ubl_tools() {
|
|
540
|
+ START_MENU();
|
|
541
|
+ MENU_BACK(MSG_UBL_LEVEL_BED);
|
|
542
|
+ MENU_ITEM(submenu, MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh);
|
|
543
|
+ MENU_ITEM(gcode, MSG_UBL_MANUAL_MESH, PSTR("G29 I999\nG29 P2 B T0"));
|
|
544
|
+ MENU_ITEM(submenu, MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
|
|
545
|
+ MENU_ITEM(submenu, MSG_UBL_EDIT_MESH_MENU, _lcd_ubl_edit_mesh);
|
|
546
|
+ MENU_ITEM(submenu, MSG_UBL_MESH_LEVELING, _lcd_ubl_mesh_leveling);
|
|
547
|
+ END_MENU();
|
|
548
|
+}
|
|
549
|
+
|
|
550
|
+/**
|
|
551
|
+ * UBL Step-By-Step submenu
|
|
552
|
+ *
|
|
553
|
+ * << Unified Bed Leveling
|
|
554
|
+ * 1 Build Cold Mesh
|
|
555
|
+ * 2 Smart Fill-in
|
|
556
|
+ * - 3 Validate Mesh >>
|
|
557
|
+ * 4 Fine Tune All
|
|
558
|
+ * - 5 Validate Mesh >>
|
|
559
|
+ * 6 Fine Tune All
|
|
560
|
+ * 7 Save Bed Mesh
|
|
561
|
+ */
|
|
562
|
+void _lcd_ubl_step_by_step() {
|
|
563
|
+ START_MENU();
|
|
564
|
+ MENU_BACK(MSG_UBL_LEVEL_BED);
|
|
565
|
+ MENU_ITEM(gcode, "1 " MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
|
|
566
|
+ MENU_ITEM(gcode, "2 " MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
|
|
567
|
+ MENU_ITEM(submenu, "3 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
|
|
568
|
+ MENU_ITEM(gcode, "4 " MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
|
|
569
|
+ MENU_ITEM(submenu, "5 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
|
|
570
|
+ MENU_ITEM(gcode, "6 " MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
|
|
571
|
+ MENU_ITEM(function, "7 " MSG_UBL_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
|
|
572
|
+ END_MENU();
|
|
573
|
+}
|
|
574
|
+
|
|
575
|
+/**
|
|
576
|
+ * UBL System submenu
|
|
577
|
+ *
|
|
578
|
+ * << Motion
|
|
579
|
+ * - Manually Build Mesh >>
|
|
580
|
+ * - Activate UBL >>
|
|
581
|
+ * - Deactivate UBL >>
|
|
582
|
+ * - Step-By-Step UBL >>
|
|
583
|
+ * - Mesh Storage >>
|
|
584
|
+ * - Output Map >>
|
|
585
|
+ * - UBL Tools >>
|
|
586
|
+ * - Output UBL Info >>
|
|
587
|
+ */
|
|
588
|
+
|
|
589
|
+void _lcd_ubl_level_bed() {
|
|
590
|
+ START_MENU();
|
|
591
|
+ MENU_BACK(MSG_MOTION);
|
|
592
|
+ MENU_ITEM(gcode, MSG_UBL_ACTIVATE_MESH, PSTR("G29 A"));
|
|
593
|
+ MENU_ITEM(gcode, MSG_UBL_DEACTIVATE_MESH, PSTR("G29 D"));
|
|
594
|
+ MENU_ITEM(submenu, MSG_UBL_STEP_BY_STEP_MENU, _lcd_ubl_step_by_step);
|
|
595
|
+ MENU_ITEM(function, MSG_UBL_MESH_EDIT, _lcd_ubl_output_map_lcd_cmd);
|
|
596
|
+ MENU_ITEM(submenu, MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh);
|
|
597
|
+ MENU_ITEM(submenu, MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map);
|
|
598
|
+ MENU_ITEM(submenu, MSG_UBL_TOOLS, _menu_ubl_tools);
|
|
599
|
+ MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W"));
|
|
600
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
601
|
+ MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &lcd_z_fade_height, 0, 100, _lcd_set_z_fade_height);
|
|
602
|
+ #endif
|
|
603
|
+ END_MENU();
|
|
604
|
+}
|
|
605
|
+
|
|
606
|
+#endif // HAS_LCD_MENU && AUTO_BED_LEVELING_UBL
|