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.

M114.cpp 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. void report_xyze(const float pos[XYZE], const uint8_t n = 4, const uint8_t precision = 3) {
  28. char str[12];
  29. for (uint8_t i = 0; i < n; i++) {
  30. SERIAL_CHAR(' ');
  31. SERIAL_CHAR(axis_codes[i]);
  32. SERIAL_CHAR(':');
  33. SERIAL_PROTOCOL(dtostrf(pos[i], 8, precision, str));
  34. }
  35. SERIAL_EOL();
  36. }
  37. inline void report_xyz(const float pos[XYZ]) { report_xyze(pos, 3); }
  38. void report_current_position_detail() {
  39. stepper.synchronize();
  40. SERIAL_PROTOCOLPGM("\nLogical:");
  41. const float logical[XYZ] = {
  42. LOGICAL_X_POSITION(current_position[X_AXIS]),
  43. LOGICAL_Y_POSITION(current_position[Y_AXIS]),
  44. LOGICAL_Z_POSITION(current_position[Z_AXIS])
  45. };
  46. report_xyze(logical);
  47. SERIAL_PROTOCOLPGM("Raw: ");
  48. report_xyz(current_position);
  49. float leveled[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
  50. #if PLANNER_LEVELING
  51. SERIAL_PROTOCOLPGM("Leveled:");
  52. planner.apply_leveling(leveled);
  53. report_xyz(leveled);
  54. SERIAL_PROTOCOLPGM("UnLevel:");
  55. float unleveled[XYZ] = { leveled[X_AXIS], leveled[Y_AXIS], leveled[Z_AXIS] };
  56. planner.unapply_leveling(unleveled);
  57. report_xyz(unleveled);
  58. #endif
  59. #if IS_KINEMATIC
  60. #if IS_SCARA
  61. SERIAL_PROTOCOLPGM("ScaraK: ");
  62. #else
  63. SERIAL_PROTOCOLPGM("DeltaK: ");
  64. #endif
  65. inverse_kinematics(leveled); // writes delta[]
  66. report_xyz(delta);
  67. #endif
  68. SERIAL_PROTOCOLPGM("Stepper:");
  69. LOOP_XYZE(i) {
  70. SERIAL_CHAR(' ');
  71. SERIAL_CHAR(axis_codes[i]);
  72. SERIAL_CHAR(':');
  73. SERIAL_PROTOCOL(stepper.position((AxisEnum)i));
  74. }
  75. SERIAL_EOL();
  76. #if IS_SCARA
  77. const float deg[XYZ] = {
  78. stepper.get_axis_position_degrees(A_AXIS),
  79. stepper.get_axis_position_degrees(B_AXIS)
  80. };
  81. SERIAL_PROTOCOLPGM("Degrees:");
  82. report_xyze(deg, 2);
  83. #endif
  84. SERIAL_PROTOCOLPGM("FromStp:");
  85. get_cartesian_from_steppers(); // writes cartes[XYZ] (with forward kinematics)
  86. const float from_steppers[XYZE] = { cartes[X_AXIS], cartes[Y_AXIS], cartes[Z_AXIS], stepper.get_axis_position_mm(E_AXIS) };
  87. report_xyze(from_steppers);
  88. const float diff[XYZE] = {
  89. from_steppers[X_AXIS] - leveled[X_AXIS],
  90. from_steppers[Y_AXIS] - leveled[Y_AXIS],
  91. from_steppers[Z_AXIS] - leveled[Z_AXIS],
  92. from_steppers[E_AXIS] - current_position[E_AXIS]
  93. };
  94. SERIAL_PROTOCOLPGM("Differ: ");
  95. report_xyze(diff);
  96. }
  97. #endif // M114_DETAIL
  98. /**
  99. * M114: Report current position to host
  100. */
  101. void GcodeSuite::M114() {
  102. #if ENABLED(M114_DETAIL)
  103. if (parser.seen('D')) {
  104. report_current_position_detail();
  105. return;
  106. }
  107. #endif
  108. stepper.synchronize();
  109. report_current_position();
  110. }