My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. #include "../gcode.h"
  24. #include "../../module/motion.h"
  25. #include "../../module/stepper.h"
  26. #if ENABLED(M114_DETAIL)
  27. void report_all_axis_pos(const xyze_pos_t &pos, const uint8_t n=LOGICAL_AXES, const uint8_t precision=3) {
  28. char str[12];
  29. LOOP_L_N(a, n) {
  30. SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[a]));
  31. if (pos[a] >= 0) SERIAL_CHAR(' ');
  32. SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
  33. }
  34. SERIAL_EOL();
  35. }
  36. inline void report_linear_axis_pos(const xyze_pos_t &pos) { report_all_axis_pos(pos, XYZ); }
  37. void report_linear_axis_pos(const xyz_pos_t &pos, const uint8_t precision=3) {
  38. char str[12];
  39. LOOP_NUM_AXES(a) SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[a]), dtostrf(pos[a], 1, precision, str));
  40. SERIAL_EOL();
  41. }
  42. void report_current_position_detail() {
  43. // Position as sent by G-code
  44. SERIAL_ECHOPGM("\nLogical:");
  45. report_linear_axis_pos(current_position.asLogical());
  46. // Cartesian position in native machine space
  47. SERIAL_ECHOPGM("Raw: ");
  48. report_linear_axis_pos(current_position);
  49. xyze_pos_t leveled = current_position;
  50. #if HAS_LEVELING
  51. // Current position with leveling applied
  52. SERIAL_ECHOPGM("Leveled:");
  53. planner.apply_leveling(leveled);
  54. report_linear_axis_pos(leveled);
  55. // Test planner un-leveling. This should match the Raw result.
  56. SERIAL_ECHOPGM("UnLevel:");
  57. xyze_pos_t unleveled = leveled;
  58. planner.unapply_leveling(unleveled);
  59. report_linear_axis_pos(unleveled);
  60. #endif
  61. #if IS_KINEMATIC
  62. // Kinematics applied to the leveled position
  63. SERIAL_ECHOPGM(TERN(IS_SCARA, "ScaraK: ", "DeltaK: "));
  64. inverse_kinematics(leveled); // writes delta[]
  65. report_linear_axis_pos(delta);
  66. #endif
  67. planner.synchronize();
  68. SERIAL_ECHOPGM("Stepper:");
  69. LOOP_LOGICAL_AXES(i) {
  70. SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[i]), stepper.position((AxisEnum)i));
  71. }
  72. SERIAL_EOL();
  73. #if IS_SCARA
  74. const xy_float_t deg = {
  75. planner.get_axis_position_degrees(A_AXIS),
  76. planner.get_axis_position_degrees(B_AXIS)
  77. };
  78. SERIAL_ECHOPGM("Degrees:");
  79. report_all_axis_pos(deg, 2);
  80. #endif
  81. SERIAL_ECHOPGM("FromStp:");
  82. get_cartesian_from_steppers(); // writes 'cartes' (with forward kinematics)
  83. xyze_pos_t from_steppers = LOGICAL_AXIS_ARRAY(
  84. planner.get_axis_position_mm(E_AXIS),
  85. cartes.x, cartes.y, cartes.z,
  86. planner.get_axis_position_mm(I_AXIS),
  87. planner.get_axis_position_mm(J_AXIS),
  88. planner.get_axis_position_mm(K_AXIS),
  89. planner.get_axis_position_mm(U_AXIS),
  90. planner.get_axis_position_mm(V_AXIS),
  91. planner.get_axis_position_mm(W_AXIS)
  92. );
  93. report_all_axis_pos(from_steppers);
  94. const xyze_float_t diff = from_steppers - leveled;
  95. SERIAL_ECHOPGM("Diff: ");
  96. report_all_axis_pos(diff);
  97. TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_grblstate_moving());
  98. }
  99. #endif // M114_DETAIL
  100. /**
  101. * M114: Report the current position to host.
  102. * Since steppers are moving, the count positions are
  103. * projected by using planner calculations.
  104. * D - Report more detail. This syncs the planner. (Requires M114_DETAIL)
  105. * E - Report E stepper position (Requires M114_DETAIL)
  106. * R - Report the realtime position instead of projected.
  107. */
  108. void GcodeSuite::M114() {
  109. #if ENABLED(M114_DETAIL)
  110. if (parser.seen_test('D')) {
  111. #if DISABLED(M114_LEGACY)
  112. planner.synchronize();
  113. #endif
  114. report_current_position();
  115. report_current_position_detail();
  116. return;
  117. }
  118. #if HAS_EXTRUDERS
  119. if (parser.seen_test('E')) {
  120. SERIAL_ECHOLNPGM("Count E:", stepper.position(E_AXIS));
  121. return;
  122. }
  123. #endif
  124. #endif
  125. #if ENABLED(M114_REALTIME)
  126. if (parser.seen_test('R')) { report_real_position(); return; }
  127. #endif
  128. TERN_(M114_LEGACY, planner.synchronize());
  129. report_current_position_projected();
  130. TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_grblstate_moving());
  131. }