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

Fix g12 for single nozzle #17540

11 changes: 8 additions & 3 deletions Marlin/src/gcode/calibrate/M100.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,18 @@
// Utility functions
//

// Location of a variable on its stack frame. Returns a value above
// the stack (once the function returns to the caller).
char* top_of_stack() {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreturn-local-addr"

// Location of a variable in its stack frame.
// The returned address will be above the stack (after it returns).
char *top_of_stack() {
char x;
return &x + 1; // x is pulled on return;
}

#pragma GCC diagnostic pop

// Count the number of test bytes at the specified location.
inline int32_t count_test_bytes(const char * const start_free_memory) {
for (uint32_t i = 0; i < 32000; i++)
Expand Down
40 changes: 33 additions & 7 deletions Marlin/src/libs/nozzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,48 @@ Nozzle nozzle;
void Nozzle::clean(const uint8_t &pattern, const uint8_t &strokes, const float &radius, const uint8_t &objects, const uint8_t cleans) {
xyz_pos_t start[HOTENDS] = NOZZLE_CLEAN_START_POINT, end[HOTENDS] = NOZZLE_CLEAN_END_POINT, middle[HOTENDS] = NOZZLE_CLEAN_CIRCLE_MIDDLE;

const uint8_t arrPos = ANY(SINGLENOZZLE, MIXING_EXTRUDER) ? 0 : active_extruder;

#if HAS_SOFTWARE_ENDSTOPS

#define LIMIT_AXIS(A) do{ \
LIMIT( start[arrPos].A, soft_endstop.min.A, soft_endstop.max.A); \
LIMIT(middle[arrPos].A, soft_endstop.min.A, soft_endstop.max.A); \
LIMIT( end[arrPos].A, soft_endstop.min.A, soft_endstop.max.A); \
}while(0)

LIMIT_AXIS(x);
LIMIT_AXIS(y);
LIMIT_AXIS(z);

const bool radiusOutOfRange = (middle[arrPos].x + radius > soft_endstop.max.x)
|| (middle[arrPos].x - radius < soft_endstop.min.x)
|| (middle[arrPos].y + radius > soft_endstop.max.y)
|| (middle[arrPos].y - radius < soft_endstop.min.y);

if (radiusOutOfRange && pattern == 2) {
SERIAL_ECHOLNPGM("Warning: Radius Out of Range");
return;
}

#endif

if (pattern == 2) {
if (!(cleans & (_BV(X_AXIS) | _BV(Y_AXIS)))) {
SERIAL_ECHOLNPGM("Warning : Clean Circle requires XY");
SERIAL_ECHOLNPGM("Warning: Clean Circle requires XY");
return;
}
}
else {
if (!TEST(cleans, X_AXIS)) start[active_extruder].x = end[active_extruder].x = current_position.x;
if (!TEST(cleans, Y_AXIS)) start[active_extruder].y = end[active_extruder].y = current_position.y;
if (!TEST(cleans, X_AXIS)) start[arrPos].x = end[arrPos].x = current_position.x;
if (!TEST(cleans, Y_AXIS)) start[arrPos].y = end[arrPos].y = current_position.y;
}
if (!TEST(cleans, Z_AXIS)) start[active_extruder].z = end[active_extruder].z = current_position.z;
if (!TEST(cleans, Z_AXIS)) start[arrPos].z = end[arrPos].z = current_position.z;

switch (pattern) {
case 1: zigzag(start[active_extruder], end[active_extruder], strokes, objects); break;
case 2: circle(start[active_extruder], middle[active_extruder], strokes, radius); break;
default: stroke(start[active_extruder], end[active_extruder], strokes);
case 1: zigzag(start[arrPos], end[arrPos], strokes, objects); break;
case 2: circle(start[arrPos], middle[arrPos], strokes, radius); break;
default: stroke(start[arrPos], end[arrPos], strokes);
}
}

Expand Down