Skip to content

Commit

Permalink
Fix SD_FINISHED_RELEASECOMMAND bug
Browse files Browse the repository at this point in the history
Fixes #17401 bug that was introduced in 8f26c3a
  • Loading branch information
thinkyhead committed Apr 12, 2020
1 parent a97ae51 commit 39fe6ef
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,8 @@
// Enable this option and set to HIGH if your SD cards are incorrectly detected.
//#define SD_DETECT_STATE HIGH

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

// Reverse SD sort to show "more recent" files first, according to the card's FAT.
// Since the FAT gets out of order with usage, SDCARD_SORT_ALPHA is recommended.
Expand Down
14 changes: 7 additions & 7 deletions Marlin/src/gcode/sd/M1001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "../gcode.h"
#include "../../module/printcounter.h"

#ifdef SD_FINISHED_RELEASECOMMAND
#include "../queue.h"
#endif

#if EITHER(LCD_SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE)
#include "../../lcd/ultralcd.h"
#endif
Expand All @@ -47,10 +51,6 @@
#include "../../feature/host_actions.h"
#endif

#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
#include "../../module/planner.h"
#endif

#ifndef PE_LEDS_COMPLETED_TIME
#define PE_LEDS_COMPLETED_TIME (30*60)
#endif
Expand Down Expand Up @@ -95,9 +95,9 @@ void GcodeSuite::M1001() {
}
#endif

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

// Re-select the last printed file in the UI
Expand Down
9 changes: 9 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@
#define HAS_FILAMENT_SENSOR 1
#endif

// Let SD_FINISHED_RELEASECOMMAND stand in for SD_FINISHED_STEPPERRELEASE
#if ENABLED(SD_FINISHED_STEPPERRELEASE)
#ifndef SD_FINISHED_RELEASECOMMAND)
#define SD_FINISHED_RELEASECOMMAND "M84" // planner.finish_and_disable()
#endif
#else
#undef SD_FINISHED_RELEASECOMMAND
#endif

#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
#define HAS_PRINT_PROGRESS 1
#endif
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1601,8 +1601,8 @@ void Planner::quick_stop() {
clear_block_buffer_runtime();
#endif

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

// Reenable Stepper ISR
if (was_enabled) stepper.wake_up();
Expand Down
7 changes: 1 addition & 6 deletions Marlin/src/module/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -807,12 +807,7 @@ class Planner {
// Periodic tick to handle cleaning timeouts
// Called from the Temperature ISR at ~1kHz
static void tick() {
if (cleaning_buffer_counter) {
--cleaning_buffer_counter;
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
if (!cleaning_buffer_counter) queue.inject_P(PSTR(SD_FINISHED_RELEASECOMMAND));
#endif
}
if (cleaning_buffer_counter) --cleaning_buffer_counter;
}

/**
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/module/probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Probe {

static bool set_deployed(const bool deploy);


#if IS_KINEMATIC

#if HAS_PROBE_XY_OFFSET
Expand Down

0 comments on commit 39fe6ef

Please sign in to comment.