My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

M421.cpp 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. * unified.cpp - Unified Bed Leveling
  24. */
  25. #include "../../../inc/MarlinConfig.h"
  26. #if ENABLED(AUTO_BED_LEVELING_UBL)
  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. * M421 I<xindex> J<yindex> N
  39. * M421 C Z<linear>
  40. * M421 C Q<offset>
  41. */
  42. void GcodeSuite::M421() {
  43. xy_int8_t ij = { int8_t(parser.intval('I', -1)), int8_t(parser.intval('J', -1)) };
  44. const bool hasI = ij.x >= 0,
  45. hasJ = ij.y >= 0,
  46. hasC = parser.seen('C'),
  47. hasN = parser.seen('N'),
  48. hasZ = parser.seen('Z'),
  49. hasQ = !hasZ && parser.seen('Q');
  50. if (hasC) ij = ubl.find_closest_mesh_point_of_type(REAL, current_position);
  51. if (int(hasC) + int(hasI && hasJ) != 1 || !(hasZ || hasQ || hasN))
  52. SERIAL_ERROR_MSG(STR_ERR_M421_PARAMETERS);
  53. else if (!WITHIN(ij.x, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(ij.y, 0, GRID_MAX_POINTS_Y - 1))
  54. SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
  55. else {
  56. float &zval = ubl.z_values[ij.x][ij.y];
  57. zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0);
  58. #if ENABLED(EXTENSIBLE_UI)
  59. ExtUI::onMeshUpdate(ij.x, ij.y, zval);
  60. #endif
  61. }
  62. }
  63. #endif // AUTO_BED_LEVELING_UBL