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

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