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_delta_calibrate.cpp 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. // Delta Calibrate Menu
  24. //
  25. #include "../../inc/MarlinConfigPre.h"
  26. #if HAS_MARLINUI_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
  27. #include "menu_item.h"
  28. #include "../../module/delta.h"
  29. #include "../../module/motion.h"
  30. #include "../../module/planner.h"
  31. #if HAS_LEVELING
  32. #include "../../feature/bedlevel/bedlevel.h"
  33. #endif
  34. #if ENABLED(EXTENSIBLE_UI)
  35. #include "../extui/ui_api.h"
  36. #endif
  37. #if HAS_PROBE_XY_OFFSET
  38. #include "../../module/probe.h"
  39. #endif
  40. void _man_probe_pt(const xy_pos_t &xy) {
  41. if (!ui.wait_for_move) {
  42. ui.wait_for_move = true;
  43. do_blocking_move_to_xy_z(xy, Z_CLEARANCE_BETWEEN_PROBES);
  44. ui.wait_for_move = false;
  45. ui.synchronize();
  46. ui.manual_move.menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / planner.settings.axis_steps_per_mm[0]); // Use first axis as for delta XYZ should always match
  47. ui.goto_screen([]{ lcd_move_axis(Z_AXIS); });
  48. }
  49. }
  50. #if ENABLED(DELTA_AUTO_CALIBRATION)
  51. #if HAS_RESUME_CONTINUE
  52. #include "../../MarlinCore.h" // for wait_for_user_response()
  53. #endif
  54. #if ENABLED(HOST_PROMPT_SUPPORT)
  55. #include "../../feature/host_actions.h" // for hostui.prompt_do
  56. #endif
  57. float lcd_probe_pt(const xy_pos_t &xy) {
  58. _man_probe_pt(xy);
  59. ui.defer_status_screen();
  60. TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Delta Calibration in progress"), FPSTR(CONTINUE_STR)));
  61. TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Delta Calibration in progress")));
  62. TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
  63. ui.goto_previous_screen_no_defer();
  64. return current_position.z;
  65. }
  66. #endif
  67. #if ENABLED(DELTA_CALIBRATION_MENU)
  68. #include "../../gcode/queue.h"
  69. void _lcd_calibrate_homing() {
  70. _lcd_draw_homing();
  71. if (all_axes_homed()) ui.goto_previous_screen();
  72. }
  73. void _lcd_delta_calibrate_home() {
  74. queue.inject_P(G28_STR);
  75. ui.goto_screen(_lcd_calibrate_homing);
  76. }
  77. void _goto_tower_a(const_float_t a) {
  78. float dcr = DELTA_PRINTABLE_RADIUS - PROBING_MARGIN;
  79. TERN_(HAS_PROBE_XY_OFFSET, dcr -= HYPOT(probe.offset_xy.x, probe.offset_xy.y));
  80. TERN_(HAS_DELTA_SENSORLESS_PROBING, dcr *= sensorless_radius_factor);
  81. xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) };
  82. _man_probe_pt(tower_vec * dcr);
  83. }
  84. void _goto_tower_x() { _goto_tower_a(210); }
  85. void _goto_tower_y() { _goto_tower_a(330); }
  86. void _goto_tower_z() { _goto_tower_a( 90); }
  87. void _goto_center() { xy_pos_t ctr{0}; _man_probe_pt(ctr); }
  88. #endif
  89. void lcd_delta_settings() {
  90. auto _recalc_delta_settings = []{
  91. TERN_(HAS_LEVELING, reset_bed_level()); // After changing kinematics bed-level data is no longer valid
  92. recalc_delta_settings();
  93. };
  94. START_MENU();
  95. BACK_ITEM(MSG_DELTA_CALIBRATE);
  96. EDIT_ITEM(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings);
  97. #define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_F(float43, F(LABEL), &delta_endstop_adj.N, -5, 0, _recalc_delta_settings)
  98. EDIT_ENDSTOP_ADJ("Ex", a);
  99. EDIT_ENDSTOP_ADJ("Ey", b);
  100. EDIT_ENDSTOP_ADJ("Ez", c);
  101. EDIT_ITEM(float52sign, MSG_DELTA_RADIUS, &delta_radius, delta_radius - 5, delta_radius + 5, _recalc_delta_settings);
  102. #define EDIT_ANGLE_TRIM(LABEL,N) EDIT_ITEM_F(float43, F(LABEL), &delta_tower_angle_trim.N, -5, 5, _recalc_delta_settings)
  103. EDIT_ANGLE_TRIM("Tx", a);
  104. EDIT_ANGLE_TRIM("Ty", b);
  105. EDIT_ANGLE_TRIM("Tz", c);
  106. EDIT_ITEM(float52sign, MSG_DELTA_DIAG_ROD, &delta_diagonal_rod, delta_diagonal_rod - 5, delta_diagonal_rod + 5, _recalc_delta_settings);
  107. END_MENU();
  108. }
  109. void menu_delta_calibrate() {
  110. #if ENABLED(DELTA_CALIBRATION_MENU)
  111. const bool all_homed = all_axes_homed(); // Acquire ahead of loop
  112. #endif
  113. START_MENU();
  114. BACK_ITEM(MSG_MAIN);
  115. #if ENABLED(DELTA_AUTO_CALIBRATION)
  116. GCODES_ITEM(MSG_DELTA_AUTO_CALIBRATE, F("G33"));
  117. #if ENABLED(EEPROM_SETTINGS)
  118. ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
  119. ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);
  120. #endif
  121. #endif
  122. SUBMENU(MSG_DELTA_SETTINGS, lcd_delta_settings);
  123. #if ENABLED(DELTA_CALIBRATION_MENU)
  124. SUBMENU(MSG_AUTO_HOME, _lcd_delta_calibrate_home);
  125. if (all_homed) {
  126. SUBMENU(MSG_DELTA_CALIBRATE_X, _goto_tower_x);
  127. SUBMENU(MSG_DELTA_CALIBRATE_Y, _goto_tower_y);
  128. SUBMENU(MSG_DELTA_CALIBRATE_Z, _goto_tower_z);
  129. SUBMENU(MSG_DELTA_CALIBRATE_CENTER, _goto_center);
  130. }
  131. #endif
  132. END_MENU();
  133. }
  134. #endif // HAS_MARLINUI_MENU && (DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION)