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.

G12.cpp 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 ENABLED(NOZZLE_CLEAN_FEATURE)
  24. #include "../../../libs/nozzle.h"
  25. #include "../../gcode.h"
  26. #include "../../parser.h"
  27. #include "../../../module/motion.h"
  28. #if HAS_LEVELING
  29. #include "../../../module/planner.h"
  30. #include "../../../feature/bedlevel/bedlevel.h"
  31. #endif
  32. /**
  33. * G12: Clean the nozzle
  34. *
  35. * E<bool> : 0=Never or 1=Always apply the "software endstop" limits
  36. * P0 S<strokes> : Stroke cleaning with S strokes
  37. * P1 Sn T<objects> : Zigzag cleaning with S repeats and T zigzags
  38. * P2 Sn R<radius> : Circle cleaning with S repeats and R radius
  39. */
  40. void GcodeSuite::G12() {
  41. // Don't allow nozzle cleaning without homing first
  42. if (axis_unhomed_error()) return;
  43. #ifdef WIPE_SEQUENCE_COMMANDS
  44. if (!parser.seen_any()) {
  45. gcode.process_subcommands_now_P(PSTR(WIPE_SEQUENCE_COMMANDS));
  46. return;
  47. }
  48. #endif
  49. const uint8_t pattern = parser.ushortval('P', 0),
  50. strokes = parser.ushortval('S', NOZZLE_CLEAN_STROKES),
  51. objects = parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES);
  52. const float radius = parser.linearval('R', NOZZLE_CLEAN_CIRCLE_RADIUS);
  53. const bool seenxyz = parser.seen("XYZ");
  54. const uint8_t cleans = (!seenxyz || parser.boolval('X') ? _BV(X_AXIS) : 0)
  55. | (!seenxyz || parser.boolval('Y') ? _BV(Y_AXIS) : 0)
  56. | TERN(NOZZLE_CLEAN_NO_Z, 0, (!seenxyz || parser.boolval('Z') ? _BV(Z_AXIS) : 0))
  57. ;
  58. #if HAS_LEVELING
  59. // Disable bed leveling if cleaning Z
  60. TEMPORARY_BED_LEVELING_STATE(!TEST(cleans, Z_AXIS) && planner.leveling_active);
  61. #endif
  62. TEMPORARY_SOFT_ENDSTOP_STATE(parser.boolval('E'));
  63. nozzle.clean(pattern, strokes, radius, objects, cleans);
  64. }
  65. #endif // NOZZLE_CLEAN_FEATURE