Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: G12 not working as expected since #25666 #25766

Merged
merged 6 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2408,9 +2408,7 @@
// Default pattern to use when 'P' is not provided to G12. One of the enabled options above.
#define NOZZLE_CLEAN_DEFAULT_PATTERN 0

#if ENABLED(NOZZLE_CLEAN_PATTERN_LINE)
#define NOZZLE_CLEAN_STROKES 12 // Default number of pattern repetitions
#endif
#define NOZZLE_CLEAN_STROKES 12 // Default number of pattern repetitions

#if ENABLED(NOZZLE_CLEAN_PATTERN_ZIGZAG)
#define NOZZLE_CLEAN_TRIANGLES 3 // Default number of triangles
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/clean/G12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void GcodeSuite::G12() {
NOZZLE_CLEAN_DEFAULT_PATTERN
#endif
);
const uint8_t strokes = TERN0(NOZZLE_CLEAN_PATTERN_LINE, parser.ushortval('S', NOZZLE_CLEAN_STROKES)),
const uint8_t strokes = parser.ushortval('S', NOZZLE_CLEAN_STROKES),
objects = TERN0(NOZZLE_CLEAN_PATTERN_ZIGZAG, parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES));
const float radius = TERN0(NOZZLE_CLEAN_PATTERN_CIRCLE, parser.linearval('R', NOZZLE_CLEAN_CIRCLE_RADIUS));

Expand Down
13 changes: 6 additions & 7 deletions Marlin/src/libs/nozzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Nozzle nozzle;
* @param end xyz_pos_t defining the ending point
* @param strokes number of strokes to execute
*/
void Nozzle::stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes) {
void Nozzle::stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t strokes) {
#if ENABLED(NOZZLE_CLEAN_GOBACK)
const xyz_pos_t oldpos = current_position;
#endif
Expand Down Expand Up @@ -87,7 +87,7 @@ Nozzle nozzle;
* @param strokes number of strokes to execute
* @param objects number of triangles to do
*/
void Nozzle::zigzag(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes, const uint8_t &objects) {
void Nozzle::zigzag(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t strokes, const uint8_t objects) {
const xy_pos_t diff = end - start;
if (!diff.x || !diff.y) return;

Expand Down Expand Up @@ -135,7 +135,7 @@ Nozzle nozzle;
* @param strokes number of strokes to execute
* @param radius radius of circle
*/
void Nozzle::circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const_float_t radius) {
void Nozzle::circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t strokes, const_float_t radius) {
if (strokes == 0) return;

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

switch (pattern) {
default:
switch (pattern) { // no default clause as pattern is already validated
#if ENABLED(NOZZLE_CLEAN_PATTERN_LINE)
case 0: stroke(start[arrPos], end[arrPos], strokes);
case 0: stroke(start[arrPos], end[arrPos], strokes); break;
#endif
#if ENABLED(NOZZLE_CLEAN_PATTERN_ZIGZAG)
case 1: zigzag(start[arrPos], end[arrPos], strokes, objects); break;
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/libs/nozzle.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Nozzle {
* @param end xyz_pos_t defining the ending point
* @param strokes number of strokes to execute
*/
static void stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes) __Os;
static void stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t strokes) __Os;

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

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

#endif // NOZZLE_CLEAN_FEATURE

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

#endif // NOZZLE_CLEAN_FEATURE

Expand Down