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.

probe.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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. #pragma once
  23. /**
  24. * probe.h - Move, deploy, enable, etc.
  25. */
  26. #include "../inc/MarlinConfig.h"
  27. #if HAS_BED_PROBE
  28. extern xyz_pos_t probe_offset;
  29. #if HAS_PROBE_XY_OFFSET
  30. extern xyz_pos_t &probe_offset_xy;
  31. #else
  32. constexpr xy_pos_t probe_offset_xy{0};
  33. #endif
  34. bool set_probe_deployed(const bool deploy);
  35. #ifdef Z_AFTER_PROBING
  36. void move_z_after_probing();
  37. #endif
  38. enum ProbePtRaise : unsigned char {
  39. PROBE_PT_NONE, // No raise or stow after run_z_probe
  40. PROBE_PT_STOW, // Do a complete stow after run_z_probe
  41. PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
  42. PROBE_PT_BIG_RAISE // Raise to big clearance after run_z_probe
  43. };
  44. float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true);
  45. inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true) {
  46. return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative);
  47. }
  48. #define DEPLOY_PROBE() set_probe_deployed(true)
  49. #define STOW_PROBE() set_probe_deployed(false)
  50. #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
  51. extern const char msg_wait_for_bed_heating[25];
  52. #endif
  53. #else
  54. constexpr xyz_pos_t probe_offset{0};
  55. constexpr xy_pos_t probe_offset_xy{0};
  56. #define DEPLOY_PROBE()
  57. #define STOW_PROBE()
  58. #endif
  59. #if HAS_BED_PROBE || ENABLED(PROBE_MANUALLY)
  60. #if IS_KINEMATIC
  61. constexpr float printable_radius = (
  62. #if ENABLED(DELTA)
  63. DELTA_PRINTABLE_RADIUS
  64. #elif IS_SCARA
  65. SCARA_PRINTABLE_RADIUS
  66. #endif
  67. );
  68. inline float probe_radius() {
  69. return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(probe_offset_xy.x, probe_offset_xy.y));
  70. }
  71. #endif
  72. inline float probe_min_x() {
  73. return (
  74. #if IS_KINEMATIC
  75. (X_CENTER) - probe_radius()
  76. #else
  77. _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset_xy.x)
  78. #endif
  79. );
  80. }
  81. inline float probe_max_x() {
  82. return (
  83. #if IS_KINEMATIC
  84. (X_CENTER) + probe_radius()
  85. #else
  86. _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset_xy.x)
  87. #endif
  88. );
  89. }
  90. inline float probe_min_y() {
  91. return (
  92. #if IS_KINEMATIC
  93. (Y_CENTER) - probe_radius()
  94. #else
  95. _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset_xy.y)
  96. #endif
  97. );
  98. }
  99. inline float probe_max_y() {
  100. return (
  101. #if IS_KINEMATIC
  102. (Y_CENTER) + probe_radius()
  103. #else
  104. _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset_xy.y)
  105. #endif
  106. );
  107. }
  108. #if NEEDS_THREE_PROBE_POINTS
  109. // Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
  110. template <typename T>
  111. inline void get_three_probe_points(T points[3]) {
  112. #if ENABLED(HAS_FIXED_3POINT)
  113. points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
  114. points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
  115. points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
  116. #else
  117. #if IS_KINEMATIC
  118. constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
  119. COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5;
  120. points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0);
  121. points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
  122. points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
  123. #else
  124. points[0].set(probe_min_x(), probe_min_y());
  125. points[1].set(probe_max_x(), probe_min_y());
  126. points[2].set((probe_max_x() - probe_min_x()) / 2, probe_max_y());
  127. #endif
  128. #endif
  129. }
  130. #endif
  131. #endif
  132. #if HAS_Z_SERVO_PROBE
  133. void servo_probe_init();
  134. #endif
  135. #if QUIET_PROBING
  136. void probing_pause(const bool p);
  137. #endif