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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 - Auto Bed Leveling
  24. */
  25. #include "../../../inc/MarlinConfig.h"
  26. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  27. #include "../../gcode.h"
  28. #include "../../../feature/bedlevel/bedlevel.h"
  29. #if ENABLED(EXTENSIBLE_UI)
  30. #include "../../../lcd/extensible_ui/ui_api.h"
  31. #endif
  32. /**
  33. * M421: Set a single Mesh Bed Leveling Z coordinate
  34. *
  35. * Usage:
  36. * M421 I<xindex> J<yindex> Z<linear>
  37. * M421 I<xindex> J<yindex> Q<offset>
  38. */
  39. void GcodeSuite::M421() {
  40. int8_t ix = parser.intval('I', -1), iy = parser.intval('J', -1);
  41. const bool hasI = ix >= 0,
  42. hasJ = iy >= 0,
  43. hasZ = parser.seen('Z'),
  44. hasQ = !hasZ && parser.seen('Q');
  45. if (!hasI || !hasJ || !(hasZ || hasQ))
  46. SERIAL_ERROR_MSG(STR_ERR_M421_PARAMETERS);
  47. else if (!WITHIN(ix, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))
  48. SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
  49. else {
  50. z_values[ix][iy] = parser.value_linear_units() + (hasQ ? z_values[ix][iy] : 0);
  51. #if ENABLED(ABL_BILINEAR_SUBDIVISION)
  52. bed_level_virt_interpolate();
  53. #endif
  54. #if ENABLED(EXTENSIBLE_UI)
  55. ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]);
  56. #endif
  57. }
  58. }
  59. #endif // AUTO_BED_LEVELING_BILINEAR