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

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