From 2d758663db570d8fc37255bf75c1bd3a98c333fe Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 29 Apr 2020 03:25:35 -0500 Subject: [PATCH] G12 E soft endstops parameter (#17788) --- Marlin/src/gcode/calibrate/G425.cpp | 2 -- Marlin/src/gcode/feature/clean/G12.cpp | 13 +++++++++---- Marlin/src/libs/nozzle.cpp | 22 ++++++++++++---------- Marlin/src/module/motion.h | 2 ++ 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 18b5dc56ab..b0126c44da 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -92,8 +92,6 @@ struct measurements_t { xy_float_t nozzle_outer_dimension = nod; }; -#define TEMPORARY_SOFT_ENDSTOP_STATE(enable) REMEMBER(tes, soft_endstops_enabled, enable); - #if ENABLED(BACKLASH_GCODE) #define TEMPORARY_BACKLASH_CORRECTION(value) REMEMBER(tbst, backlash.correction, value) #else diff --git a/Marlin/src/gcode/feature/clean/G12.cpp b/Marlin/src/gcode/feature/clean/G12.cpp index 6d13a010be..bdfaf38a06 100644 --- a/Marlin/src/gcode/feature/clean/G12.cpp +++ b/Marlin/src/gcode/feature/clean/G12.cpp @@ -37,6 +37,11 @@ /** * G12: Clean the nozzle + * + * E : 0=Never or 1=Always apply the "software endstop" limits + * P0 S : Stroke cleaning with S strokes + * P1 Sn T : Zigzag cleaning with S repeats and T zigzags + * P2 Sn R : Circle cleaning with S repeats and R radius */ void GcodeSuite::G12() { // Don't allow nozzle cleaning without homing first @@ -45,14 +50,12 @@ void GcodeSuite::G12() { const uint8_t pattern = parser.ushortval('P', 0), strokes = parser.ushortval('S', NOZZLE_CLEAN_STROKES), objects = parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES); - const float radius = parser.floatval('R', NOZZLE_CLEAN_CIRCLE_RADIUS); + const float radius = parser.linearval('R', NOZZLE_CLEAN_CIRCLE_RADIUS); const bool seenxyz = parser.seen("XYZ"); const uint8_t cleans = (!seenxyz || parser.boolval('X') ? _BV(X_AXIS) : 0) | (!seenxyz || parser.boolval('Y') ? _BV(Y_AXIS) : 0) - #if DISABLED(NOZZLE_CLEAN_NO_Z) - | (!seenxyz || parser.boolval('Z') ? _BV(Z_AXIS) : 0) - #endif + | TERN(NOZZLE_CLEAN_NO_Z, 0, (!seenxyz || parser.boolval('Z') ? _BV(Z_AXIS) : 0)) ; #if HAS_LEVELING @@ -60,6 +63,8 @@ void GcodeSuite::G12() { TEMPORARY_BED_LEVELING_STATE(!TEST(cleans, Z_AXIS) && planner.leveling_active); #endif + TEMPORARY_SOFT_ENDSTOP_STATE(parser.boolval('E')); + nozzle.clean(pattern, strokes, radius, objects, cleans); } diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index f3434a642d..6796b4d112 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -152,18 +152,20 @@ Nozzle nozzle; LIMIT( end[arrPos].A, soft_endstop.min.A, soft_endstop.max.A); \ }while(0) - LIMIT_AXIS(x); - LIMIT_AXIS(y); - LIMIT_AXIS(z); + if (soft_endstops_enabled) { - 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); + 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; + } - if (radiusOutOfRange && pattern == 2) { - SERIAL_ECHOLNPGM("Warning: Radius Out of Range"); - return; } #endif diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index eb7bc37894..1348adb3bd 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -152,6 +152,7 @@ typedef struct { xyz_pos_t min, max; } axis_limits_t; , const uint8_t old_tool_index=0, const uint8_t new_tool_index=0 #endif ); + #define TEMPORARY_SOFT_ENDSTOP_STATE(enable) REMEMBER(tes, soft_endstops_enabled, enable); #else constexpr bool soft_endstops_enabled = false; //constexpr axis_limits_t soft_endstop = { @@ -159,6 +160,7 @@ typedef struct { xyz_pos_t min, max; } axis_limits_t; // { X_MAX_POS, Y_MAX_POS, Z_MAX_POS } }; #define apply_motion_limits(V) NOOP #define update_software_endstops(...) NOOP + #define TEMPORARY_SOFT_ENDSTOP_STATE(...) NOOP #endif void report_real_position();