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

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