Skip to content

Commit

Permalink
Fix G12 for SINGLENOZZLE (MarlinFirmware#17540)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
2 people authored and HairingX committed Jun 16, 2021
1 parent f73617e commit 9799aa0
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions Marlin/src/libs/nozzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,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

0 comments on commit 9799aa0

Please sign in to comment.