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.

M421.cpp 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /**
  23. * M421.cpp - Mesh Bed Leveling
  24. */
  25. #include "../../../inc/MarlinConfig.h"
  26. #if ENABLED(MESH_BED_LEVELING)
  27. #include "../../gcode.h"
  28. #include "../../../module/motion.h"
  29. #include "../../../feature/bedlevel/mbl/mesh_bed_leveling.h"
  30. /**
  31. * M421: Set a single Mesh Bed Leveling Z coordinate
  32. *
  33. * Usage:
  34. * M421 X<linear> Y<linear> Z<linear>
  35. * M421 X<linear> Y<linear> Q<offset>
  36. * M421 I<xindex> J<yindex> Z<linear>
  37. * M421 I<xindex> J<yindex> Q<offset>
  38. */
  39. void GcodeSuite::M421() {
  40. const bool hasX = parser.seen('X'), hasI = parser.seen('I');
  41. const int8_t ix = hasI ? parser.value_int() : hasX ? mbl.probe_index_x(RAW_X_POSITION(parser.value_linear_units())) : -1;
  42. const bool hasY = parser.seen('Y'), hasJ = parser.seen('J');
  43. const int8_t iy = hasJ ? parser.value_int() : hasY ? mbl.probe_index_y(RAW_Y_POSITION(parser.value_linear_units())) : -1;
  44. const bool hasZ = parser.seen('Z'), hasQ = !hasZ && parser.seen('Q');
  45. if (int(hasI && hasJ) + int(hasX && hasY) != 1 || !(hasZ || hasQ))
  46. SERIAL_ERROR_MSG(STR_ERR_M421_PARAMETERS);
  47. else if (ix < 0 || iy < 0)
  48. SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
  49. else
  50. mbl.set_z(ix, iy, parser.value_linear_units() + (hasQ ? mbl.z_values[ix][iy] : 0));
  51. }
  52. #endif // MESH_BED_LEVELING