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.

M290.cpp 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 "../../inc/MarlinConfig.h"
  23. #if ENABLED(BABYSTEPPING)
  24. #include "../gcode.h"
  25. #include "../../feature/babystep.h"
  26. #include "../../module/probe.h"
  27. #include "../../module/temperature.h"
  28. #include "../../module/planner.h"
  29. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  30. #include "../../core/serial.h"
  31. #endif
  32. #if ENABLED(MESH_BED_LEVELING)
  33. #include "../../feature/bedlevel/bedlevel.h"
  34. #endif
  35. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  36. FORCE_INLINE void mod_probe_offset(const float &offs) {
  37. if (TERN1(BABYSTEP_HOTEND_Z_OFFSET, active_extruder == 0)) {
  38. probe.offset.z += offs;
  39. SERIAL_ECHO_START();
  40. SERIAL_ECHOLNPAIR(STR_PROBE_OFFSET " " STR_Z, probe.offset.z);
  41. }
  42. else {
  43. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  44. hotend_offset[active_extruder].z -= offs;
  45. SERIAL_ECHO_START();
  46. SERIAL_ECHOLNPAIR(STR_PROBE_OFFSET STR_Z ": ", hotend_offset[active_extruder].z);
  47. #endif
  48. }
  49. }
  50. #endif
  51. /**
  52. * M290: Babystepping
  53. *
  54. * Send 'R' or no parameters for a report.
  55. *
  56. * X<linear> - Distance to step X
  57. * Y<linear> - Distance to step Y
  58. * Z<linear> - Distance to step Z
  59. * S<linear> - Distance to step Z (alias for Z)
  60. *
  61. * With BABYSTEP_ZPROBE_OFFSET:
  62. * P0 - Don't adjust the Z probe offset
  63. */
  64. void GcodeSuite::M290() {
  65. #if ENABLED(BABYSTEP_XY)
  66. LOOP_XYZ(a)
  67. if (parser.seenval(XYZ_CHAR(a)) || (a == Z_AXIS && parser.seenval('S'))) {
  68. const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
  69. babystep.add_mm((AxisEnum)a, offs);
  70. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  71. if (a == Z_AXIS && (!parser.seen('P') || parser.value_bool())) mod_probe_offset(offs);
  72. #endif
  73. }
  74. #else
  75. if (parser.seenval('Z') || parser.seenval('S')) {
  76. const float offs = constrain(parser.value_axis_units(Z_AXIS), -2, 2);
  77. babystep.add_mm(Z_AXIS, offs);
  78. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  79. if (!parser.seen('P') || parser.value_bool()) mod_probe_offset(offs);
  80. #endif
  81. }
  82. #endif
  83. if (!parser.seen("XYZ") || parser.seen('R')) {
  84. SERIAL_ECHO_START();
  85. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  86. SERIAL_ECHOLNPAIR(STR_PROBE_OFFSET " " STR_Z, probe.offset.z);
  87. #endif
  88. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  89. {
  90. SERIAL_ECHOLNPAIR_P(
  91. PSTR("Hotend "), int(active_extruder)
  92. #if ENABLED(BABYSTEP_XY)
  93. , PSTR("Offset X"), hotend_offset[active_extruder].x
  94. , SP_Y_STR, hotend_offset[active_extruder].y
  95. , SP_Z_STR
  96. #else
  97. , PSTR("Offset Z")
  98. #endif
  99. , hotend_offset[active_extruder].z
  100. );
  101. }
  102. #endif
  103. #if ENABLED(MESH_BED_LEVELING)
  104. SERIAL_ECHOLNPAIR("MBL Adjust Z", mbl.z_offset);
  105. #endif
  106. #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
  107. {
  108. SERIAL_ECHOLNPAIR_P(
  109. #if ENABLED(BABYSTEP_XY)
  110. PSTR("Babystep X"), babystep.axis_total[X_AXIS]
  111. , SP_Y_STR, babystep.axis_total[Y_AXIS]
  112. , SP_Z_STR
  113. #else
  114. PSTR("Babystep Z")
  115. #endif
  116. , babystep.axis_total[BS_TOTAL_IND(Z_AXIS)]
  117. );
  118. }
  119. #endif
  120. }
  121. }
  122. #endif // BABYSTEPPING