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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  42. #define _GET_MESH_X(I) bilinear_start[X_AXIS] + I * bilinear_grid_spacing[X_AXIS]
  43. #define _GET_MESH_Y(J) bilinear_start[Y_AXIS] + J * bilinear_grid_spacing[Y_AXIS]
  44. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  45. #define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I)
  46. #define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J)
  47. #elif ENABLED(MESH_BED_LEVELING)
  48. #define _GET_MESH_X(I) mbl.index_to_xpos[I]
  49. #define _GET_MESH_Y(J) mbl.index_to_ypos[J]
  50. #endif
  51. set_destination_to_current();
  52. if (hasI) destination[X_AXIS] = LOGICAL_X_POSITION(_GET_MESH_X(ix));
  53. if (hasJ) destination[Y_AXIS] = LOGICAL_Y_POSITION(_GET_MESH_Y(iy));
  54. if (parser.boolval('P')) {
  55. if (hasI) destination[X_AXIS] -= X_PROBE_OFFSET_FROM_EXTRUDER;
  56. if (hasJ) destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
  57. }
  58. const float fval = parser.linearval('F');
  59. if (fval > 0.0) feedrate_mm_s = MMM_TO_MMS(fval);
  60. // SCARA kinematic has "safe" XY raw moves
  61. #if IS_SCARA
  62. prepare_uninterpolated_move_to_destination();
  63. #else
  64. prepare_move_to_destination();
  65. #endif
  66. }
  67. }
  68. #endif // HAS_MESH