My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

z_stepper_align.cpp 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. * feature/z_stepper_align.cpp
  24. */
  25. #include "../inc/MarlinConfigPre.h"
  26. #if ENABLED(Z_STEPPER_AUTO_ALIGN)
  27. #include "z_stepper_align.h"
  28. #include "../module/probe.h"
  29. ZStepperAlign z_stepper_align;
  30. xy_pos_t ZStepperAlign::xy[NUM_Z_STEPPERS];
  31. #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
  32. xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPERS];
  33. #endif
  34. void ZStepperAlign::reset_to_default() {
  35. #ifdef Z_STEPPER_ALIGN_XY
  36. constexpr xy_pos_t xy_init[] = Z_STEPPER_ALIGN_XY;
  37. static_assert(COUNT(xy_init) == NUM_Z_STEPPERS,
  38. "Z_STEPPER_ALIGN_XY requires "
  39. #if NUM_Z_STEPPERS == 4
  40. "four {X,Y} entries (Z, Z2, Z3, and Z4)."
  41. #elif NUM_Z_STEPPERS == 3
  42. "three {X,Y} entries (Z, Z2, and Z3)."
  43. #else
  44. "two {X,Y} entries (Z and Z2)."
  45. #endif
  46. );
  47. #define VALIDATE_ALIGN_POINT(N) static_assert(N >= NUM_Z_STEPPERS || Probe::build_time::can_reach(xy_init[N]), \
  48. "Z_STEPPER_ALIGN_XY point " STRINGIFY(N) " is not reachable with the default NOZZLE_TO_PROBE offset and PROBING_MARGIN.")
  49. VALIDATE_ALIGN_POINT(0); VALIDATE_ALIGN_POINT(1); VALIDATE_ALIGN_POINT(2); VALIDATE_ALIGN_POINT(3);
  50. #else // !Z_STEPPER_ALIGN_XY
  51. const xy_pos_t xy_init[] = {
  52. #if NUM_Z_STEPPERS >= 3 // First probe point...
  53. #if !Z_STEPPERS_ORIENTATION
  54. { probe.min_x(), probe.min_y() }, // SW
  55. #elif Z_STEPPERS_ORIENTATION == 1
  56. { probe.min_x(), probe.max_y() }, // NW
  57. #elif Z_STEPPERS_ORIENTATION == 2
  58. { probe.max_x(), probe.max_y() }, // NE
  59. #elif Z_STEPPERS_ORIENTATION == 3
  60. { probe.max_x(), probe.min_y() }, // SE
  61. #else
  62. #error "Z_STEPPERS_ORIENTATION must be from 0 to 3 (first point SW, NW, NE, SE)."
  63. #endif
  64. #if NUM_Z_STEPPERS == 4 // 3 more points...
  65. #if !Z_STEPPERS_ORIENTATION
  66. { probe.min_x(), probe.max_y() }, { probe.max_x(), probe.max_y() }, { probe.max_x(), probe.min_y() } // SW
  67. #elif Z_STEPPERS_ORIENTATION == 1
  68. { probe.max_x(), probe.max_y() }, { probe.max_x(), probe.min_y() }, { probe.min_x(), probe.min_y() } // NW
  69. #elif Z_STEPPERS_ORIENTATION == 2
  70. { probe.max_x(), probe.min_y() }, { probe.min_x(), probe.min_y() }, { probe.min_x(), probe.max_y() } // NE
  71. #elif Z_STEPPERS_ORIENTATION == 3
  72. { probe.min_x(), probe.min_y() }, { probe.min_x(), probe.max_y() }, { probe.max_x(), probe.max_y() } // SE
  73. #endif
  74. #elif !Z_STEPPERS_ORIENTATION // or 2 more points...
  75. { probe.max_x(), probe.min_y() }, { X_CENTER, probe.max_y() } // SW
  76. #elif Z_STEPPERS_ORIENTATION == 1
  77. { probe.min_x(), probe.min_y() }, { probe.max_x(), Y_CENTER } // NW
  78. #elif Z_STEPPERS_ORIENTATION == 2
  79. { probe.min_x(), probe.max_y() }, { X_CENTER, probe.min_y() } // NE
  80. #elif Z_STEPPERS_ORIENTATION == 3
  81. { probe.max_x(), probe.max_y() }, { probe.min_x(), Y_CENTER } // SE
  82. #endif
  83. #elif Z_STEPPERS_ORIENTATION
  84. { X_CENTER, probe.min_y() }, { X_CENTER, probe.max_y() }
  85. #else
  86. { probe.min_x(), Y_CENTER }, { probe.max_x(), Y_CENTER }
  87. #endif
  88. };
  89. #endif // !Z_STEPPER_ALIGN_XY
  90. COPY(xy, xy_init);
  91. #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
  92. constexpr xy_pos_t stepper_xy_init[] = Z_STEPPER_ALIGN_STEPPER_XY;
  93. static_assert(
  94. COUNT(stepper_xy_init) == NUM_Z_STEPPERS,
  95. "Z_STEPPER_ALIGN_STEPPER_XY requires "
  96. #if NUM_Z_STEPPERS == 4
  97. "four {X,Y} entries (Z, Z2, Z3, and Z4)."
  98. #elif NUM_Z_STEPPERS == 3
  99. "three {X,Y} entries (Z, Z2, and Z3)."
  100. #endif
  101. );
  102. COPY(stepper_xy, stepper_xy_init);
  103. #endif
  104. }
  105. #endif // Z_STEPPER_AUTO_ALIGN