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

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