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_tramming.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. //
  23. // Bed Tramming Wizard
  24. //
  25. #include "../../inc/MarlinConfigPre.h"
  26. #if BOTH(HAS_LCD_MENU, ASSISTED_TRAMMING_WIZARD)
  27. #include "menu_item.h"
  28. #include "../../feature/tramming.h"
  29. #include "../../module/motion.h"
  30. #include "../../module/probe.h"
  31. #include "../../gcode/queue.h"
  32. //#define DEBUG_OUT 1
  33. #include "../../core/debug_out.h"
  34. float z_measured[G35_PROBE_COUNT] = { 0 };
  35. static uint8_t tram_index = 0;
  36. #if HAS_LEVELING
  37. #include "../../feature/bedlevel/bedlevel.h"
  38. #endif
  39. static bool probe_single_point() {
  40. do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES));
  41. // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety
  42. const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[tram_index], TERN(BLTOUCH_HS_MODE, PROBE_PT_STOW, PROBE_PT_RAISE), 0, true);
  43. DEBUG_ECHOLNPAIR("probe_single_point: ", z_probed_height, "mm");
  44. z_measured[tram_index] = z_probed_height;
  45. move_to_tramming_wait_pos();
  46. return !ISNAN(z_probed_height);
  47. }
  48. static void _menu_single_probe(const uint8_t point) {
  49. tram_index = point;
  50. DEBUG_ECHOLNPAIR("Screen: single probe screen Arg:", point);
  51. START_MENU();
  52. STATIC_ITEM(MSG_LEVEL_CORNERS, SS_LEFT);
  53. STATIC_ITEM(MSG_LAST_VALUE_SP, SS_LEFT, ftostr42_52(z_measured[0] - z_measured[point])); // Print diff
  54. ACTION_ITEM(MSG_UBL_BC_INSERT2, []{ if (probe_single_point()) ui.refresh(); });
  55. ACTION_ITEM(MSG_BUTTON_DONE, []{ ui.goto_previous_screen(); }); // Back
  56. END_MENU();
  57. }
  58. static void tramming_wizard_menu() {
  59. DEBUG_ECHOLNPAIR("Screen: tramming_wizard_menu");
  60. START_MENU();
  61. STATIC_ITEM(MSG_SELECT_ORIGIN);
  62. // Draw a menu item for each tramming point
  63. LOOP_L_N(i, G35_PROBE_COUNT)
  64. SUBMENU_N_P(i, (char*)pgm_read_ptr(&tramming_point_name[i]), []{ _menu_single_probe(MenuItemBase::itemIndex); });
  65. ACTION_ITEM(MSG_BUTTON_DONE, []{
  66. probe.stow(); // Stow before exiting Tramming Wizard
  67. ui.goto_previous_screen_no_defer();
  68. });
  69. END_MENU();
  70. }
  71. // Init the wizard and enter the submenu
  72. void goto_tramming_wizard() {
  73. DEBUG_ECHOLNPAIR("Screen: goto_tramming_wizard", 1);
  74. tram_index = 0;
  75. ui.defer_status_screen();
  76. // Inject G28, wait for homing to complete,
  77. set_all_unhomed();
  78. queue.inject_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
  79. ui.goto_screen([]{
  80. _lcd_draw_homing();
  81. if (all_axes_homed())
  82. ui.goto_screen(tramming_wizard_menu);
  83. });
  84. }
  85. #endif // HAS_LCD_MENU && ASSISTED_TRAMMING_WIZARD