Allow nozzle clean with limited Axis (#14619)

This commit is contained in:
InsanityAutomation
2019-07-14 07:58:53 -04:00
committed by Scott Lahteine
parent 6dcb85927a
commit d2f20803ba
114 changed files with 483 additions and 122 deletions

View File

@ -1522,8 +1522,11 @@
// Middle point of circle
#define NOZZLE_CLEAN_CIRCLE_MIDDLE NOZZLE_CLEAN_START_POINT
// Moves the nozzle to the initial position
// Move the nozzle to the initial position after cleaning
#define NOZZLE_CLEAN_GOBACK
// Enable for a purge/clean station that's always at the gantry height (thus no Z move)
//#define NOZZLE_CLEAN_NO_Z
#endif
/**

View File

@ -42,6 +42,16 @@ void GcodeSuite::G12() {
// Don't allow nozzle cleaning without homing first
if (axis_unhomed_error()) return;
const bool seenxyz = parser.seen("XYZ"),
clean_x = !seenxyz || parser.boolval('X'),
clean_y = !seenxyz || parser.boolval('Y');
#if ENABLED(NOZZLE_CLEAN_NO_Z)
static constexpr bool clean_z = false;
#else
const bool clean_z = !seenxyz || parser.boolval('Z');
#endif
const uint8_t pattern = parser.ushortval('P', 0),
strokes = parser.ushortval('S', NOZZLE_CLEAN_STROKES),
objects = parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES);
@ -49,14 +59,14 @@ void GcodeSuite::G12() {
#if HAS_LEVELING
const bool was_enabled = planner.leveling_active;
set_bed_leveling_enabled(false);
if (clean_z) set_bed_leveling_enabled(false);
#endif
Nozzle::clean(pattern, strokes, radius, objects);
Nozzle::clean(pattern, strokes, radius, objects, clean_x, clean_y, clean_z);
// Re-enable bed level correction if it had been on
#if HAS_LEVELING
set_bed_leveling_enabled(was_enabled);
if (clean_z) set_bed_leveling_enabled(was_enabled);
#endif
}

View File

@ -46,7 +46,11 @@
#endif
// Move to the starting point
do_blocking_move_to(start.x, start.y, start.z);
#if ENABLED(NOZZLE_CLEAN_NO_Z)
do_blocking_move_to_xy(start.x, start.y);
#else
do_blocking_move_to(start.x, start.y, start.z);
#endif
// Start the stroke pattern
for (uint8_t i = 0; i < (strokes >> 1); i++) {
@ -76,7 +80,11 @@
const float ix = current_position[X_AXIS], iy = current_position[Y_AXIS], iz = current_position[Z_AXIS];
#endif
do_blocking_move_to(start.x, start.y, start.z);
#if ENABLED(NOZZLE_CLEAN_NO_Z)
do_blocking_move_to_xy(start.x, start.y);
#else
do_blocking_move_to(start.x, start.y, start.z);
#endif
const uint8_t zigs = objects << 1;
const bool horiz = ABS(diffx) >= ABS(diffy); // Do a horizontal wipe?
@ -119,7 +127,11 @@
const float ix = current_position[X_AXIS], iy = current_position[Y_AXIS], iz = current_position[Z_AXIS];
#endif
do_blocking_move_to(start.x, start.y, start.z);
#if ENABLED(NOZZLE_CLEAN_NO_Z)
do_blocking_move_to_xy(start.x, start.y);
#else
do_blocking_move_to(start.x, start.y, start.z);
#endif
for (uint8_t s = 0; s < strokes; s++)
for (uint8_t i = 0; i < NOZZLE_CLEAN_CIRCLE_FN; i++)
@ -143,7 +155,13 @@
* @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 &radius, const uint8_t &objects/*=0*/) {
void Nozzle::clean(const uint8_t &pattern, const uint8_t &strokes, const float &radius, const uint8_t &objects, const bool clean_x, const bool clean_y, const bool clean_z) {
point_t start = NOZZLE_CLEAN_START_POINT;
point_t end = NOZZLE_CLEAN_END_POINT;
if (!clean_x) start.x = end.x = current_position[X_AXIS];
if (!clean_y) start.y = end.y = current_position[Y_AXIS];
if (!clean_z) start.z = end.z = current_position[Z_AXIS];
switch (pattern) {
case 1:
zigzag(NOZZLE_CLEAN_START_POINT, NOZZLE_CLEAN_END_POINT, strokes, objects);
@ -162,9 +180,9 @@
#if ENABLED(NOZZLE_PARK_FEATURE)
void Nozzle::park(const uint8_t z_action, const point_t &park /*= NOZZLE_PARK_POINT*/) {
const float fr_xy = NOZZLE_PARK_XY_FEEDRATE;
const float fr_z = NOZZLE_PARK_Z_FEEDRATE;
void Nozzle::park(const uint8_t z_action, const point_t &park/*=NOZZLE_PARK_POINT*/) {
const float fr_xy = NOZZLE_PARK_XY_FEEDRATE,
fr_z = NOZZLE_PARK_Z_FEEDRATE;
switch (z_action) {
case 1: // Go to Z-park height

View File

@ -78,7 +78,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 &radius, const uint8_t &objects=0) _Os;
static void clean(const uint8_t &pattern, const uint8_t &strokes, const float &radius, const uint8_t &objects, const bool clean_x, const bool clean_y, const bool clean_z) _Os;
#endif // NOZZLE_CLEAN_FEATURE