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

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