Skip to content

Commit 39fe6ef

Browse files
committed
Fix SD_FINISHED_RELEASECOMMAND bug
Fixes #17401 bug that was introduced in 8f26c3a
1 parent a97ae51 commit 39fe6ef

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

Marlin/Configuration_adv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,8 @@
10351035
// Enable this option and set to HIGH if your SD cards are incorrectly detected.
10361036
//#define SD_DETECT_STATE HIGH
10371037

1038-
#define SD_FINISHED_STEPPERRELEASE true // Disable steppers when SD Print is finished
1039-
#define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the Z enabled so your bed stays in place.
1038+
#define SD_FINISHED_STEPPERRELEASE true // Disable steppers when SD Print is finished
1039+
#define SD_FINISHED_RELEASECOMMAND "M84" // Use "M84XYE" to keep Z enabled so your bed stays in place
10401040

10411041
// Reverse SD sort to show "more recent" files first, according to the card's FAT.
10421042
// Since the FAT gets out of order with usage, SDCARD_SORT_ALPHA is recommended.

Marlin/src/gcode/sd/M1001.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#include "../gcode.h"
2828
#include "../../module/printcounter.h"
2929

30+
#ifdef SD_FINISHED_RELEASECOMMAND
31+
#include "../queue.h"
32+
#endif
33+
3034
#if EITHER(LCD_SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE)
3135
#include "../../lcd/ultralcd.h"
3236
#endif
@@ -47,10 +51,6 @@
4751
#include "../../feature/host_actions.h"
4852
#endif
4953

50-
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
51-
#include "../../module/planner.h"
52-
#endif
53-
5454
#ifndef PE_LEDS_COMPLETED_TIME
5555
#define PE_LEDS_COMPLETED_TIME (30*60)
5656
#endif
@@ -95,9 +95,9 @@ void GcodeSuite::M1001() {
9595
}
9696
#endif
9797

98-
// Wait for the queue to empty (and "clean"), inject SD_FINISHED_RELEASECOMMAND
99-
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
100-
planner.finish_and_disable();
98+
// Inject SD_FINISHED_RELEASECOMMAND, if any
99+
#ifdef SD_FINISHED_RELEASECOMMAND
100+
queue.inject_P(PSTR(SD_FINISHED_RELEASECOMMAND));
101101
#endif
102102

103103
// Re-select the last printed file in the UI

Marlin/src/inc/Conditionals_adv.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@
6868
#define HAS_FILAMENT_SENSOR 1
6969
#endif
7070

71+
// Let SD_FINISHED_RELEASECOMMAND stand in for SD_FINISHED_STEPPERRELEASE
72+
#if ENABLED(SD_FINISHED_STEPPERRELEASE)
73+
#ifndef SD_FINISHED_RELEASECOMMAND)
74+
#define SD_FINISHED_RELEASECOMMAND "M84" // planner.finish_and_disable()
75+
#endif
76+
#else
77+
#undef SD_FINISHED_RELEASECOMMAND
78+
#endif
79+
7180
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
7281
#define HAS_PRINT_PROGRESS 1
7382
#endif

Marlin/src/module/planner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,8 +1601,8 @@ void Planner::quick_stop() {
16011601
clear_block_buffer_runtime();
16021602
#endif
16031603

1604-
// Make sure to drop any attempt of queuing moves for at least 1 second
1605-
cleaning_buffer_counter = 1000;
1604+
// Make sure to drop any attempt of queuing moves for 1 second
1605+
cleaning_buffer_counter = TEMP_TIMER_FREQUENCY;
16061606

16071607
// Reenable Stepper ISR
16081608
if (was_enabled) stepper.wake_up();

Marlin/src/module/planner.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -807,12 +807,7 @@ class Planner {
807807
// Periodic tick to handle cleaning timeouts
808808
// Called from the Temperature ISR at ~1kHz
809809
static void tick() {
810-
if (cleaning_buffer_counter) {
811-
--cleaning_buffer_counter;
812-
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
813-
if (!cleaning_buffer_counter) queue.inject_P(PSTR(SD_FINISHED_RELEASECOMMAND));
814-
#endif
815-
}
810+
if (cleaning_buffer_counter) --cleaning_buffer_counter;
816811
}
817812

818813
/**

Marlin/src/module/probe.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class Probe {
4747

4848
static bool set_deployed(const bool deploy);
4949

50-
5150
#if IS_KINEMATIC
5251

5352
#if HAS_PROBE_XY_OFFSET

0 commit comments

Comments
 (0)