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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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 "../../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(BABYSTEP_ZPROBE_OFFSET)
  33. FORCE_INLINE void mod_zprobe_zoffset(const float &offs) {
  34. if (true
  35. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  36. && active_extruder == 0
  37. #endif
  38. ) {
  39. zprobe_offset[Z_AXIS] += offs;
  40. SERIAL_ECHO_START();
  41. SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET MSG_Z ": ", zprobe_offset[Z_AXIS]);
  42. }
  43. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  44. else {
  45. hotend_offset[Z_AXIS][active_extruder] -= offs;
  46. SERIAL_ECHO_START();
  47. SERIAL_ECHOLNPAIR(MSG_Z_OFFSET ": ", hotend_offset[Z_AXIS][active_extruder]);
  48. }
  49. #endif
  50. }
  51. #endif
  52. /**
  53. * M290: Babystepping
  54. *
  55. * X<linear> - Distance to step X
  56. * Y<linear> - Distance to step Y
  57. * Z<linear> - Distance to step Z
  58. * S<linear> - Distance to step Z (alias for Z)
  59. *
  60. * With BABYSTEP_ZPROBE_OFFSET:
  61. * P0 - Don't adjust the Z probe offset.
  62. */
  63. void GcodeSuite::M290() {
  64. #if ENABLED(BABYSTEP_XY)
  65. for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
  66. if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
  67. const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
  68. babystep.add_mm((AxisEnum)a, offs);
  69. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  70. if (a == Z_AXIS && (!parser.seen('P') || parser.value_bool())) mod_zprobe_zoffset(offs);
  71. #endif
  72. }
  73. #else
  74. if (parser.seenval('Z') || parser.seenval('S')) {
  75. const float offs = constrain(parser.value_axis_units(Z_AXIS), -2, 2);
  76. babystep.add_mm(Z_AXIS, offs);
  77. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  78. if (!parser.seen('P') || parser.value_bool()) mod_zprobe_zoffset(offs);
  79. #endif
  80. }
  81. #endif
  82. }
  83. #endif // BABYSTEPPING