From af054923a7653874da0469bf8f09cd0f48ed300d Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Wed, 20 Sep 2023 13:54:32 +0200
Subject: [PATCH 1/8] Add M125
---
Firmware/Marlin.h | 1 +
Firmware/Marlin_main.cpp | 44 ++++++++++++++++++++++++++++++++++++----
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h
index 02c22eaa3..cd9782456 100755
--- a/Firmware/Marlin.h
+++ b/Firmware/Marlin.h
@@ -232,6 +232,7 @@ extern int feedmultiply;
extern int extrudemultiply; // Sets extrude multiply factor (in percent) for all extruders
extern float extruder_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
extern float current_position[NUM_AXIS] ;
+extern float pause_position[3];
extern float destination[NUM_AXIS] ;
extern float min_pos[3];
extern float max_pos[3];
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index 74d5abe56..98bd04e3a 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -200,6 +200,8 @@ float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
bool axis_known_position[3] = {false, false, false};
+float pause_position[3] = { X_PAUSE_POS, Y_PAUSE_POS, Z_PAUSE_LIFT };
+
uint8_t fanSpeed = 0;
uint8_t newFanSpeed = 0;
@@ -7671,16 +7673,50 @@ Sigma_Exit:
/*!
### M601 - Pause print M601: Pause print
+ Without any parameters it will park the extruder to default.
+ #### Usage
+
+ M601 [ X | Y | Z | S ]
+
+ #### Parameters
+ - `X` - X position to park at (otherwise X_PAUSE_POS 50) these are saved until change or reset.
+ - `Y` - Y position to park at (otherwise Y_PAUSE_POS 190) these are saved until change or reset.
+ - `Z` - Z raise before park (otherwise Z_PAUSE_LIFT 20) these are saved until change or reset.
+ - `S` - Set values [S0 = set default | S1 = set values only without pausing]
*/
/*!
- ### M125 - Pause print (TODO: not implemented)
+
+ ### M125 - Pause print M125: Pause print
+ Without any parameters it will park the extruderthe extruder to default.
+ #### Usage
+
+ M125 [ X | Y | Z | S ]
+
+ #### Parameters
+ - `X` - X position to park at (otherwise X_PAUSE_POS 50) these are saved until change or reset.
+ - `Y` - Y position to park at (otherwise Y_PAUSE_POS 190 these are saved until change or reset.
+ - `Z` - Z raise before park (otherwise Z_PAUSE_LIFT 20) these are saved until change or reset.
+ - `S` - Set values [S0 = set to default values | S1 = sset values only without pausing]
*/
/*!
### M25 - Pause SD print M25: Pause SD print
*/
case 25:
+ case 125:
case 601:
{
+ if (code_seen('X')) pause_position[1] = code_value_uint8();
+ if (code_seen('Y')) pause_position[2] = code_value_uint8();
+ if (code_seen('Z')) pause_position[3] = code_value_uint8();
+ if (code_seen('S')) {
+ if ( code_value_uint8() == 0 ) {
+ pause_position[1] = X_PAUSE_POS;
+ pause_position[2] = Y_PAUSE_POS;
+ pause_position[3] = Z_PAUSE_LIFT;
+ } else {
+ break;
+ }
+ }
if (!isPrintPaused) {
st_synchronize();
ClearToSend(); //send OK even before the command finishes executing because we want to make sure it is not skipped because of cmdqueue_pop_front();
@@ -10405,12 +10441,12 @@ void long_pause() //long pause print
setTargetHotend(0);
// Lift z
- raise_z(Z_PAUSE_LIFT);
+ raise_z(pause_position[3]);
// Move XY to side
if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) {
- current_position[X_AXIS] = X_PAUSE_POS;
- current_position[Y_AXIS] = Y_PAUSE_POS;
+ current_position[X_AXIS] = pause_position[1];
+ current_position[Y_AXIS] = pause_position[2];
plan_buffer_line_curposXYZE(50);
}
From 43692b416b1e6f08de061651690e03b3c4a5a1fc Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Wed, 20 Sep 2023 17:40:37 +0200
Subject: [PATCH 2/8] Fix float Thanks to @gudnimg for pointing out
---
Firmware/Marlin_main.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index 98bd04e3a..40c88111a 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -7705,9 +7705,9 @@ Sigma_Exit:
case 125:
case 601:
{
- if (code_seen('X')) pause_position[1] = code_value_uint8();
- if (code_seen('Y')) pause_position[2] = code_value_uint8();
- if (code_seen('Z')) pause_position[3] = code_value_uint8();
+ if (code_seen('X')) pause_position[1] = code_value();
+ if (code_seen('Y')) pause_position[2] = code_value();
+ if (code_seen('Z')) pause_position[3] = code_value();
if (code_seen('S')) {
if ( code_value_uint8() == 0 ) {
pause_position[1] = X_PAUSE_POS;
From 4dc87acf207d0187c87cf9f24b551cf139ce870a Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Wed, 8 Nov 2023 16:05:24 +0100
Subject: [PATCH 3/8] Fix issues Check printer limits Fix crash when pausing /
paused
---
Firmware/Marlin_main.cpp | 50 +++++++++++++++++++++++++++++-----------
1 file changed, 36 insertions(+), 14 deletions(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index 40c88111a..e350f4376 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -558,8 +558,8 @@ void crashdet_stop_and_save_print()
void crashdet_restore_print_and_continue()
{
- restore_print_from_ram_and_continue(default_retraction); //XYZ = orig, E +1mm unretract
-// babystep_apply();
+ restore_print_from_ram_and_continue(default_retraction); //XYZ = orig, E +1mm unretract
+//babystep_apply();
}
void crashdet_fmt_error(char* buf, uint8_t mask)
@@ -633,8 +633,8 @@ void crashdet_detected(uint8_t mask)
void crashdet_recover()
{
- crashdet_restore_print_and_continue();
- if (lcd_crash_detect_enabled()) tmc2130_sg_stop_on_crash = true;
+ if (!isPrintPaused) crashdet_restore_print_and_continue();
+ if (lcd_crash_detect_enabled()) tmc2130_sg_stop_on_crash = true;
}
void crashdet_cancel()
@@ -7696,7 +7696,7 @@ Sigma_Exit:
- `X` - X position to park at (otherwise X_PAUSE_POS 50) these are saved until change or reset.
- `Y` - Y position to park at (otherwise Y_PAUSE_POS 190 these are saved until change or reset.
- `Z` - Z raise before park (otherwise Z_PAUSE_LIFT 20) these are saved until change or reset.
- - `S` - Set values [S0 = set to default values | S1 = sset values only without pausing]
+ - `S` - Set values [S0 = set to default values | S1 = set values only without pausing]
*/
/*!
### M25 - Pause SD print M25: Pause SD print
@@ -7705,18 +7705,40 @@ Sigma_Exit:
case 125:
case 601:
{
- if (code_seen('X')) pause_position[1] = code_value();
- if (code_seen('Y')) pause_position[2] = code_value();
- if (code_seen('Z')) pause_position[3] = code_value();
+ if (code_seen('X')) {
+ //Check that the X pause position is within printer limits
+ if ((code_value() >= X_MIN_POS) && (code_value() <= X_MAX_POS-1)) {
+ pause_position[X_AXIS] = code_value();
+ } else pause_position[X_AXIS] = X_PAUSE_POS;
+ }
+ if (code_seen('Y')) {
+ //Check that the Y pause position is within printer limits
+ if ((code_value() >= Y_MIN_POS) && (code_value() <= Y_MAX_POS-1)) {
+ pause_position[Y_AXIS] = code_value();
+ } else pause_position[Y_AXIS] = Y_PAUSE_POS;
+ }
+ if (code_seen('Z')) {
+ //Check that the Z pause lift is within printer limits
+ if (code_value() <=Z_MAX_POS) {
+ pause_position[Z_AXIS] = code_value();
+ } else pause_position[Z_AXIS] = Z_PAUSE_LIFT;
+ }
if (code_seen('S')) {
if ( code_value_uint8() == 0 ) {
- pause_position[1] = X_PAUSE_POS;
- pause_position[2] = Y_PAUSE_POS;
- pause_position[3] = Z_PAUSE_LIFT;
+ pause_position[X_AXIS] = X_PAUSE_POS;
+ pause_position[Y_AXIS] = Y_PAUSE_POS;
+ pause_position[Z_AXIS] = Z_PAUSE_LIFT;
} else {
break;
}
}
+/* SERIAL_ECHOPGM("X:");
+ SERIAL_ECHOLN(pause_position[X_AXIS]);
+ SERIAL_ECHOPGM("Y:");
+ SERIAL_ECHOLN(pause_position[Y_AXIS]);
+ SERIAL_ECHOPGM("Z:");
+ SERIAL_ECHOLN(pause_position[Z_AXIS]);
+*/
if (!isPrintPaused) {
st_synchronize();
ClearToSend(); //send OK even before the command finishes executing because we want to make sure it is not skipped because of cmdqueue_pop_front();
@@ -10441,12 +10463,12 @@ void long_pause() //long pause print
setTargetHotend(0);
// Lift z
- raise_z(pause_position[3]);
+ raise_z(pause_position[Z_AXIS]);
// Move XY to side
if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) {
- current_position[X_AXIS] = pause_position[1];
- current_position[Y_AXIS] = pause_position[2];
+ current_position[X_AXIS] = pause_position[X_AXIS];
+ current_position[Y_AXIS] = pause_position[Y_AXIS];
plan_buffer_line_curposXYZE(50);
}
From 498d99b84b429aa43aa0fc61c636c6fc8b88c5b9 Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Thu, 9 Nov 2023 12:43:27 +0100
Subject: [PATCH 4/8] Code size improvments
---
Firmware/Marlin_main.cpp | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index e350f4376..4778d99e7 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -7705,24 +7705,23 @@ Sigma_Exit:
case 125:
case 601:
{
- if (code_seen('X')) {
- //Check that the X pause position is within printer limits
- if ((code_value() >= X_MIN_POS) && (code_value() <= X_MAX_POS-1)) {
- pause_position[X_AXIS] = code_value();
- } else pause_position[X_AXIS] = X_PAUSE_POS;
+ float temp_pause_position[3] = { X_PAUSE_POS, Y_PAUSE_POS, Z_PAUSE_LIFT };
+ for (uint8_t axis = 0; axis < E_AXIS; axis++) {
+ if (code_seen(axis_codes[axis])) temp_pause_position[axis] = code_value();
}
- if (code_seen('Y')) {
- //Check that the Y pause position is within printer limits
- if ((code_value() >= Y_MIN_POS) && (code_value() <= Y_MAX_POS-1)) {
- pause_position[Y_AXIS] = code_value();
- } else pause_position[Y_AXIS] = Y_PAUSE_POS;
+ //Check that the X pause position is within printer limits
+ if ((temp_pause_position[X_AXIS] >= X_MIN_POS) && (temp_pause_position[X_AXIS] <= X_MAX_POS-1)) {
+ pause_position[X_AXIS] = temp_pause_position[X_AXIS];
+ }
+ //Check that the Y pause position is within printer limits
+ if ((temp_pause_position[Y_AXIS] >= Y_MIN_POS) && (temp_pause_position[Y_AXIS] <= Y_MAX_POS-1)) {
+ pause_position[Y_AXIS] = temp_pause_position[Y_AXIS];
}
- if (code_seen('Z')) {
- //Check that the Z pause lift is within printer limits
- if (code_value() <=Z_MAX_POS) {
- pause_position[Z_AXIS] = code_value();
- } else pause_position[Z_AXIS] = Z_PAUSE_LIFT;
+ //Check that the Z lift position is within printer limits
+ if (temp_pause_position[Z_AXIS] <=Z_MAX_POS) {
+ pause_position[Z_AXIS] = temp_pause_position[Z_AXIS];
}
+
if (code_seen('S')) {
if ( code_value_uint8() == 0 ) {
pause_position[X_AXIS] = X_PAUSE_POS;
From 2e121337162652444e0669a53c9ee2409214411c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?=
Date: Sun, 19 Nov 2023 09:29:46 +0000
Subject: [PATCH 5/8] M125: Code size optimisation
Change in memory:
Flash: -66 bytes
SRAM: -12 bytes
---
Firmware/Marlin_main.cpp | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index 4778d99e7..f01136c83 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -7705,21 +7705,15 @@ Sigma_Exit:
case 125:
case 601:
{
- float temp_pause_position[3] = { X_PAUSE_POS, Y_PAUSE_POS, Z_PAUSE_LIFT };
+ // Set default values
+ pause_position[X_AXIS] = X_PAUSE_POS;
+ pause_position[Y_AXIS] = Y_PAUSE_POS;
+ pause_position[Z_AXIS] = Z_PAUSE_LIFT;
+
for (uint8_t axis = 0; axis < E_AXIS; axis++) {
- if (code_seen(axis_codes[axis])) temp_pause_position[axis] = code_value();
- }
- //Check that the X pause position is within printer limits
- if ((temp_pause_position[X_AXIS] >= X_MIN_POS) && (temp_pause_position[X_AXIS] <= X_MAX_POS-1)) {
- pause_position[X_AXIS] = temp_pause_position[X_AXIS];
+ if (code_seen(axis_codes[axis])) {
+ pause_position[axis] = constrain(code_value(), min_pos[axis], max_pos[axis]);
}
- //Check that the Y pause position is within printer limits
- if ((temp_pause_position[Y_AXIS] >= Y_MIN_POS) && (temp_pause_position[Y_AXIS] <= Y_MAX_POS-1)) {
- pause_position[Y_AXIS] = temp_pause_position[Y_AXIS];
- }
- //Check that the Z lift position is within printer limits
- if (temp_pause_position[Z_AXIS] <=Z_MAX_POS) {
- pause_position[Z_AXIS] = temp_pause_position[Z_AXIS];
}
if (code_seen('S')) {
From 4a4c015ad8cd51539471e881bcb206db7820c9a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?=
Date: Sun, 19 Nov 2023 09:30:18 +0000
Subject: [PATCH 6/8] M125: make pause_position static
---
Firmware/Marlin.h | 1 -
Firmware/Marlin_main.cpp | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h
index cd9782456..02c22eaa3 100755
--- a/Firmware/Marlin.h
+++ b/Firmware/Marlin.h
@@ -232,7 +232,6 @@ extern int feedmultiply;
extern int extrudemultiply; // Sets extrude multiply factor (in percent) for all extruders
extern float extruder_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
extern float current_position[NUM_AXIS] ;
-extern float pause_position[3];
extern float destination[NUM_AXIS] ;
extern float min_pos[3];
extern float max_pos[3];
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index f01136c83..8da171900 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -200,7 +200,7 @@ float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
bool axis_known_position[3] = {false, false, false};
-float pause_position[3] = { X_PAUSE_POS, Y_PAUSE_POS, Z_PAUSE_LIFT };
+static float pause_position[3] = { X_PAUSE_POS, Y_PAUSE_POS, Z_PAUSE_LIFT };
uint8_t fanSpeed = 0;
uint8_t newFanSpeed = 0;
From 0d60a82c56e51f84959920a3a47fd9be59655a87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?=
Date: Sun, 19 Nov 2023 16:57:25 +0000
Subject: [PATCH 7/8] Don't reset pause_position on every M125
Change in memory:
Flash: -76 bytes
SRAM: 0 bytes
---
Firmware/Marlin_main.cpp | 5 -----
1 file changed, 5 deletions(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index 8da171900..9fcf12a34 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -7705,11 +7705,6 @@ Sigma_Exit:
case 125:
case 601:
{
- // Set default values
- pause_position[X_AXIS] = X_PAUSE_POS;
- pause_position[Y_AXIS] = Y_PAUSE_POS;
- pause_position[Z_AXIS] = Z_PAUSE_LIFT;
-
for (uint8_t axis = 0; axis < E_AXIS; axis++) {
if (code_seen(axis_codes[axis])) {
pause_position[axis] = constrain(code_value(), min_pos[axis], max_pos[axis]);
From 96094dc548147c8c8cf7c5358015c797670c0cf4 Mon Sep 17 00:00:00 2001
From: 3d-gussner <3d.gussner@gmail.com>
Date: Mon, 20 Nov 2023 07:28:21 +0100
Subject: [PATCH 8/8] Don't pause with `S`et values Update documentation
---
Firmware/Marlin_main.cpp | 44 +++++++++++++++++++++++++++-------------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index 9fcf12a34..5bbe9b2d3 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -7673,54 +7673,70 @@ Sigma_Exit:
/*!
### M601 - Pause print M601: Pause print
- Without any parameters it will park the extruder to default.
+ Without any parameters it will park the extruder to default or last set position.
+ The default pause position will be set during power up and a reset, the new pause positions aren't permanent.
#### Usage
M601 [ X | Y | Z | S ]
#### Parameters
- - `X` - X position to park at (otherwise X_PAUSE_POS 50) these are saved until change or reset.
- - `Y` - Y position to park at (otherwise Y_PAUSE_POS 190) these are saved until change or reset.
- - `Z` - Z raise before park (otherwise Z_PAUSE_LIFT 20) these are saved until change or reset.
- - `S` - Set values [S0 = set default | S1 = set values only without pausing]
+ - `X` - X position to park at (default X_PAUSE_POS 50) these are saved until change or reset.
+ - `Y` - Y position to park at (default Y_PAUSE_POS 190) these are saved until change or reset.
+ - `Z` - Z raise before park (default Z_PAUSE_LIFT 20) these are saved until change or reset.
+ - `S` - Set values [S0 = set to default values | S1 = set values] without pausing
*/
/*!
### M125 - Pause print M125: Pause print
- Without any parameters it will park the extruderthe extruder to default.
+ Without any parameters it will park the extruder to default or last set position.
+ The default pause position will be set during power up and a reset, the new pause positions aren't permanent.
#### Usage
M125 [ X | Y | Z | S ]
#### Parameters
- - `X` - X position to park at (otherwise X_PAUSE_POS 50) these are saved until change or reset.
- - `Y` - Y position to park at (otherwise Y_PAUSE_POS 190 these are saved until change or reset.
- - `Z` - Z raise before park (otherwise Z_PAUSE_LIFT 20) these are saved until change or reset.
- - `S` - Set values [S0 = set to default values | S1 = set values only without pausing]
+ - `X` - X position to park at (default X_PAUSE_POS 50) these are saved until change or reset.
+ - `Y` - Y position to park at (default Y_PAUSE_POS 190) these are saved until change or reset.
+ - `Z` - Z raise before park (default Z_PAUSE_LIFT 20) these are saved until change or reset.
+ - `S` - Set values [S0 = set to default values | S1 = set values] without pausing
*/
/*!
### M25 - Pause SD print M25: Pause SD print
+ Without any parameters it will park the extruder to default or last set position.
+ The default pause position will be set during power up and a reset, the new pause positions aren't permanent.
+ #### Usage
+
+ M25 [ X | Y | Z | S ]
+
+ #### Parameters
+ - `X` - X position to park at (default X_PAUSE_POS 50) these are saved until change or reset.
+ - `Y` - Y position to park at (default Y_PAUSE_POS 190) these are saved until change or reset.
+ - `Z` - Z raise before park (default Z_PAUSE_LIFT 20) these are saved until change or reset.
+ - `S` - Set values [S0 = set to default values | S1 = set values] without pausing
*/
case 25:
case 125:
case 601:
{
+ //Set new pause position for all three axis XYZ
for (uint8_t axis = 0; axis < E_AXIS; axis++) {
if (code_seen(axis_codes[axis])) {
+ //Check that the positions are within hardware limits
pause_position[axis] = constrain(code_value(), min_pos[axis], max_pos[axis]);
}
}
-
+ //Set default or new pause position without pausing
if (code_seen('S')) {
if ( code_value_uint8() == 0 ) {
pause_position[X_AXIS] = X_PAUSE_POS;
pause_position[Y_AXIS] = Y_PAUSE_POS;
pause_position[Z_AXIS] = Z_PAUSE_LIFT;
- } else {
- break;
}
+ break;
}
-/* SERIAL_ECHOPGM("X:");
+/*
+ //Debug serial output
+ SERIAL_ECHOPGM("X:");
SERIAL_ECHOLN(pause_position[X_AXIS]);
SERIAL_ECHOPGM("Y:");
SERIAL_ECHOLN(pause_position[Y_AXIS]);