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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.manage_heater();
  30. }
  31. delay(ms);
  32. thermalManager.manage_heater(); // 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/stepper.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, "MarkForged")
  55. TERN_(IS_CARTESIAN, "Cartesian")
  56. );
  57. SERIAL_ECHOLNPGM("Probe: "
  58. TERN_(PROBE_MANUALLY, "PROBE_MANUALLY")
  59. TERN_(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE")
  60. TERN_(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE")
  61. TERN_(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"))
  62. TERN_(TOUCH_MI_PROBE, "TOUCH_MI_PROBE")
  63. TERN_(Z_PROBE_SLED, "Z_PROBE_SLED")
  64. TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY")
  65. TERN_(SOLENOID_PROBE, "SOLENOID_PROBE")
  66. TERN(PROBE_SELECTED, "", "NONE")
  67. );
  68. #if HAS_BED_PROBE
  69. #if !HAS_PROBE_XY_OFFSET
  70. SERIAL_ECHOPGM("Probe Offset X0 Y0 Z", probe.offset.z, " (");
  71. #else
  72. SERIAL_ECHOPGM_P(PSTR("Probe Offset X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR, probe.offset.z);
  73. if (probe.offset_xy.x > 0)
  74. SERIAL_ECHOPGM(" (Right");
  75. else if (probe.offset_xy.x < 0)
  76. SERIAL_ECHOPGM(" (Left");
  77. else if (probe.offset_xy.y != 0)
  78. SERIAL_ECHOPGM(" (Middle");
  79. else
  80. SERIAL_ECHOPGM(" (Aligned With");
  81. if (probe.offset_xy.y > 0)
  82. SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back")));
  83. else if (probe.offset_xy.y < 0)
  84. SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front")));
  85. else if (probe.offset_xy.x != 0)
  86. SERIAL_ECHOPGM("-Center");
  87. SERIAL_ECHOPGM(" & ");
  88. #endif
  89. SERIAL_ECHOF(probe.offset.z < 0 ? F("Below") : probe.offset.z > 0 ? F("Above") : F("Same Z as"));
  90. SERIAL_ECHOLNPGM(" Nozzle)");
  91. #endif
  92. #if HAS_ABL_OR_UBL
  93. SERIAL_ECHOPGM("Auto Bed Leveling: "
  94. TERN_(AUTO_BED_LEVELING_LINEAR, "LINEAR")
  95. TERN_(AUTO_BED_LEVELING_BILINEAR, "BILINEAR")
  96. TERN_(AUTO_BED_LEVELING_3POINT, "3POINT")
  97. TERN_(AUTO_BED_LEVELING_UBL, "UBL")
  98. );
  99. if (planner.leveling_active) {
  100. SERIAL_ECHOLNPGM(" (enabled)");
  101. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  102. if (planner.z_fade_height)
  103. SERIAL_ECHOLNPGM("Z Fade: ", planner.z_fade_height);
  104. #endif
  105. #if ABL_PLANAR
  106. SERIAL_ECHOPGM("ABL Adjustment");
  107. LOOP_LINEAR_AXES(a) {
  108. const float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a];
  109. SERIAL_CHAR(' ', AXIS_CHAR(a));
  110. if (v > 0) SERIAL_CHAR('+');
  111. SERIAL_DECIMAL(v);
  112. }
  113. #else
  114. #if ENABLED(AUTO_BED_LEVELING_UBL)
  115. SERIAL_ECHOPGM("UBL Adjustment Z");
  116. const float rz = ubl.get_z_correction(current_position);
  117. #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
  118. SERIAL_ECHOPGM("ABL Adjustment Z");
  119. const float rz = bilinear_z_offset(current_position);
  120. #endif
  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. SERIAL_ECHOPGM("MBL Adjustment Z", ftostr43sign(mbl.get_z(current_position), '+'));
  138. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  139. if (planner.z_fade_height) {
  140. SERIAL_ECHOPGM(" (", ftostr43sign(
  141. mbl.get_z(current_position, planner.fade_scaling_factor_for_z(current_position.z)), '+'
  142. ));
  143. SERIAL_CHAR(')');
  144. }
  145. #endif
  146. }
  147. else
  148. SERIAL_ECHOPGM(" (disabled)");
  149. SERIAL_EOL();
  150. #endif // MESH_BED_LEVELING
  151. }
  152. #endif // DEBUG_LEVELING_FEATURE