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.

M665.cpp 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 IS_KINEMATIC
  24. #include "../gcode.h"
  25. #include "../../module/motion.h"
  26. #if ENABLED(DELTA)
  27. #include "../../module/delta.h"
  28. /**
  29. * M665: Set delta configurations
  30. *
  31. * H = delta height
  32. * L = diagonal rod
  33. * R = delta radius
  34. * S = segments per second
  35. * X = Alpha (Tower 1) angle trim
  36. * Y = Beta (Tower 2) angle trim
  37. * Z = Gamma (Tower 3) angle trim
  38. * A = Alpha (Tower 1) diagonal rod trim
  39. * B = Beta (Tower 2) diagonal rod trim
  40. * C = Gamma (Tower 3) diagonal rod trim
  41. */
  42. void GcodeSuite::M665() {
  43. if (!parser.seen_any()) return M665_report();
  44. if (parser.seenval('H')) delta_height = parser.value_linear_units();
  45. if (parser.seenval('L')) delta_diagonal_rod = parser.value_linear_units();
  46. if (parser.seenval('R')) delta_radius = parser.value_linear_units();
  47. if (parser.seenval('S')) segments_per_second = parser.value_float();
  48. if (parser.seenval('X')) delta_tower_angle_trim.a = parser.value_float();
  49. if (parser.seenval('Y')) delta_tower_angle_trim.b = parser.value_float();
  50. if (parser.seenval('Z')) delta_tower_angle_trim.c = parser.value_float();
  51. if (parser.seenval('A')) delta_diagonal_rod_trim.a = parser.value_float();
  52. if (parser.seenval('B')) delta_diagonal_rod_trim.b = parser.value_float();
  53. if (parser.seenval('C')) delta_diagonal_rod_trim.c = parser.value_float();
  54. recalc_delta_settings();
  55. }
  56. void GcodeSuite::M665_report(const bool forReplay/*=true*/) {
  57. report_heading_etc(forReplay, PSTR(STR_DELTA_SETTINGS));
  58. SERIAL_ECHOLNPGM_P(
  59. PSTR(" M665 L"), LINEAR_UNIT(delta_diagonal_rod)
  60. , PSTR(" R"), LINEAR_UNIT(delta_radius)
  61. , PSTR(" H"), LINEAR_UNIT(delta_height)
  62. , PSTR(" S"), segments_per_second
  63. , SP_X_STR, LINEAR_UNIT(delta_tower_angle_trim.a)
  64. , SP_Y_STR, LINEAR_UNIT(delta_tower_angle_trim.b)
  65. , SP_Z_STR, LINEAR_UNIT(delta_tower_angle_trim.c)
  66. , PSTR(" A"), LINEAR_UNIT(delta_diagonal_rod_trim.a)
  67. , PSTR(" B"), LINEAR_UNIT(delta_diagonal_rod_trim.b)
  68. , PSTR(" C"), LINEAR_UNIT(delta_diagonal_rod_trim.c)
  69. );
  70. }
  71. #elif IS_SCARA
  72. #include "../../module/scara.h"
  73. /**
  74. * M665: Set SCARA settings
  75. *
  76. * Parameters:
  77. *
  78. * S[segments-per-second] - Segments-per-second
  79. *
  80. * Without NO_WORKSPACE_OFFSETS:
  81. *
  82. * P[theta-psi-offset] - Theta-Psi offset, added to the shoulder (A/X) angle
  83. * T[theta-offset] - Theta offset, added to the elbow (B/Y) angle
  84. * Z[z-offset] - Z offset, added to Z
  85. *
  86. * A, P, and X are all aliases for the shoulder angle
  87. * B, T, and Y are all aliases for the elbow angle
  88. */
  89. void GcodeSuite::M665() {
  90. if (!parser.seen_any()) return M665_report();
  91. if (parser.seenval('S')) segments_per_second = parser.value_float();
  92. #if HAS_SCARA_OFFSET
  93. if (parser.seenval('Z')) scara_home_offset.z = parser.value_linear_units();
  94. const bool hasA = parser.seenval('A'), hasP = parser.seenval('P'), hasX = parser.seenval('X');
  95. const uint8_t sumAPX = hasA + hasP + hasX;
  96. if (sumAPX) {
  97. if (sumAPX == 1)
  98. scara_home_offset.a = parser.value_float();
  99. else {
  100. SERIAL_ERROR_MSG("Only one of A, P, or X is allowed.");
  101. return;
  102. }
  103. }
  104. const bool hasB = parser.seenval('B'), hasT = parser.seenval('T'), hasY = parser.seenval('Y');
  105. const uint8_t sumBTY = hasB + hasT + hasY;
  106. if (sumBTY) {
  107. if (sumBTY == 1)
  108. scara_home_offset.b = parser.value_float();
  109. else {
  110. SERIAL_ERROR_MSG("Only one of B, T, or Y is allowed.");
  111. return;
  112. }
  113. }
  114. #endif // HAS_SCARA_OFFSET
  115. }
  116. void GcodeSuite::M665_report(const bool forReplay/*=true*/) {
  117. report_heading_etc(forReplay, PSTR(STR_SCARA_SETTINGS " (" STR_SCARA_S TERN_(HAS_SCARA_OFFSET, " " STR_SCARA_P_T_Z) ")"));
  118. SERIAL_ECHOLNPGM_P(
  119. PSTR(" M665 S"), segments_per_second
  120. #if HAS_SCARA_OFFSET
  121. , SP_P_STR, scara_home_offset.a
  122. , SP_T_STR, scara_home_offset.b
  123. , SP_Z_STR, LINEAR_UNIT(scara_home_offset.z)
  124. #endif
  125. );
  126. }
  127. #endif
  128. #endif // IS_KINEMATIC