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 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. //
  23. // Delta Calibrate Menu
  24. //
  25. #include "../../inc/MarlinConfigPre.h"
  26. #if HAS_LCD_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
  27. #include "menu.h"
  28. #include "../../module/delta.h"
  29. #include "../../module/motion.h"
  30. #if HAS_LEVELING
  31. #include "../../feature/bedlevel/bedlevel.h"
  32. #endif
  33. #if ENABLED(EXTENSIBLE_UI)
  34. #include "../../lcd/extui/ui_api.h"
  35. #endif
  36. void _man_probe_pt(const xy_pos_t &xy) {
  37. if (!ui.wait_for_move) {
  38. ui.wait_for_move = true;
  39. do_blocking_move_to_xy_z(xy, Z_CLEARANCE_BETWEEN_PROBES);
  40. ui.wait_for_move = false;
  41. ui.synchronize();
  42. move_menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
  43. ui.goto_screen(lcd_move_z);
  44. }
  45. }
  46. #if ENABLED(DELTA_AUTO_CALIBRATION)
  47. #include "../../gcode/gcode.h"
  48. #if ENABLED(HOST_PROMPT_SUPPORT)
  49. #include "../../feature/host_actions.h" // for host_prompt_do
  50. #endif
  51. float lcd_probe_pt(const xy_pos_t &xy) {
  52. _man_probe_pt(xy);
  53. KEEPALIVE_STATE(PAUSED_FOR_USER);
  54. ui.defer_status_screen();
  55. wait_for_user = true;
  56. #if ENABLED(HOST_PROMPT_SUPPORT)
  57. host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Delta Calibration in progress"), CONTINUE_STR);
  58. #endif
  59. #if ENABLED(EXTENSIBLE_UI)
  60. ExtUI::onUserConfirmRequired_P(PSTR("Delta Calibration in progress"));
  61. #endif
  62. while (wait_for_user) idle();
  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 &a) {
  78. xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) };
  79. _man_probe_pt(tower_vec * delta_calibration_radius());
  80. }
  81. void _goto_tower_x() { _goto_tower_a(210); }
  82. void _goto_tower_y() { _goto_tower_a(330); }
  83. void _goto_tower_z() { _goto_tower_a( 90); }
  84. void _goto_center() { xy_pos_t ctr{0}; _man_probe_pt(ctr); }
  85. #endif
  86. void lcd_delta_settings() {
  87. auto _recalc_delta_settings = []{
  88. #if HAS_LEVELING
  89. reset_bed_level(); // After changing kinematics bed-level data is no longer valid
  90. #endif
  91. recalc_delta_settings();
  92. };
  93. START_MENU();
  94. BACK_ITEM(MSG_DELTA_CALIBRATE);
  95. EDIT_ITEM(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings);
  96. #define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_endstop_adj.N, -5, 5, _recalc_delta_settings)
  97. EDIT_ENDSTOP_ADJ("Ex", a);
  98. EDIT_ENDSTOP_ADJ("Ey", b);
  99. EDIT_ENDSTOP_ADJ("Ez", c);
  100. EDIT_ITEM(float52sign, MSG_DELTA_RADIUS, &delta_radius, delta_radius - 5, delta_radius + 5, _recalc_delta_settings);
  101. #define EDIT_ANGLE_TRIM(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_tower_angle_trim.N, -5, 5, _recalc_delta_settings)
  102. EDIT_ANGLE_TRIM("Tx", a);
  103. EDIT_ANGLE_TRIM("Ty", b);
  104. EDIT_ANGLE_TRIM("Tz", c);
  105. EDIT_ITEM(float52sign, MSG_DELTA_DIAG_ROD, &delta_diagonal_rod, delta_diagonal_rod - 5, delta_diagonal_rod + 5, _recalc_delta_settings);
  106. END_MENU();
  107. }
  108. void menu_delta_calibrate() {
  109. START_MENU();
  110. BACK_ITEM(MSG_MAIN);
  111. #if ENABLED(DELTA_AUTO_CALIBRATION)
  112. GCODES_ITEM(MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
  113. #if ENABLED(EEPROM_SETTINGS)
  114. ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
  115. ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
  116. #endif
  117. #endif
  118. SUBMENU(MSG_DELTA_SETTINGS, lcd_delta_settings);
  119. #if ENABLED(DELTA_CALIBRATION_MENU)
  120. SUBMENU(MSG_AUTO_HOME, _lcd_delta_calibrate_home);
  121. if (all_axes_homed()) {
  122. SUBMENU(MSG_DELTA_CALIBRATE_X, _goto_tower_x);
  123. SUBMENU(MSG_DELTA_CALIBRATE_Y, _goto_tower_y);
  124. SUBMENU(MSG_DELTA_CALIBRATE_Z, _goto_tower_z);
  125. SUBMENU(MSG_DELTA_CALIBRATE_CENTER, _goto_center);
  126. }
  127. #endif
  128. END_MENU();
  129. }
  130. #endif // HAS_LCD_MENU && (DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION)