My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

M114.cpp 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. #include "../../inc/MarlinConfig.h"
  23. #include "../gcode.h"
  24. #include "../../module/motion.h"
  25. #include "../../module/stepper.h"
  26. #if ENABLED(M114_DETAIL)
  27. #if HAS_L64XX
  28. #include "../../libs/L64XX/L64XX_Marlin.h"
  29. #define DEBUG_OUT ENABLED(L6470_CHITCHAT)
  30. #include "../../core/debug_out.h"
  31. #endif
  32. void report_xyze(const xyze_pos_t &pos, const uint8_t n=4, const uint8_t precision=3) {
  33. char str[12];
  34. for (uint8_t a = 0; a < n; a++) {
  35. SERIAL_CHAR(' ', axis_codes[a], ':');
  36. SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
  37. }
  38. SERIAL_EOL();
  39. }
  40. void report_xyz(const xyz_pos_t &pos, const uint8_t precision=3) {
  41. char str[12];
  42. for (uint8_t a = X_AXIS; a <= Z_AXIS; a++) {
  43. SERIAL_CHAR(' ', axis_codes[a], ':');
  44. SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
  45. }
  46. SERIAL_EOL();
  47. }
  48. inline void report_xyz(const xyze_pos_t &pos) { report_xyze(pos, 3); }
  49. void report_current_position_detail() {
  50. SERIAL_ECHOPGM("\nLogical:");
  51. report_xyz(current_position.asLogical());
  52. SERIAL_ECHOPGM("Raw: ");
  53. report_xyz(current_position);
  54. xyze_pos_t leveled = current_position;
  55. #if HAS_LEVELING
  56. SERIAL_ECHOPGM("Leveled:");
  57. planner.apply_leveling(leveled);
  58. report_xyz(leveled);
  59. SERIAL_ECHOPGM("UnLevel:");
  60. xyze_pos_t unleveled = leveled;
  61. planner.unapply_leveling(unleveled);
  62. report_xyz(unleveled);
  63. #endif
  64. #if IS_KINEMATIC
  65. #if IS_SCARA
  66. SERIAL_ECHOPGM("ScaraK: ");
  67. #else
  68. SERIAL_ECHOPGM("DeltaK: ");
  69. #endif
  70. inverse_kinematics(leveled); // writes delta[]
  71. report_xyz(delta);
  72. #endif
  73. planner.synchronize();
  74. #if HAS_L64XX
  75. char temp_buf[80];
  76. int32_t temp;
  77. //#define ABS_POS_SIGN_MASK 0b1111 1111 1110 0000 0000 0000 0000 0000
  78. #define ABS_POS_SIGN_MASK 0b11111111111000000000000000000000
  79. #define REPORT_ABSOLUTE_POS(Q) do{ \
  80. L64xxManager.say_axis(Q, false); \
  81. temp = L6470_GETPARAM(L6470_ABS_POS,Q); \
  82. if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \
  83. sprintf_P(temp_buf, PSTR(":%8ld "), temp); \
  84. DEBUG_ECHO(temp_buf); \
  85. }while(0)
  86. DEBUG_ECHOPGM("\nL6470:");
  87. #if AXIS_IS_L64XX(X)
  88. REPORT_ABSOLUTE_POS(X);
  89. #endif
  90. #if AXIS_IS_L64XX(X2)
  91. REPORT_ABSOLUTE_POS(X2);
  92. #endif
  93. #if AXIS_IS_L64XX(Y)
  94. REPORT_ABSOLUTE_POS(Y);
  95. #endif
  96. #if AXIS_IS_L64XX(Y2)
  97. REPORT_ABSOLUTE_POS(Y2);
  98. #endif
  99. #if AXIS_IS_L64XX(Z)
  100. REPORT_ABSOLUTE_POS(Z);
  101. #endif
  102. #if AXIS_IS_L64XX(Z2)
  103. REPORT_ABSOLUTE_POS(Z2);
  104. #endif
  105. #if AXIS_IS_L64XX(Z3)
  106. REPORT_ABSOLUTE_POS(Z3);
  107. #endif
  108. #if AXIS_IS_L64XX(Z4)
  109. REPORT_ABSOLUTE_POS(Z4);
  110. #endif
  111. #if AXIS_IS_L64XX(E0)
  112. REPORT_ABSOLUTE_POS(E0);
  113. #endif
  114. #if AXIS_IS_L64XX(E1)
  115. REPORT_ABSOLUTE_POS(E1);
  116. #endif
  117. #if AXIS_IS_L64XX(E2)
  118. REPORT_ABSOLUTE_POS(E2);
  119. #endif
  120. #if AXIS_IS_L64XX(E3)
  121. REPORT_ABSOLUTE_POS(E3);
  122. #endif
  123. #if AXIS_IS_L64XX(E4)
  124. REPORT_ABSOLUTE_POS(E4);
  125. #endif
  126. #if AXIS_IS_L64XX(E5)
  127. REPORT_ABSOLUTE_POS(E5);
  128. #endif
  129. SERIAL_EOL();
  130. #endif // HAS_L64XX
  131. SERIAL_ECHOPGM("Stepper:");
  132. LOOP_XYZE(i) {
  133. SERIAL_CHAR(' ', axis_codes[i], ':');
  134. SERIAL_ECHO(stepper.position((AxisEnum)i));
  135. }
  136. SERIAL_EOL();
  137. #if IS_SCARA
  138. const xy_float_t deg = {
  139. planner.get_axis_position_degrees(A_AXIS),
  140. planner.get_axis_position_degrees(B_AXIS)
  141. };
  142. SERIAL_ECHOPGM("Degrees:");
  143. report_xyze(deg, 2);
  144. #endif
  145. SERIAL_ECHOPGM("FromStp:");
  146. get_cartesian_from_steppers(); // writes 'cartes' (with forward kinematics)
  147. xyze_pos_t from_steppers = { cartes.x, cartes.y, cartes.z, planner.get_axis_position_mm(E_AXIS) };
  148. report_xyze(from_steppers);
  149. const xyze_float_t diff = from_steppers - leveled;
  150. SERIAL_ECHOPGM("Diff: ");
  151. report_xyze(diff);
  152. }
  153. #endif // M114_DETAIL
  154. /**
  155. * M114: Report current position to host
  156. */
  157. void GcodeSuite::M114() {
  158. #if ENABLED(M114_DETAIL)
  159. if (parser.seen('D')) {
  160. report_current_position_detail();
  161. return;
  162. }
  163. if (parser.seen('E')) {
  164. SERIAL_ECHOLNPAIR("Count E:", stepper.position(E_AXIS));
  165. return;
  166. }
  167. #endif
  168. planner.synchronize();
  169. report_current_position();
  170. }