From bd4e38860b0ceacd543df8d6cc03a252028efd56 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 7 Mar 2020 01:27:52 -0600 Subject: [PATCH 1/6] Suggested message change --- Marlin/src/core/language.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index f58ace77091b..a166de59cae6 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -185,7 +185,7 @@ #define STR_INVALID_POS_SLOT "Invalid slot. Total: " #define STR_SD_CANT_OPEN_SUBDIR "Cannot open subdir " -#define STR_SD_INIT_FAIL "SD init fail" +#define STR_SD_INIT_FAIL "No SD card" #define STR_SD_VOL_INIT_FAIL "volume.init failed" #define STR_SD_OPENROOT_FAIL "openRoot failed" #define STR_SD_CARD_OK "SD card ok" From 811f189108c7a81f48790f2b9ca982c3a5b67827 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 13 Apr 2020 23:25:00 -0400 Subject: [PATCH 2/6] Add softendstop clamping and fix array position for single nozzle and mixing --- Marlin/src/libs/nozzle.cpp | 57 ++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index ecbfeb331ede..b961e7da038e 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -159,6 +159,51 @@ 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; + #if ANY(SINGLENOZZLE, MIXING_EXTRUDER) + const uint8_t arrPos = 0; + #else + const uint8_t arrPos = active_extruder; + #endif + + #if HAS_SOFTWARE_ENDSTOPS + NOMORE(start[arrPos].x, soft_endstop.max.x); + NOMORE(middle[arrPos].x, soft_endstop.max.x); + NOMORE(end[arrPos].x, soft_endstop.max.x); + NOMORE(start[arrPos].y, soft_endstop.max.y); + NOMORE(middle[arrPos].y, soft_endstop.max.y); + NOMORE(end[arrPos].y, soft_endstop.max.y); + NOMORE(start[arrPos].z, soft_endstop.max.z); + NOMORE(middle[arrPos].z, soft_endstop.max.z); + NOMORE(end[arrPos].z, soft_endstop.max.z); + + NOLESS(start[arrPos].x, ); + NOLESS(middle[arrPos].x, soft_endstop.min.x); + NOLESS(end[arrPos].x, soft_endstop.min.x); + NOLESS(start[arrPos].y, soft_endstop.min.y); + NOLESS(middle[arrPos].y, soft_endstop.min.y); + NOLESS(end[arrPos].y, soft_endstop.min.y); + NOLESS(start[arrPos].z, soft_endstop.min.z); + NOLESS(middle[arrPos].z, soft_endstop.min.z); + NOLESS(end[arrPos].z, soft_endstop.min.z); + + bool radiusOutOfRange = false; + if(middle.x + (radius / 3.14) > soft_endstop.max.x) + radiusOutOfRange = true; + if(middle.x + (radius / 3.14) < soft_endstop.min.x) + radiusOutOfRange = true; + if(middle.y + (radius / 3.14) > soft_endstop.max.y) + radiusOutOfRange = true; + if(middle.y + (radius / 3.14) < soft_endstop.min.y) + radiusOutOfRange = true; + + 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"); @@ -166,15 +211,15 @@ Nozzle nozzle; } } 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); } } From 65570a4ea03e4533024499fd798035e18f921f25 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 16 Apr 2020 00:24:27 -0500 Subject: [PATCH 3/6] Update nozzle.cpp --- Marlin/src/libs/nozzle.cpp | 60 +++++++++++++------------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index b961e7da038e..319af7832c46 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -159,46 +159,28 @@ 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; - #if ANY(SINGLENOZZLE, MIXING_EXTRUDER) - const uint8_t arrPos = 0; - #else - const uint8_t arrPos = active_extruder; - #endif + const uint8_t arrPos = ANY(SINGLENOZZLE, MIXING_EXTRUDER) ? 0 : active_extruder; #if HAS_SOFTWARE_ENDSTOPS - NOMORE(start[arrPos].x, soft_endstop.max.x); - NOMORE(middle[arrPos].x, soft_endstop.max.x); - NOMORE(end[arrPos].x, soft_endstop.max.x); - NOMORE(start[arrPos].y, soft_endstop.max.y); - NOMORE(middle[arrPos].y, soft_endstop.max.y); - NOMORE(end[arrPos].y, soft_endstop.max.y); - NOMORE(start[arrPos].z, soft_endstop.max.z); - NOMORE(middle[arrPos].z, soft_endstop.max.z); - NOMORE(end[arrPos].z, soft_endstop.max.z); - - NOLESS(start[arrPos].x, ); - NOLESS(middle[arrPos].x, soft_endstop.min.x); - NOLESS(end[arrPos].x, soft_endstop.min.x); - NOLESS(start[arrPos].y, soft_endstop.min.y); - NOLESS(middle[arrPos].y, soft_endstop.min.y); - NOLESS(end[arrPos].y, soft_endstop.min.y); - NOLESS(start[arrPos].z, soft_endstop.min.z); - NOLESS(middle[arrPos].z, soft_endstop.min.z); - NOLESS(end[arrPos].z, soft_endstop.min.z); - - bool radiusOutOfRange = false; - if(middle.x + (radius / 3.14) > soft_endstop.max.x) - radiusOutOfRange = true; - if(middle.x + (radius / 3.14) < soft_endstop.min.x) - radiusOutOfRange = true; - if(middle.y + (radius / 3.14) > soft_endstop.max.y) - radiusOutOfRange = true; - if(middle.y + (radius / 3.14) < soft_endstop.min.y) - radiusOutOfRange = true; - - if(radiusOutOfRange && pattern == 2) - { - SERIAL_ECHOLNPGM("Warning : Radius Out of Range"); + + #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 float arc_part = radius / M_PI; + const bool radiusOutOfRange = (middle.x + arc_part > soft_endstop.max.x) + || (middle.x + arc_part < soft_endstop.min.x) + || (middle.y + arc_part > soft_endstop.max.y) + || (middle.y + arc_part < soft_endstop.min.y); + + if (radiusOutOfRange && pattern == 2) { + SERIAL_ECHOLNPGM("Warning: Radius Out of Range"); return; } @@ -206,7 +188,7 @@ Nozzle nozzle; 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; } } From 0b7cfad20c079fb91549b50a0e88c07f6db3fb49 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 21 Apr 2020 12:30:58 -0500 Subject: [PATCH 4/6] Fix M100 compile warning --- Marlin/src/gcode/calibrate/M100.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/calibrate/M100.cpp b/Marlin/src/gcode/calibrate/M100.cpp index 6b8a0de528f7..fb04420e545f 100644 --- a/Marlin/src/gcode/calibrate/M100.cpp +++ b/Marlin/src/gcode/calibrate/M100.cpp @@ -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++) From 8524e5cbbcd815f39c44d79bff9f708e16479b8d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 21 Apr 2020 12:31:09 -0500 Subject: [PATCH 5/6] Fix radiusOutOfRange --- Marlin/src/libs/nozzle.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 319af7832c46..6c97af94335f 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -174,10 +174,10 @@ Nozzle nozzle; LIMIT_AXIS(z); const float arc_part = radius / M_PI; - const bool radiusOutOfRange = (middle.x + arc_part > soft_endstop.max.x) - || (middle.x + arc_part < soft_endstop.min.x) - || (middle.y + arc_part > soft_endstop.max.y) - || (middle.y + arc_part < soft_endstop.min.y); + const bool radiusOutOfRange = (middle[arrPos].x + arc_part > soft_endstop.max.x) + || (middle[arrPos].x + arc_part < soft_endstop.min.x) + || (middle[arrPos].y + arc_part > soft_endstop.max.y) + || (middle[arrPos].y + arc_part < soft_endstop.min.y); if (radiusOutOfRange && pattern == 2) { SERIAL_ECHOLNPGM("Warning: Radius Out of Range"); From 44dedc7acca7417fba01d179165a617faaf5e1ad Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 22 Apr 2020 18:51:33 -0500 Subject: [PATCH 6/6] Check radius around XY for limits --- Marlin/src/libs/nozzle.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 6c97af94335f..350444d91a85 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -173,11 +173,10 @@ Nozzle nozzle; LIMIT_AXIS(y); LIMIT_AXIS(z); - const float arc_part = radius / M_PI; - const bool radiusOutOfRange = (middle[arrPos].x + arc_part > soft_endstop.max.x) - || (middle[arrPos].x + arc_part < soft_endstop.min.x) - || (middle[arrPos].y + arc_part > soft_endstop.max.y) - || (middle[arrPos].y + arc_part < soft_endstop.min.y); + 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");