My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

M666.cpp 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. #include "../../inc/MarlinConfig.h"
  23. #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS
  24. #include "../gcode.h"
  25. #if ENABLED(DELTA)
  26. #include "../../module/delta.h"
  27. #include "../../module/motion.h"
  28. #else
  29. #include "../../module/endstops.h"
  30. #endif
  31. #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
  32. #include "../../core/debug_out.h"
  33. #if ENABLED(DELTA)
  34. /**
  35. * M666: Set delta endstop adjustment
  36. */
  37. void GcodeSuite::M666() {
  38. DEBUG_SECTION(log_M666, "M666", DEBUGGING(LEVELING));
  39. bool is_err = false, is_set = false;
  40. LOOP_NUM_AXES(i) {
  41. if (parser.seenval(AXIS_CHAR(i))) {
  42. is_set = true;
  43. const float v = parser.value_linear_units();
  44. if (v > 0)
  45. is_err = true;
  46. else {
  47. delta_endstop_adj[i] = v;
  48. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("delta_endstop_adj[", AS_CHAR(AXIS_CHAR(i)), "] = ", v);
  49. }
  50. }
  51. }
  52. if (is_err) SERIAL_ECHOLNPGM("?M666 offsets must be <= 0");
  53. if (!is_set) M666_report();
  54. }
  55. void GcodeSuite::M666_report(const bool forReplay/*=true*/) {
  56. report_heading_etc(forReplay, F(STR_ENDSTOP_ADJUSTMENT));
  57. SERIAL_ECHOLNPGM_P(
  58. PSTR(" M666 X"), LINEAR_UNIT(delta_endstop_adj.a)
  59. , SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b)
  60. , SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c)
  61. );
  62. }
  63. #else
  64. /**
  65. * M666: Set Dual Endstops offsets for X, Y, and/or Z.
  66. * With no parameters report current offsets.
  67. *
  68. * For Triple / Quad Z Endstops:
  69. * Set Z2 Only: M666 S2 Z<offset>
  70. * Set Z3 Only: M666 S3 Z<offset>
  71. * Set Z4 Only: M666 S4 Z<offset>
  72. * Set All: M666 Z<offset>
  73. */
  74. void GcodeSuite::M666() {
  75. if (!parser.seen_any()) return M666_report();
  76. #if ENABLED(X_DUAL_ENDSTOPS)
  77. if (parser.seenval('X')) endstops.x2_endstop_adj = parser.value_linear_units();
  78. #endif
  79. #if ENABLED(Y_DUAL_ENDSTOPS)
  80. if (parser.seenval('Y')) endstops.y2_endstop_adj = parser.value_linear_units();
  81. #endif
  82. #if ENABLED(Z_MULTI_ENDSTOPS)
  83. if (parser.seenval('Z')) {
  84. const float z_adj = parser.value_linear_units();
  85. #if NUM_Z_STEPPERS == 2
  86. endstops.z2_endstop_adj = z_adj;
  87. #else
  88. const int ind = parser.intval('S');
  89. #define _SET_ZADJ(N) if (!ind || ind == N) endstops.z##N##_endstop_adj = z_adj;
  90. REPEAT_S(2, INCREMENT(NUM_Z_STEPPERS), _SET_ZADJ)
  91. #endif
  92. }
  93. #endif
  94. }
  95. void GcodeSuite::M666_report(const bool forReplay/*=true*/) {
  96. report_heading_etc(forReplay, F(STR_ENDSTOP_ADJUSTMENT));
  97. SERIAL_ECHOPGM(" M666");
  98. #if ENABLED(X_DUAL_ENDSTOPS)
  99. SERIAL_ECHOLNPGM_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj));
  100. #endif
  101. #if ENABLED(Y_DUAL_ENDSTOPS)
  102. SERIAL_ECHOLNPGM_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj));
  103. #endif
  104. #if ENABLED(Z_MULTI_ENDSTOPS)
  105. #if NUM_Z_STEPPERS >= 3
  106. SERIAL_ECHOPGM(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
  107. report_echo_start(forReplay);
  108. SERIAL_ECHOPGM(" M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
  109. #if NUM_Z_STEPPERS >= 4
  110. report_echo_start(forReplay);
  111. SERIAL_ECHOPGM(" M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj));
  112. #endif
  113. #else
  114. SERIAL_ECHOLNPGM_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj));
  115. #endif
  116. #endif
  117. }
  118. #endif // HAS_EXTRA_ENDSTOPS
  119. #endif // DELTA || HAS_EXTRA_ENDSTOPS