My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

menu_ubl.cpp 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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. // Unified Bed Leveling Menus
  24. //
  25. #include "../../inc/MarlinConfigPre.h"
  26. #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL)
  27. #include "menu.h"
  28. #include "../../gcode/gcode.h"
  29. #include "../../gcode/queue.h"
  30. #include "../../module/motion.h"
  31. #include "../../module/planner.h"
  32. #include "../../module/configuration_store.h"
  33. #include "../../feature/bedlevel/bedlevel.h"
  34. static int16_t ubl_storage_slot = 0,
  35. custom_hotend_temp = 190,
  36. side_points = 3,
  37. ubl_fillin_amount = 5,
  38. ubl_height_amount = 1;
  39. static uint8_t n_edit_pts = 1;
  40. static int8_t x_plot = 0, y_plot = 0; // May be negative during move
  41. #if HAS_HEATED_BED
  42. static int16_t custom_bed_temp = 50;
  43. #endif
  44. float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5 decimal places. So we keep a
  45. // separate value that doesn't lose precision.
  46. static int16_t ubl_encoderPosition = 0;
  47. static void _lcd_mesh_fine_tune(PGM_P const msg) {
  48. ui.defer_status_screen();
  49. if (ubl.encoder_diff) {
  50. ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1;
  51. ubl.encoder_diff = 0;
  52. mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005f * 0.5f;
  53. mesh_edit_value = mesh_edit_accumulator;
  54. ui.encoderPosition = 0;
  55. ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
  56. const int32_t rounded = (int32_t)(mesh_edit_value * 1000);
  57. mesh_edit_value = float(rounded - (rounded % 5L)) / 1000;
  58. }
  59. if (ui.should_draw()) {
  60. MenuEditItemBase::draw_edit_screen(msg, ftostr43sign(mesh_edit_value));
  61. TERN_(MESH_EDIT_GFX_OVERLAY, _lcd_zoffset_overlay_gfx(mesh_edit_value));
  62. }
  63. }
  64. void lcd_limbo() {
  65. ui.currentScreen = []{};
  66. ui.defer_status_screen();
  67. }
  68. float lcd_mesh_edit() {
  69. lcd_limbo();
  70. ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
  71. _lcd_mesh_fine_tune(GET_TEXT(MSG_MESH_EDITOR));
  72. return mesh_edit_value;
  73. }
  74. void lcd_mesh_edit_setup(const float &initial) {
  75. mesh_edit_value = mesh_edit_accumulator = initial;
  76. lcd_limbo();
  77. }
  78. void _lcd_z_offset_edit() {
  79. _lcd_mesh_fine_tune(GET_TEXT(MSG_UBL_Z_OFFSET));
  80. }
  81. float lcd_z_offset_edit() {
  82. ui.goto_screen(_lcd_z_offset_edit);
  83. return mesh_edit_value;
  84. }
  85. void lcd_z_offset_edit_setup(const float &initial) {
  86. mesh_edit_value = mesh_edit_accumulator = initial;
  87. ui.goto_screen(_lcd_z_offset_edit);
  88. }
  89. /**
  90. * UBL Build Custom Mesh Command
  91. */
  92. void _lcd_ubl_build_custom_mesh() {
  93. char ubl_lcd_gcode[64];
  94. #if HAS_HEATED_BED
  95. sprintf_P(ubl_lcd_gcode, PSTR("G28\nM190 S%i\nM109 S%i\nG29 P1"), custom_bed_temp, custom_hotend_temp);
  96. #else
  97. sprintf_P(ubl_lcd_gcode, PSTR("G28\nM109 S%i\nG29 P1"), custom_hotend_temp);
  98. #endif
  99. queue.inject(ubl_lcd_gcode);
  100. }
  101. /**
  102. * UBL Custom Mesh submenu
  103. *
  104. * << Build Mesh
  105. * Hotend Temp: ---
  106. * Bed Temp: ---
  107. * Build Custom Mesh
  108. */
  109. void _lcd_ubl_custom_mesh() {
  110. START_MENU();
  111. BACK_ITEM(MSG_UBL_BUILD_MESH_MENU);
  112. #if HAS_HOTEND
  113. EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT);
  114. #endif
  115. #if HAS_HEATED_BED
  116. EDIT_ITEM(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP, BED_MAX_TARGET);
  117. #endif
  118. ACTION_ITEM(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_build_custom_mesh);
  119. END_MENU();
  120. }
  121. /**
  122. * UBL Adjust Mesh Height Command
  123. */
  124. void _lcd_ubl_adjust_height_cmd() {
  125. char ubl_lcd_gcode[16];
  126. const int ind = ubl_height_amount > 0 ? 9 : 10;
  127. strcpy_P(ubl_lcd_gcode, PSTR("G29 P6 C -"));
  128. sprintf_P(&ubl_lcd_gcode[ind], PSTR(".%i"), ABS(ubl_height_amount));
  129. queue.inject(ubl_lcd_gcode);
  130. }
  131. /**
  132. * UBL Adjust Mesh Height submenu
  133. *
  134. * << Edit Mesh
  135. * Height Amount: ---
  136. * Adjust Mesh Height
  137. * << Info Screen
  138. */
  139. void _menu_ubl_height_adjust() {
  140. START_MENU();
  141. BACK_ITEM(MSG_EDIT_MESH);
  142. EDIT_ITEM(int3, MSG_UBL_MESH_HEIGHT_AMOUNT, &ubl_height_amount, -9, 9, _lcd_ubl_adjust_height_cmd);
  143. ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
  144. END_MENU();
  145. }
  146. /**
  147. * UBL Edit Mesh submenu
  148. *
  149. * << UBL Tools
  150. * Fine Tune All
  151. * Fine Tune Closest
  152. * - Adjust Mesh Height >>
  153. * << Info Screen
  154. */
  155. void _lcd_ubl_edit_mesh() {
  156. START_MENU();
  157. BACK_ITEM(MSG_UBL_TOOLS);
  158. GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
  159. GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
  160. SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
  161. ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
  162. END_MENU();
  163. }
  164. #if ENABLED(G26_MESH_VALIDATION)
  165. /**
  166. * UBL Validate Custom Mesh Command
  167. */
  168. void _lcd_ubl_validate_custom_mesh() {
  169. char ubl_lcd_gcode[24];
  170. const int16_t temp = TERN(HAS_HEATED_BED, custom_bed_temp, 0);
  171. sprintf_P(ubl_lcd_gcode, PSTR("G28\nG26 C P H%" PRIi16 TERN_(HAS_HEATED_BED, " B%" PRIi16))
  172. , custom_hotend_temp
  173. #if HAS_HEATED_BED
  174. , temp
  175. #endif
  176. );
  177. queue.inject(ubl_lcd_gcode);
  178. }
  179. /**
  180. * UBL Validate Mesh submenu
  181. *
  182. * << UBL Tools
  183. * Mesh Validation with Material 1
  184. * Mesh Validation with Material 2
  185. * Validate Custom Mesh
  186. * << Info Screen
  187. */
  188. void _lcd_ubl_validate_mesh() {
  189. START_MENU();
  190. BACK_ITEM(MSG_UBL_TOOLS);
  191. #if HAS_HEATED_BED
  192. GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_1_TEMP_BED) " H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
  193. GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_2_TEMP_BED) " H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
  194. #else
  195. GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
  196. GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
  197. #endif
  198. ACTION_ITEM(MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
  199. ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
  200. END_MENU();
  201. }
  202. #endif
  203. /**
  204. * UBL Grid Leveling submenu
  205. *
  206. * << UBL Tools
  207. * Side points: ---
  208. * Level Mesh
  209. */
  210. void _lcd_ubl_grid_level() {
  211. START_MENU();
  212. BACK_ITEM(MSG_UBL_TOOLS);
  213. EDIT_ITEM(int3, MSG_UBL_SIDE_POINTS, &side_points, 2, 6);
  214. ACTION_ITEM(MSG_UBL_MESH_LEVEL, []{
  215. char ubl_lcd_gcode[12];
  216. sprintf_P(ubl_lcd_gcode, PSTR("G29 J%i"), side_points);
  217. queue.inject(ubl_lcd_gcode);
  218. });
  219. END_MENU();
  220. }
  221. /**
  222. * UBL Mesh Leveling submenu
  223. *
  224. * << UBL Tools
  225. * 3-Point Mesh Leveling
  226. * - Grid Mesh Leveling >>
  227. * << Info Screen
  228. */
  229. void _lcd_ubl_mesh_leveling() {
  230. START_MENU();
  231. BACK_ITEM(MSG_UBL_TOOLS);
  232. GCODES_ITEM(MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
  233. SUBMENU(MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
  234. ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
  235. END_MENU();
  236. }
  237. /**
  238. * UBL Fill-in Amount Mesh Command
  239. */
  240. void _lcd_ubl_fillin_amount_cmd() {
  241. char ubl_lcd_gcode[18];
  242. sprintf_P(ubl_lcd_gcode, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
  243. gcode.process_subcommands_now(ubl_lcd_gcode);
  244. }
  245. /**
  246. * UBL Fill-in Mesh submenu
  247. *
  248. * << Build Mesh
  249. * Fill-in Amount: ---
  250. * Fill-in Mesh
  251. * Smart Fill-in
  252. * Manual Fill-in
  253. * << Info Screen
  254. */
  255. void _menu_ubl_fillin() {
  256. START_MENU();
  257. BACK_ITEM(MSG_UBL_BUILD_MESH_MENU);
  258. EDIT_ITEM(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
  259. GCODES_ITEM(MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
  260. GCODES_ITEM(MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
  261. ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
  262. END_MENU();
  263. }
  264. void _lcd_ubl_invalidate() {
  265. ubl.invalidate();
  266. SERIAL_ECHOLNPGM("Mesh invalidated.");
  267. }
  268. /**
  269. * UBL Build Mesh submenu
  270. *
  271. * << UBL Tools
  272. * Build Mesh with Material 1
  273. * Build Mesh with Material 2
  274. * - Build Custom Mesh >>
  275. * Build Cold Mesh
  276. * - Fill-in Mesh >>
  277. * Continue Bed Mesh
  278. * Invalidate All
  279. * Invalidate Closest
  280. * << Info Screen
  281. */
  282. void _lcd_ubl_build_mesh() {
  283. START_MENU();
  284. BACK_ITEM(MSG_UBL_TOOLS);
  285. #if HAS_HEATED_BED
  286. GCODES_ITEM(MSG_UBL_BUILD_MESH_M1, PSTR(
  287. "G28\n"
  288. "M190 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\n"
  289. "M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
  290. "G29 P1\n"
  291. "M104 S0\n"
  292. "M140 S0"
  293. ));
  294. GCODES_ITEM(MSG_UBL_BUILD_MESH_M2, PSTR(
  295. "G28\n"
  296. "M190 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\n"
  297. "M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
  298. "G29 P1\n"
  299. "M104 S0\n"
  300. "M140 S0"
  301. ));
  302. #else
  303. GCODES_ITEM(MSG_UBL_BUILD_MESH_M1, PSTR(
  304. "G28\n"
  305. "M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
  306. "G29 P1\n"
  307. "M104 S0"
  308. ));
  309. GCODES_ITEM(MSG_UBL_BUILD_MESH_M2, PSTR(
  310. "G28\n"
  311. "M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
  312. "G29 P1\n"
  313. "M104 S0"
  314. ));
  315. #endif
  316. SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh);
  317. GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
  318. SUBMENU(MSG_UBL_FILLIN_MESH, _menu_ubl_fillin);
  319. GCODES_ITEM(MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
  320. ACTION_ITEM(MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
  321. GCODES_ITEM(MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
  322. ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
  323. END_MENU();
  324. }
  325. /**
  326. * UBL Load / Save Mesh Commands
  327. */
  328. inline void _lcd_ubl_load_save_cmd(const char loadsave, PGM_P const msg) {
  329. char ubl_lcd_gcode[40];
  330. sprintf_P(ubl_lcd_gcode, PSTR("G29 %c%i\nM117 "), loadsave, ubl_storage_slot);
  331. sprintf_P(&ubl_lcd_gcode[strlen(ubl_lcd_gcode)], msg, ubl_storage_slot);
  332. gcode.process_subcommands_now(ubl_lcd_gcode);
  333. }
  334. void _lcd_ubl_load_mesh_cmd() { _lcd_ubl_load_save_cmd('L', GET_TEXT(MSG_MESH_LOADED)); }
  335. void _lcd_ubl_save_mesh_cmd() { _lcd_ubl_load_save_cmd('S', GET_TEXT(MSG_MESH_SAVED)); }
  336. /**
  337. * UBL Mesh Storage submenu
  338. *
  339. * << Unified Bed Leveling
  340. * Memory Slot: ---
  341. * Load Bed Mesh
  342. * Save Bed Mesh
  343. */
  344. void _lcd_ubl_storage_mesh() {
  345. int16_t a = settings.calc_num_meshes();
  346. START_MENU();
  347. BACK_ITEM(MSG_UBL_LEVEL_BED);
  348. if (!WITHIN(ubl_storage_slot, 0, a - 1))
  349. STATIC_ITEM(MSG_UBL_NO_STORAGE);
  350. else {
  351. EDIT_ITEM(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, a - 1);
  352. ACTION_ITEM(MSG_UBL_LOAD_MESH, _lcd_ubl_load_mesh_cmd);
  353. ACTION_ITEM(MSG_UBL_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
  354. }
  355. END_MENU();
  356. }
  357. /**
  358. * UBL LCD "radar" map homing
  359. */
  360. void _lcd_ubl_output_map_lcd();
  361. void _lcd_ubl_map_homing() {
  362. ui.defer_status_screen();
  363. _lcd_draw_homing();
  364. if (all_axes_homed()) {
  365. ubl.lcd_map_control = true; // Return to the map screen
  366. ui.goto_screen(_lcd_ubl_output_map_lcd);
  367. }
  368. }
  369. /**
  370. * UBL LCD "radar" map point editing
  371. */
  372. void _lcd_ubl_map_lcd_edit_cmd() {
  373. char ubl_lcd_gcode[50], str[10], str2[10];
  374. dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str);
  375. dtostrf(ubl.mesh_index_to_ypos(y_plot), 0, 2, str2);
  376. snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, int(n_edit_pts));
  377. queue.inject(ubl_lcd_gcode);
  378. }
  379. /**
  380. * UBL LCD Map Movement
  381. */
  382. void ubl_map_move_to_xy() {
  383. const feedRate_t fr_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
  384. destination = current_position; // sync destination at the start
  385. #if ENABLED(DELTA)
  386. if (current_position.z > delta_clip_start_height) {
  387. destination.z = delta_clip_start_height;
  388. prepare_internal_move_to_destination(fr_mm_s);
  389. }
  390. #endif
  391. destination.set(ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot));
  392. prepare_internal_move_to_destination(fr_mm_s);
  393. }
  394. /**
  395. * UBL LCD "radar" map
  396. */
  397. void _lcd_ubl_output_map_lcd() {
  398. static int16_t step_scaler = 0;
  399. if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
  400. if (ui.encoderPosition) {
  401. step_scaler += int32_t(ui.encoderPosition);
  402. x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
  403. ui.encoderPosition = 0;
  404. ui.refresh(LCDVIEW_REDRAW_NOW);
  405. }
  406. #define KEEP_LOOPING ENABLED(IS_KINEMATIC) // Loop until a valid point is found
  407. do {
  408. // Encoder to the right (++)
  409. if (x_plot >= GRID_MAX_POINTS_X) { x_plot = 0; y_plot++; }
  410. if (y_plot >= GRID_MAX_POINTS_Y) y_plot = 0;
  411. // Encoder to the left (--)
  412. if (x_plot < 0) { x_plot = GRID_MAX_POINTS_X - 1; y_plot--; }
  413. if (y_plot < 0) y_plot = GRID_MAX_POINTS_Y - 1;
  414. #if IS_KINEMATIC
  415. const xy_pos_t xy = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) };
  416. if (position_is_reachable(xy)) break; // Found a valid point
  417. x_plot += (step_scaler < 0) ? -1 : 1;
  418. #endif
  419. } while(KEEP_LOOPING);
  420. // Determine number of points to edit
  421. #if IS_KINEMATIC
  422. n_edit_pts = 9; //TODO: Delta accessible edit points
  423. #else
  424. const bool xc = WITHIN(x_plot, 1, GRID_MAX_POINTS_X - 2),
  425. yc = WITHIN(y_plot, 1, GRID_MAX_POINTS_Y - 2);
  426. n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
  427. #endif
  428. // Cleanup
  429. if (ABS(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) step_scaler = 0;
  430. if (ui.should_draw()) {
  431. ui.ubl_plot(x_plot, y_plot);
  432. if (!planner.movesplanned())
  433. ubl_map_move_to_xy(); // Move to new location
  434. }
  435. }
  436. /**
  437. * UBL Homing before LCD map
  438. */
  439. void _lcd_ubl_output_map_lcd_cmd() {
  440. if (!all_axes_known()) {
  441. set_all_unhomed();
  442. queue.inject_P(G28_STR);
  443. }
  444. if (planner.movesplanned()) return;
  445. ui.goto_screen(_lcd_ubl_map_homing);
  446. }
  447. /**
  448. * UBL Output map submenu
  449. *
  450. * << Unified Bed Leveling
  451. * Output for Host
  452. * Output for CSV
  453. * Off Printer Backup
  454. */
  455. void _lcd_ubl_output_map() {
  456. START_MENU();
  457. BACK_ITEM(MSG_UBL_LEVEL_BED);
  458. GCODES_ITEM(MSG_UBL_OUTPUT_MAP_HOST, PSTR("G29 T0"));
  459. GCODES_ITEM(MSG_UBL_OUTPUT_MAP_CSV, PSTR("G29 T1"));
  460. GCODES_ITEM(MSG_UBL_OUTPUT_MAP_BACKUP, PSTR("G29 S-1"));
  461. END_MENU();
  462. }
  463. /**
  464. * UBL Tools submenu
  465. *
  466. * << Unified Bed Leveling
  467. * - Build Mesh >>
  468. * - Validate Mesh >>
  469. * - Edit Mesh >>
  470. * - Mesh Leveling >>
  471. */
  472. void _menu_ubl_tools() {
  473. START_MENU();
  474. BACK_ITEM(MSG_UBL_LEVEL_BED);
  475. SUBMENU(MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh);
  476. GCODES_ITEM(MSG_UBL_MANUAL_MESH, PSTR("G29 I999\nG29 P2 B T0"));
  477. #if ENABLED(G26_MESH_VALIDATION)
  478. SUBMENU(MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
  479. #endif
  480. SUBMENU(MSG_EDIT_MESH, _lcd_ubl_edit_mesh);
  481. SUBMENU(MSG_UBL_MESH_LEVELING, _lcd_ubl_mesh_leveling);
  482. END_MENU();
  483. }
  484. #if ENABLED(G26_MESH_VALIDATION)
  485. /**
  486. * UBL Step-By-Step submenu
  487. *
  488. * << Unified Bed Leveling
  489. * 1 Build Cold Mesh
  490. * 2 Smart Fill-in
  491. * - 3 Validate Mesh >>
  492. * 4 Fine Tune All
  493. * - 5 Validate Mesh >>
  494. * 6 Fine Tune All
  495. * 7 Save Bed Mesh
  496. */
  497. void _lcd_ubl_step_by_step() {
  498. START_MENU();
  499. BACK_ITEM(MSG_UBL_LEVEL_BED);
  500. GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
  501. GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29 P3 T0"));
  502. SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
  503. GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
  504. SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
  505. GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
  506. ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
  507. END_MENU();
  508. }
  509. #endif
  510. /**
  511. * UBL System submenu
  512. *
  513. * << Motion
  514. * - Manually Build Mesh >>
  515. * - Activate UBL >>
  516. * - Deactivate UBL >>
  517. * - Step-By-Step UBL >>
  518. * - Mesh Storage >>
  519. * - Output Map >>
  520. * - UBL Tools >>
  521. * - Output UBL Info >>
  522. */
  523. void _lcd_ubl_level_bed() {
  524. START_MENU();
  525. BACK_ITEM(MSG_MOTION);
  526. if (planner.leveling_active)
  527. GCODES_ITEM(MSG_UBL_DEACTIVATE_MESH, PSTR("G29 D"));
  528. else
  529. GCODES_ITEM(MSG_UBL_ACTIVATE_MESH, PSTR("G29 A"));
  530. #if ENABLED(G26_MESH_VALIDATION)
  531. SUBMENU(MSG_UBL_STEP_BY_STEP_MENU, _lcd_ubl_step_by_step);
  532. #endif
  533. ACTION_ITEM(MSG_UBL_MESH_EDIT, _lcd_ubl_output_map_lcd_cmd);
  534. SUBMENU(MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh);
  535. SUBMENU(MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map);
  536. SUBMENU(MSG_UBL_TOOLS, _menu_ubl_tools);
  537. GCODES_ITEM(MSG_UBL_INFO_UBL, PSTR("G29 W"));
  538. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  539. editable.decimal = planner.z_fade_height;
  540. EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); });
  541. #endif
  542. END_MENU();
  543. }
  544. #endif // HAS_LCD_MENU && AUTO_BED_LEVELING_UBL