Skip to content

Commit 9aa69cb

Browse files
authored
Fix G12 Nozzle Clean (MarlinFirmware#25766)
Followup to MarlinFirmware#25666
1 parent 61f0dd2 commit 9aa69cb

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

Marlin/Configuration.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -2408,9 +2408,7 @@
24082408
// Default pattern to use when 'P' is not provided to G12. One of the enabled options above.
24092409
#define NOZZLE_CLEAN_DEFAULT_PATTERN 0
24102410

2411-
#if ENABLED(NOZZLE_CLEAN_PATTERN_LINE)
2412-
#define NOZZLE_CLEAN_STROKES 12 // Default number of pattern repetitions
2413-
#endif
2411+
#define NOZZLE_CLEAN_STROKES 12 // Default number of pattern repetitions
24142412

24152413
#if ENABLED(NOZZLE_CLEAN_PATTERN_ZIGZAG)
24162414
#define NOZZLE_CLEAN_TRIANGLES 3 // Default number of triangles

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void GcodeSuite::G12() {
6464
NOZZLE_CLEAN_DEFAULT_PATTERN
6565
#endif
6666
);
67-
const uint8_t strokes = TERN0(NOZZLE_CLEAN_PATTERN_LINE, parser.ushortval('S', NOZZLE_CLEAN_STROKES)),
67+
const uint8_t strokes = parser.ushortval('S', NOZZLE_CLEAN_STROKES),
6868
objects = TERN0(NOZZLE_CLEAN_PATTERN_ZIGZAG, parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES));
6969
const float radius = TERN0(NOZZLE_CLEAN_PATTERN_CIRCLE, parser.linearval('R', NOZZLE_CLEAN_CIRCLE_RADIUS));
7070

Marlin/src/libs/nozzle.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Nozzle nozzle;
4646
* @param end xyz_pos_t defining the ending point
4747
* @param strokes number of strokes to execute
4848
*/
49-
void Nozzle::stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes) {
49+
void Nozzle::stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t strokes) {
5050
#if ENABLED(NOZZLE_CLEAN_GOBACK)
5151
const xyz_pos_t oldpos = current_position;
5252
#endif
@@ -87,7 +87,7 @@ Nozzle nozzle;
8787
* @param strokes number of strokes to execute
8888
* @param objects number of triangles to do
8989
*/
90-
void Nozzle::zigzag(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes, const uint8_t &objects) {
90+
void Nozzle::zigzag(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t strokes, const uint8_t objects) {
9191
const xy_pos_t diff = end - start;
9292
if (!diff.x || !diff.y) return;
9393

@@ -135,7 +135,7 @@ Nozzle nozzle;
135135
* @param strokes number of strokes to execute
136136
* @param radius radius of circle
137137
*/
138-
void Nozzle::circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const_float_t radius) {
138+
void Nozzle::circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t strokes, const_float_t radius) {
139139
if (strokes == 0) return;
140140

141141
#if ENABLED(NOZZLE_CLEAN_GOBACK)
@@ -164,7 +164,7 @@ Nozzle nozzle;
164164
* @param pattern one of the available patterns
165165
* @param argument depends on the cleaning pattern
166166
*/
167-
void Nozzle::clean(const uint8_t &pattern, const uint8_t &strokes, const_float_t radius, const uint8_t &objects, const uint8_t cleans) {
167+
void Nozzle::clean(const uint8_t pattern, const uint8_t strokes, const_float_t radius, const uint8_t objects, const uint8_t cleans) {
168168
xyz_pos_t start[HOTENDS] = NOZZLE_CLEAN_START_POINT, end[HOTENDS] = NOZZLE_CLEAN_END_POINT;
169169
#if ENABLED(NOZZLE_CLEAN_PATTERN_CIRCLE)
170170
xyz_pos_t middle[HOTENDS] = NOZZLE_CLEAN_CIRCLE_MIDDLE;
@@ -230,10 +230,9 @@ Nozzle nozzle;
230230
}
231231
if (!TEST(cleans, Z_AXIS)) start[arrPos].z = end[arrPos].z = current_position.z;
232232

233-
switch (pattern) {
234-
default:
233+
switch (pattern) { // no default clause as pattern is already validated
235234
#if ENABLED(NOZZLE_CLEAN_PATTERN_LINE)
236-
case 0: stroke(start[arrPos], end[arrPos], strokes);
235+
case 0: stroke(start[arrPos], end[arrPos], strokes); break;
237236
#endif
238237
#if ENABLED(NOZZLE_CLEAN_PATTERN_ZIGZAG)
239238
case 1: zigzag(start[arrPos], end[arrPos], strokes, objects); break;

Marlin/src/libs/nozzle.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Nozzle {
4141
* @param end xyz_pos_t defining the ending point
4242
* @param strokes number of strokes to execute
4343
*/
44-
static void stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes) __Os;
44+
static void stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t strokes) __Os;
4545

4646
/**
4747
* @brief Zig-zag clean pattern
@@ -52,7 +52,7 @@ class Nozzle {
5252
* @param strokes number of strokes to execute
5353
* @param objects number of objects to create
5454
*/
55-
static void zigzag(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes, const uint8_t &objects) __Os;
55+
static void zigzag(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t strokes, const uint8_t objects) __Os;
5656

5757
/**
5858
* @brief Circular clean pattern
@@ -62,7 +62,7 @@ class Nozzle {
6262
* @param strokes number of strokes to execute
6363
* @param radius radius of circle
6464
*/
65-
static void circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const_float_t radius) __Os;
65+
static void circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t strokes, const_float_t radius) __Os;
6666

6767
#endif // NOZZLE_CLEAN_FEATURE
6868

@@ -77,7 +77,7 @@ class Nozzle {
7777
* @param pattern one of the available patterns
7878
* @param argument depends on the cleaning pattern
7979
*/
80-
static void clean(const uint8_t &pattern, const uint8_t &strokes, const_float_t radius, const uint8_t &objects, const uint8_t cleans) __Os;
80+
static void clean(const uint8_t pattern, const uint8_t strokes, const_float_t radius, const uint8_t objects, const uint8_t cleans) __Os;
8181

8282
#endif // NOZZLE_CLEAN_FEATURE
8383

0 commit comments

Comments
 (0)