My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

menu_ubl.cpp 17KB

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