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.

utility.cpp 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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 "utility.h"
  23. #include "../MarlinCore.h"
  24. #include "../module/temperature.h"
  25. void safe_delay(millis_t ms) {
  26. while (ms > 50) {
  27. ms -= 50;
  28. delay(50);
  29. thermalManager.task();
  30. }
  31. delay(ms);
  32. thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made
  33. }
  34. // A delay to provide brittle hosts time to receive bytes
  35. #if ENABLED(SERIAL_OVERRUN_PROTECTION)
  36. #include "../gcode/gcode.h" // for set_autoreport_paused
  37. void serial_delay(const millis_t ms) {
  38. const bool was = gcode.set_autoreport_paused(true);
  39. safe_delay(ms);
  40. gcode.set_autoreport_paused(was);
  41. }
  42. #endif
  43. #if ENABLED(DEBUG_LEVELING_FEATURE)
  44. #include "../module/probe.h"
  45. #include "../module/motion.h"
  46. #include "../module/planner.h"
  47. #include "../libs/numtostr.h"
  48. #include "../feature/bedlevel/bedlevel.h"
  49. void log_machine_info() {
  50. SERIAL_ECHOLNPGM("Machine Type: "
  51. TERN_(DELTA, "Delta")
  52. TERN_(IS_SCARA, "SCARA")
  53. TERN_(IS_CORE, "Core")
  54. TERN_(MARKFORGED_XY, "MarkForgedXY")
  55. TERN_(MARKFORGED_YX, "MarkForgedYX")
  56. TERN_(IS_CARTESIAN, "Cartesian")
  57. );
  58. SERIAL_ECHOLNPGM("Probe: "
  59. TERN_(PROBE_MANUALLY, "PROBE_MANUALLY")
  60. TERN_(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE")
  61. TERN_(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE")
  62. TERN_(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"))
  63. TERN_(BD_SENSOR, "BD_SENSOR")
  64. TERN_(TOUCH_MI_PROBE, "TOUCH_MI_PROBE")
  65. TERN_(Z_PROBE_SLED, "Z_PROBE_SLED")
  66. TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY")
  67. TERN_(SOLENOID_PROBE, "SOLENOID_PROBE")
  68. TERN_(MAGLEV4, "MAGLEV4")
  69. IF_DISABLED(PROBE_SELECTED, "NONE")
  70. );
  71. #if HAS_BED_PROBE
  72. #if !HAS_PROBE_XY_OFFSET
  73. SERIAL_ECHOPGM("Probe Offset X0 Y0 Z", probe.offset.z, " (");
  74. #else
  75. SERIAL_ECHOPGM_P(PSTR("Probe Offset X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR, probe.offset.z);
  76. if (probe.offset_xy.x > 0)
  77. SERIAL_ECHOPGM(" (Right");
  78. else if (probe.offset_xy.x < 0)
  79. SERIAL_ECHOPGM(" (Left");
  80. else if (probe.offset_xy.y != 0)
  81. SERIAL_ECHOPGM(" (Middle");
  82. else
  83. SERIAL_ECHOPGM(" (Aligned With");
  84. if (probe.offset_xy.y > 0)
  85. SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back")));
  86. else if (probe.offset_xy.y < 0)
  87. SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front")));
  88. else if (probe.offset_xy.x != 0)
  89. SERIAL_ECHOPGM("-Center");
  90. SERIAL_ECHOPGM(" & ");
  91. #endif
  92. SERIAL_ECHOF(probe.offset.z < 0 ? F("Below") : probe.offset.z > 0 ? F("Above") : F("Same Z as"));
  93. SERIAL_ECHOLNPGM(" Nozzle)");
  94. #endif
  95. #if HAS_ABL_OR_UBL
  96. SERIAL_ECHOPGM("Auto Bed Leveling: "
  97. TERN_(AUTO_BED_LEVELING_LINEAR, "LINEAR")
  98. TERN_(AUTO_BED_LEVELING_BILINEAR, "BILINEAR")
  99. TERN_(AUTO_BED_LEVELING_3POINT, "3POINT")
  100. TERN_(AUTO_BED_LEVELING_UBL, "UBL")
  101. );
  102. if (planner.leveling_active) {
  103. SERIAL_ECHOLNPGM(" (enabled)");
  104. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  105. if (planner.z_fade_height)
  106. SERIAL_ECHOLNPGM("Z Fade: ", planner.z_fade_height);
  107. #endif
  108. #if ABL_PLANAR
  109. SERIAL_ECHOPGM("ABL Adjustment");
  110. LOOP_NUM_AXES(a) {
  111. SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_STR[a]));
  112. serial_offset(planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]);
  113. }
  114. #else
  115. #if ENABLED(AUTO_BED_LEVELING_UBL)
  116. SERIAL_ECHOPGM("UBL Adjustment Z");
  117. #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
  118. SERIAL_ECHOPGM("ABL Adjustment Z");
  119. #endif
  120. const float rz = bedlevel.get_z_correction(current_position);
  121. SERIAL_ECHO(ftostr43sign(rz, '+'));
  122. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  123. if (planner.z_fade_height) {
  124. SERIAL_ECHOPGM(" (", ftostr43sign(rz * planner.fade_scaling_factor_for_z(current_position.z), '+'));
  125. SERIAL_CHAR(')');
  126. }
  127. #endif
  128. #endif
  129. }
  130. else
  131. SERIAL_ECHOLNPGM(" (disabled)");
  132. SERIAL_EOL();
  133. #elif ENABLED(MESH_BED_LEVELING)
  134. SERIAL_ECHOPGM("Mesh Bed Leveling");
  135. if (planner.leveling_active) {
  136. SERIAL_ECHOLNPGM(" (enabled)");
  137. const float z_offset = bedlevel.get_z_offset(),
  138. z_correction = bedlevel.get_z_correction(current_position);
  139. SERIAL_ECHOPGM("MBL Adjustment Z", ftostr43sign(z_offset + z_correction, '+'));
  140. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  141. if (planner.z_fade_height) {
  142. SERIAL_ECHOPGM(" (", ftostr43sign(
  143. z_offset + z_correction * planner.fade_scaling_factor_for_z(current_position.z), '+'
  144. ));
  145. SERIAL_CHAR(')');
  146. }
  147. #endif
  148. }
  149. else
  150. SERIAL_ECHOPGM(" (disabled)");
  151. SERIAL_EOL();
  152. #endif // MESH_BED_LEVELING
  153. }
  154. #endif // DEBUG_LEVELING_FEATURE