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.

M218.cpp 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 HAS_HOTEND_OFFSET
  24. #include "../gcode.h"
  25. #include "../../module/motion.h"
  26. #if ENABLED(DELTA)
  27. #include "../../module/planner.h"
  28. #endif
  29. /**
  30. * M218 - set hotend offset (in linear units)
  31. *
  32. * T<tool>
  33. * X<xoffset>
  34. * Y<yoffset>
  35. * Z<zoffset>
  36. */
  37. void GcodeSuite::M218() {
  38. if (!parser.seen_any()) return M218_report();
  39. const int8_t target_extruder = get_target_extruder_from_command();
  40. if (target_extruder < 0) return;
  41. if (parser.seenval('X')) hotend_offset[target_extruder].x = parser.value_linear_units();
  42. if (parser.seenval('Y')) hotend_offset[target_extruder].y = parser.value_linear_units();
  43. if (parser.seenval('Z')) hotend_offset[target_extruder].z = parser.value_linear_units();
  44. #if ENABLED(DELTA)
  45. if (target_extruder == active_extruder)
  46. do_blocking_move_to_xy(current_position, planner.settings.max_feedrate_mm_s[X_AXIS]);
  47. #endif
  48. }
  49. void GcodeSuite::M218_report(const bool forReplay/*=true*/) {
  50. report_heading_etc(forReplay, PSTR(STR_HOTEND_OFFSETS));
  51. LOOP_S_L_N(e, 1, HOTENDS) {
  52. report_echo_start(forReplay);
  53. SERIAL_ECHOPGM_P(
  54. PSTR(" M218 T"), e,
  55. SP_X_STR, LINEAR_UNIT(hotend_offset[e].x),
  56. SP_Y_STR, LINEAR_UNIT(hotend_offset[e].y)
  57. );
  58. SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(hotend_offset[e].z), 3);
  59. }
  60. }
  61. #endif // HAS_HOTEND_OFFSET