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.0KB

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