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.

language_ru.h 8.1KB

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