Skip to content

Commit

Permalink
🐛 Prevent stepper sleep during long UBL idle (MarlinFirmware#22137)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 15, 2021
1 parent dec083d commit 781257b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
15 changes: 7 additions & 8 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,19 +421,18 @@ void startOrResumeJob() {
* - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT)
* - Pulse FET_SAFETY_PIN if it exists
*/
inline void manage_inactivity(const bool ignore_stepper_queue=false) {
inline void manage_inactivity(const bool no_stepper_sleep=false) {

queue.get_available_commands();

const millis_t ms = millis();

// Prevent steppers timing-out in the middle of M600
// unless PAUSE_PARK_NO_STEPPER_TIMEOUT is disabled
const bool parked_or_ignoring = ignore_stepper_queue
// Prevent steppers timing-out
const bool do_reset_timeout = no_stepper_sleep
|| TERN0(PAUSE_PARK_NO_STEPPER_TIMEOUT, did_pause_print);

// Reset both the M18/M84 activity timeout and the M85 max 'kill' timeout
if (parked_or_ignoring) gcode.reset_stepper_timeout(ms);
if (do_reset_timeout) gcode.reset_stepper_timeout(ms);

if (gcode.stepper_max_timed_out(ms)) {
SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr);
Expand All @@ -449,7 +448,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
// activity timeout and the M85 max 'kill' timeout
if (planner.has_blocks_queued())
gcode.reset_stepper_timeout(ms);
else if (!parked_or_ignoring && gcode.stepper_inactive_timeout()) {
else if (!do_reset_timeout && gcode.stepper_inactive_timeout()) {
if (!already_shutdown_steppers) {
already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this

Expand Down Expand Up @@ -732,14 +731,14 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
* - Update the Průša MMU2
* - Handle Joystick jogging
*/
void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
void idle(bool no_stepper_sleep/*=false*/) {
#if ENABLED(MARLIN_DEV_MODE)
static uint16_t idle_depth = 0;
if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", idle_depth);
#endif

// Core Marlin activities
manage_inactivity(TERN_(ADVANCED_PAUSE_FEATURE, no_stepper_sleep));
manage_inactivity(no_stepper_sleep);

// Manage Heaters (and Watchdog)
thermalManager.manage_heater();
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/MarlinCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
void stop();

// Pass true to keep steppers from timing out
void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep=false));
inline void idle_no_sleep() { idle(TERN_(ADVANCED_PAUSE_FEATURE, true)); }
void idle(bool no_stepper_sleep=false);
inline void idle_no_sleep() { idle(true); }

#if ENABLED(G38_PROBE_TARGET)
extern uint8_t G38_move; // Flag to tell the ISR that G38 is in progress, and the type
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
SET_SOFT_ENDSTOP_LOOSE(true);

do {
idle();
idle_no_sleep();
new_z = ui.ubl_mesh_value();
TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
Expand Down

0 comments on commit 781257b

Please sign in to comment.