[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:
Scott Lahteine
2018-03-21 19:30:06 -05:00
committed by GitHub
parent 97e8a6ebd9
commit 1cb810ff1c
16 changed files with 47 additions and 62 deletions

View File

@ -266,8 +266,6 @@ void buffer_line_to_destination(const float fr_mm_s) {
if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
#endif
gcode.refresh_cmd_timeout();
#if UBL_SEGMENTED
// ubl segmented line will do z-only moves in single segment
ubl.prepare_segmented_line_to(destination, MMS_SCALED(fr_mm_s ? fr_mm_s : feedrate_mm_s));
@ -435,12 +433,10 @@ void bracket_probe_move(const bool before) {
saved_feedrate_mm_s = feedrate_mm_s;
saved_feedrate_percentage = feedrate_percentage;
feedrate_percentage = 100;
gcode.refresh_cmd_timeout();
}
else {
feedrate_mm_s = saved_feedrate_mm_s;
feedrate_percentage = saved_feedrate_percentage;
gcode.refresh_cmd_timeout();
}
}
@ -859,7 +855,6 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
*/
void prepare_move_to_destination() {
clamp_to_software_endstops(destination);
gcode.refresh_cmd_timeout();
#if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)

View File

@ -468,7 +468,7 @@ void Planner::check_axes_activity() {
#endif
#endif
if (blocks_queued()) {
if (has_blocks_queued()) {
#if FAN_COUNT > 0
for (uint8_t i = 0; i < FAN_COUNT; i++)
@ -1547,7 +1547,7 @@ void Planner::buffer_segment(const float &a, const float &b, const float &c, con
//*/
// Always split the first move into two (if not homing or probing)
if (!blocks_queued()) {
if (!has_blocks_queued()) {
#define _BETWEEN(A) (position[A##_AXIS] + target[A##_AXIS]) >> 1
const int32_t between[ABCE] = { _BETWEEN(A), _BETWEEN(B), _BETWEEN(C), _BETWEEN(E) };

View File

@ -512,14 +512,14 @@ class Planner {
/**
* Does the buffer have any blocks queued?
*/
static bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }
static bool has_blocks_queued() { return (block_buffer_head != block_buffer_tail); }
/**
* "Discard" the block and "release" the memory.
* Called when the current block is no longer needed.
*/
FORCE_INLINE static void discard_current_block() {
if (blocks_queued())
if (has_blocks_queued())
block_buffer_tail = BLOCK_MOD(block_buffer_tail + 1);
}
@ -528,7 +528,7 @@ class Planner {
* Called after an interrupted move to throw away the rest of the move.
*/
FORCE_INLINE static bool discard_continued_block() {
const bool discard = blocks_queued() && TEST(block_buffer[block_buffer_tail].flag, BLOCK_BIT_CONTINUED);
const bool discard = has_blocks_queued() && TEST(block_buffer[block_buffer_tail].flag, BLOCK_BIT_CONTINUED);
if (discard) discard_current_block();
return discard;
}
@ -539,7 +539,7 @@ class Planner {
* WARNING: Called from Stepper ISR context!
*/
static block_t* get_current_block() {
if (blocks_queued()) {
if (has_blocks_queued()) {
block_t * const block = &block_buffer[block_buffer_tail];
// If the block has no trapezoid calculated, it's unsafe to execute.

View File

@ -545,9 +545,6 @@ static float run_z_probe() {
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
#endif
// Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding
gcode.refresh_cmd_timeout();
// Double-probing does a fast probe followed by a slow probe
#if MULTIPLE_PROBING == 2

View File

@ -1091,7 +1091,7 @@ void Stepper::init() {
/**
* Block until all buffered steps are executed / cleaned
*/
void Stepper::synchronize() { while (planner.blocks_queued() || cleaning_buffer_counter) idle(); }
void Stepper::synchronize() { while (planner.has_blocks_queued() || cleaning_buffer_counter) idle(); }
/**
* Set the stepper positions directly in steps
@ -1191,7 +1191,7 @@ void Stepper::finish_and_disable() {
void Stepper::quick_stop() {
cleaning_buffer_counter = 5000;
DISABLE_STEPPER_DRIVER_INTERRUPT();
while (planner.blocks_queued()) planner.discard_current_block();
while (planner.has_blocks_queued()) planner.discard_current_block();
current_block = NULL;
ENABLE_STEPPER_DRIVER_INTERRUPT();
#if ENABLED(ULTRA_LCD)