Skip to content

Commit df4f806

Browse files
plampixthinkyhead
andauthored
✨ NOZZLE_CLEAN_PATTERN_* (MarlinFirmware#25666)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent 9902097 commit df4f806

File tree

5 files changed

+194
-142
lines changed

5 files changed

+194
-142
lines changed

Marlin/Configuration.h

+18-10
Original file line numberDiff line numberDiff line change
@@ -2409,23 +2409,31 @@
24092409
//#define NOZZLE_CLEAN_FEATURE
24102410

24112411
#if ENABLED(NOZZLE_CLEAN_FEATURE)
2412-
// Default number of pattern repetitions
2413-
#define NOZZLE_CLEAN_STROKES 12
2412+
#define NOZZLE_CLEAN_PATTERN_LINE // Provide 'G12 P0' - a simple linear cleaning pattern
2413+
#define NOZZLE_CLEAN_PATTERN_ZIGZAG // Provide 'G12 P1' - a zigzag cleaning pattern
2414+
#define NOZZLE_CLEAN_PATTERN_CIRCLE // Provide 'G12 P2' - a circular cleaning pattern
24142415

2415-
// Default number of triangles
2416-
#define NOZZLE_CLEAN_TRIANGLES 3
2416+
// Default pattern to use when 'P' is not provided to G12. One of the enabled options above.
2417+
#define NOZZLE_CLEAN_DEFAULT_PATTERN 0
2418+
2419+
#if ENABLED(NOZZLE_CLEAN_PATTERN_LINE)
2420+
#define NOZZLE_CLEAN_STROKES 12 // Default number of pattern repetitions
2421+
#endif
2422+
2423+
#if ENABLED(NOZZLE_CLEAN_PATTERN_ZIGZAG)
2424+
#define NOZZLE_CLEAN_TRIANGLES 3 // Default number of triangles
2425+
#endif
24172426

24182427
// Specify positions for each tool as { { X, Y, Z }, { X, Y, Z } }
24192428
// Dual hotend system may use { { -20, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { 420, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }}
24202429
#define NOZZLE_CLEAN_START_POINT { { 30, 30, (Z_MIN_POS + 1) } }
24212430
#define NOZZLE_CLEAN_END_POINT { { 100, 60, (Z_MIN_POS + 1) } }
24222431

2423-
// Circular pattern radius
2424-
#define NOZZLE_CLEAN_CIRCLE_RADIUS 6.5
2425-
// Circular pattern circle fragments number
2426-
#define NOZZLE_CLEAN_CIRCLE_FN 10
2427-
// Middle point of circle
2428-
#define NOZZLE_CLEAN_CIRCLE_MIDDLE NOZZLE_CLEAN_START_POINT
2432+
#if ENABLED(NOZZLE_CLEAN_PATTERN_CIRCLE)
2433+
#define NOZZLE_CLEAN_CIRCLE_RADIUS 6.5 // (mm) Circular pattern radius
2434+
#define NOZZLE_CLEAN_CIRCLE_FN 10 // Circular pattern circle number of segments
2435+
#define NOZZLE_CLEAN_CIRCLE_MIDDLE NOZZLE_CLEAN_START_POINT // Middle point of circle
2436+
#endif
24292437

24302438
// Move the nozzle to the initial position after cleaning
24312439
#define NOZZLE_CLEAN_GOBACK

Marlin/src/gcode/feature/clean/G12.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ void GcodeSuite::G12() {
5757
}
5858
#endif
5959

60-
const uint8_t pattern = parser.ushortval('P', 0),
61-
strokes = parser.ushortval('S', NOZZLE_CLEAN_STROKES),
62-
objects = parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES);
63-
const float radius = parser.linearval('R', NOZZLE_CLEAN_CIRCLE_RADIUS);
60+
const uint8_t pattern = (
61+
#if COUNT_ENABLED(NOZZLE_CLEAN_PATTERN_LINE, NOZZLE_CLEAN_PATTERN_ZIGZAG, NOZZLE_CLEAN_PATTERN_CIRCLE) > 1
62+
parser.ushortval('P', NOZZLE_CLEAN_DEFAULT_PATTERN)
63+
#else
64+
NOZZLE_CLEAN_DEFAULT_PATTERN
65+
#endif
66+
);
67+
const uint8_t strokes = TERN0(NOZZLE_CLEAN_PATTERN_LINEAR, parser.ushortval('S', NOZZLE_CLEAN_STROKES)),
68+
objects = TERN0(NOZZLE_CLEAN_PATTERN_ZIGZAG, parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES));
69+
const float radius = TERN0(NOZZLE_CLEAN_PATTERN_CIRCLE, parser.linearval('R', NOZZLE_CLEAN_CIRCLE_RADIUS));
6470

6571
const bool seenxyz = parser.seen("XYZ");
6672
const uint8_t cleans = (!seenxyz || parser.boolval('X') ? _BV(X_AXIS) : 0)

Marlin/src/inc/SanityCheck.h

+15
Original file line numberDiff line numberDiff line change
@@ -3816,6 +3816,21 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
38163816
#undef _CLEAN_ASSERT
38173817
#endif
38183818

3819+
/**
3820+
* Sanity check nozzle cleaning pattern settings
3821+
*/
3822+
#if ENABLED(NOZZLE_CLEAN_FEATURE)
3823+
#if NONE(NOZZLE_CLEAN_PATTERN_LINE, NOZZLE_CLEAN_PATTERN_ZIGZAG, NOZZLE_CLEAN_PATTERN_CIRCLE)
3824+
#error "NOZZLE_CLEAN_FEATURE requires at least one of NOZZLE_CLEAN_PATTERN_LINE, NOZZLE_CLEAN_PATTERN_ZIGZAG, and/or NOZZLE_CLEAN_PATTERN_CIRCLE."
3825+
#elif NOZZLE_CLEAN_DEFAULT_PATTERN == 0 && DISABLED(NOZZLE_CLEAN_PATTERN_LINE)
3826+
#error "NOZZLE_CLEAN_DEFAULT_PATTERN 0 (LINE) is not available. Enable NOZZLE_CLEAN_PATTERN_LINE or set a different NOZZLE_CLEAN_DEFAULT_PATTERN."
3827+
#elif NOZZLE_CLEAN_DEFAULT_PATTERN == 1 && DISABLED(NOZZLE_CLEAN_PATTERN_ZIGZAG)
3828+
#error "NOZZLE_CLEAN_DEFAULT_PATTERN 1 (ZIGZAG) is not available. Enable NOZZLE_CLEAN_PATTERN_ZIGZAG or set a different NOZZLE_CLEAN_DEFAULT_PATTERN."
3829+
#elif NOZZLE_CLEAN_DEFAULT_PATTERN == 2 && DISABLED(NOZZLE_CLEAN_PATTERN_CIRCLE)
3830+
#error "NOZZLE_CLEAN_DEFAULT_PATTERN 2 (CIRCLE) is not available. Enable NOZZLE_CLEAN_PATTERN_CIRCLE or set a different NOZZLE_CLEAN_DEFAULT_PATTERN."
3831+
#endif
3832+
#endif
3833+
38193834
/**
38203835
* Sanity check for MIXING_EXTRUDER & DISTINCT_E_FACTORS these are not compatible
38213836
*/

0 commit comments

Comments
 (0)