[2.0.x] Automatically reset stepper timeout (#10179)
* Automatically reset stepper timeout in manage_inactivity Any code that adds moves to the planner can skip resetting the stepper timeout. We can let `idle` / `manage_inactivity` reset the timer whenever it detects any moves in the planner. * blocks_queued => has_blocks_queued
This commit is contained in:
@ -336,7 +336,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
||||
|
||||
const millis_t ms = millis();
|
||||
|
||||
if (max_inactive_time && ELAPSED(ms, gcode.previous_cmd_ms + max_inactive_time)) {
|
||||
if (max_inactive_time && ELAPSED(ms, gcode.previous_move_ms + max_inactive_time)) {
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ECHOLNPAIR(MSG_KILL_INACTIVE_TIME, parser.command_ptr);
|
||||
kill(PSTR(MSG_KILLED));
|
||||
@ -349,23 +349,26 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
||||
#define MOVE_AWAY_TEST true
|
||||
#endif
|
||||
|
||||
if (MOVE_AWAY_TEST && stepper_inactive_time && ELAPSED(ms, gcode.previous_cmd_ms + stepper_inactive_time)
|
||||
&& !ignore_stepper_queue && !planner.blocks_queued()) {
|
||||
#if ENABLED(DISABLE_INACTIVE_X)
|
||||
disable_X();
|
||||
#endif
|
||||
#if ENABLED(DISABLE_INACTIVE_Y)
|
||||
disable_Y();
|
||||
#endif
|
||||
#if ENABLED(DISABLE_INACTIVE_Z)
|
||||
disable_Z();
|
||||
#endif
|
||||
#if ENABLED(DISABLE_INACTIVE_E)
|
||||
disable_e_steppers();
|
||||
#endif
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTIPANEL) // Only needed with an LCD
|
||||
if (ubl.lcd_map_control) ubl.lcd_map_control = defer_return_to_status = false;
|
||||
#endif
|
||||
if (stepper_inactive_time) {
|
||||
if (planner.has_blocks_queued())
|
||||
gcode.previous_move_ms = ms; // reset_stepper_timeout to keep steppers powered
|
||||
else if (MOVE_AWAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) {
|
||||
#if ENABLED(DISABLE_INACTIVE_X)
|
||||
disable_X();
|
||||
#endif
|
||||
#if ENABLED(DISABLE_INACTIVE_Y)
|
||||
disable_Y();
|
||||
#endif
|
||||
#if ENABLED(DISABLE_INACTIVE_Z)
|
||||
disable_Z();
|
||||
#endif
|
||||
#if ENABLED(DISABLE_INACTIVE_E)
|
||||
disable_e_steppers();
|
||||
#endif
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTIPANEL) // Only needed with an LCD
|
||||
if (ubl.lcd_map_control) ubl.lcd_map_control = defer_return_to_status = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CHDK // Check if pin should be set to LOW after M240 set it to HIGH
|
||||
@ -424,8 +427,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
||||
|
||||
#if ENABLED(EXTRUDER_RUNOUT_PREVENT)
|
||||
if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP
|
||||
&& ELAPSED(ms, gcode.previous_cmd_ms + (EXTRUDER_RUNOUT_SECONDS) * 1000UL)
|
||||
&& !planner.blocks_queued()
|
||||
&& ELAPSED(ms, gcode.previous_move_ms + (EXTRUDER_RUNOUT_SECONDS) * 1000UL)
|
||||
&& !planner.has_blocks_queued()
|
||||
) {
|
||||
#if ENABLED(SWITCHING_EXTRUDER)
|
||||
const bool oldstatus = E0_ENABLE_READ;
|
||||
@ -449,8 +452,6 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
||||
}
|
||||
#endif // !SWITCHING_EXTRUDER
|
||||
|
||||
gcode.refresh_cmd_timeout();
|
||||
|
||||
const float olde = current_position[E_AXIS];
|
||||
current_position[E_AXIS] += EXTRUDER_RUNOUT_EXTRUDE;
|
||||
planner.buffer_line_kinematic(current_position, MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED), active_extruder);
|
||||
@ -476,6 +477,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
||||
#endif // E_STEPPERS > 1
|
||||
}
|
||||
#endif // !SWITCHING_EXTRUDER
|
||||
|
||||
gcode.previous_move_ms = ms; // reset_stepper_timeout to keep steppers powered
|
||||
}
|
||||
#endif // EXTRUDER_RUNOUT_PREVENT
|
||||
|
||||
@ -541,7 +544,7 @@ void idle(
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
static millis_t i2cpem_next_update_ms;
|
||||
if (planner.blocks_queued() && ELAPSED(millis(), i2cpem_next_update_ms)) {
|
||||
if (planner.has_blocks_queued() && ELAPSED(millis(), i2cpem_next_update_ms)) {
|
||||
I2CPEM.update();
|
||||
i2cpem_next_update_ms = millis() + I2CPE_MIN_UPD_TIME_MS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user