My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

G42.cpp 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <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(STR_ERR_MESH_XY);
  40. return;
  41. }
  42. // Move to current_position, as modified by I, J, P parameters
  43. destination = current_position;
  44. if (hasI) destination.x = _GET_MESH_X(ix);
  45. if (hasJ) destination.y = _GET_MESH_Y(iy);
  46. #if HAS_PROBE_XY_OFFSET
  47. if (parser.boolval('P')) {
  48. if (hasI) destination.x -= probe.offset_xy.x;
  49. if (hasJ) destination.y -= probe.offset_xy.y;
  50. }
  51. #endif
  52. const feedRate_t fval = parser.linearval('F'),
  53. fr_mm_s = MMM_TO_MMS(fval > 0 ? fval : 0.0f);
  54. // SCARA kinematic has "safe" XY raw moves
  55. #if IS_SCARA
  56. prepare_internal_fast_move_to_destination(fr_mm_s);
  57. #else
  58. prepare_internal_move_to_destination(fr_mm_s);
  59. #endif
  60. }
  61. }
  62. #endif // HAS_MESH