My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

menu_tramming.cpp 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_MARLINUI_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. #if ENABLED(BLTOUCH)
  33. #include "../../feature/bltouch.h"
  34. #endif
  35. //#define DEBUG_OUT 1
  36. #include "../../core/debug_out.h"
  37. static float z_measured[G35_PROBE_COUNT];
  38. static bool z_isvalid[G35_PROBE_COUNT];
  39. static uint8_t tram_index = 0;
  40. static int8_t reference_index; // = 0
  41. #if HAS_LEVELING
  42. #include "../../feature/bedlevel/bedlevel.h"
  43. #endif
  44. static bool probe_single_point() {
  45. do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES));
  46. // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety
  47. const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN0(BLTOUCH, bltouch.high_speed_mode) ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true);
  48. z_measured[tram_index] = z_probed_height;
  49. if (reference_index < 0) reference_index = tram_index;
  50. move_to_tramming_wait_pos();
  51. DEBUG_ECHOLNPGM("probe_single_point(", tram_index, ") = ", z_probed_height, "mm");
  52. return (z_isvalid[tram_index] = !isnan(z_probed_height));
  53. }
  54. static void _menu_single_probe() {
  55. DEBUG_ECHOLNPGM("Screen: single probe screen Arg:", tram_index);
  56. START_MENU();
  57. STATIC_ITEM(MSG_BED_TRAMMING, SS_LEFT);
  58. STATIC_ITEM(MSG_LAST_VALUE_SP, SS_LEFT, z_isvalid[tram_index] ? ftostr42_52(z_measured[reference_index] - z_measured[tram_index]) : "---");
  59. ACTION_ITEM(MSG_UBL_BC_INSERT2, []{ if (probe_single_point()) ui.refresh(); });
  60. ACTION_ITEM(MSG_BUTTON_DONE, ui.goto_previous_screen);
  61. END_MENU();
  62. }
  63. static void tramming_wizard_menu() {
  64. START_MENU();
  65. STATIC_ITEM(MSG_SELECT_ORIGIN);
  66. // Draw a menu item for each tramming point
  67. for (tram_index = 0; tram_index < G35_PROBE_COUNT; tram_index++)
  68. SUBMENU_P((char*)pgm_read_ptr(&tramming_point_name[tram_index]), _menu_single_probe);
  69. ACTION_ITEM(MSG_BUTTON_DONE, []{
  70. probe.stow(); // Stow before exiting Tramming Wizard
  71. ui.goto_previous_screen_no_defer();
  72. });
  73. END_MENU();
  74. }
  75. // Init the wizard and enter the submenu
  76. void goto_tramming_wizard() {
  77. DEBUG_ECHOLNPGM("Screen: goto_tramming_wizard", 1);
  78. ui.defer_status_screen();
  79. // Initialize measured point flags
  80. ZERO(z_isvalid);
  81. reference_index = -1;
  82. // Inject G28, wait for homing to complete,
  83. set_all_unhomed();
  84. queue.inject(TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR)));
  85. ui.goto_screen([]{
  86. _lcd_draw_homing();
  87. if (all_axes_homed())
  88. ui.goto_screen(tramming_wizard_menu);
  89. });
  90. }
  91. #endif // HAS_MARLINUI_MENU && ASSISTED_TRAMMING_WIZARD