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.

G42.cpp 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 HAS_MESH
  24. #include "../gcode.h"
  25. #include "../../MarlinCore.h" // for IsRunning()
  26. #include "../../module/motion.h"
  27. #include "../../module/probe.h" // for probe_offset
  28. #include "../../feature/bedlevel/bedlevel.h"
  29. /**
  30. * G42: Move X & Y axes to mesh coordinates (I & J)
  31. */
  32. void GcodeSuite::G42() {
  33. if (MOTION_CONDITIONS) {
  34. const bool hasI = parser.seenval('I');
  35. const int8_t ix = hasI ? parser.value_int() : 0;
  36. const bool hasJ = parser.seenval('J');
  37. const int8_t iy = hasJ ? parser.value_int() : 0;
  38. if ((hasI && !WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) || (hasJ && !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))) {
  39. SERIAL_ECHOLNPGM(MSG_ERR_MESH_XY);
  40. return;
  41. }
  42. destination = current_position;
  43. if (hasI) destination.x = _GET_MESH_X(ix);
  44. if (hasJ) destination.y = _GET_MESH_Y(iy);
  45. #if HAS_BED_PROBE
  46. if (parser.boolval('P')) {
  47. if (hasI) destination.x -= probe_offset.x;
  48. if (hasJ) destination.y -= probe_offset.y;
  49. }
  50. #endif
  51. const feedRate_t fval = parser.linearval('F'),
  52. fr_mm_s = fval > 0 ? MMM_TO_MMS(fval) : 0.0f;
  53. // SCARA kinematic has "safe" XY raw moves
  54. #if IS_SCARA
  55. prepare_internal_fast_move_to_destination(fr_mm_s);
  56. #else
  57. prepare_internal_move_to_destination(fr_mm_s);
  58. #endif
  59. }
  60. }
  61. #endif // HAS_MESH