[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

@ -155,8 +155,6 @@ inline void servo_probe_test() {
} while (++i < 4);
if (probe_inverting != deploy_state) SERIAL_PROTOCOLLNPGM("WARNING - INVERTING setting probably backwards");
gcode.refresh_cmd_timeout();
if (deploy_state != stow_state) {
SERIAL_PROTOCOLLNPGM("BLTouch clone detected");
if (deploy_state) {
@ -182,8 +180,7 @@ inline void servo_probe_test() {
safe_delay(2);
if (0 == j % (500 * 1)) // keep cmd_timeout happy
gcode.refresh_cmd_timeout();
if (0 == j % (500 * 1)) gcode.reset_stepper_timeout(); // Keep steppers powered
if (deploy_state != READ(PROBE_TEST_PIN)) { // probe triggered

View File

@ -43,7 +43,7 @@ GcodeSuite gcode;
#include "../Marlin.h" // for idle() and suspend_auto_report
uint8_t GcodeSuite::target_extruder;
millis_t GcodeSuite::previous_cmd_ms;
millis_t GcodeSuite::previous_move_ms;
bool GcodeSuite::axis_relative_modes[] = AXIS_RELATIVE_MODES;
@ -121,8 +121,7 @@ void GcodeSuite::get_destination_from_command() {
* Dwell waits immediately. It does not synchronize. Use M400 instead of G4
*/
void GcodeSuite::dwell(millis_t time) {
refresh_cmd_timeout();
time += previous_cmd_ms;
time += millis();
while (PENDING(millis(), time)) idle();
}
@ -735,6 +734,8 @@ void GcodeSuite::process_next_command() {
#endif
}
reset_stepper_timeout(); // Keep steppers powered
// Parse the next command in the queue
parser.parse(current_command);
process_parsed_command();

View File

@ -280,8 +280,8 @@ public:
static bool select_coordinate_system(const int8_t _new);
#endif
static millis_t previous_cmd_ms;
FORCE_INLINE static void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
static millis_t previous_move_ms;
FORCE_INLINE static void reset_stepper_timeout() { previous_move_ms = millis(); }
static bool get_target_extruder_from_command();
static void get_destination_from_command();

View File

@ -75,10 +75,9 @@ void GcodeSuite::M0_M1() {
wait_for_user = true;
stepper.synchronize();
refresh_cmd_timeout();
if (ms > 0) {
ms += previous_cmd_ms; // wait until this time for a click
ms += previous_move_ms; // wait until this time for a click
while (PENDING(millis(), ms) && wait_for_user) idle();
}
else {

View File

@ -269,7 +269,7 @@ void GcodeSuite::G2_G3(const bool clockwise) {
// Send the arc to the planner
plan_arc(destination, arc_offset, clockwise);
refresh_cmd_timeout();
reset_stepper_timeout();
}
else {
// Bad arguments

View File

@ -204,7 +204,6 @@ void ok_to_send() {
const int16_t port = command_queue_port[cmd_queue_index_r];
if (port < 0) return;
#endif
gcode.refresh_cmd_timeout();
if (!send_ok[cmd_queue_index_r]) return;
SERIAL_PROTOCOLPGM_P(port, MSG_OK);
#if ENABLED(ADVANCED_OK)

View File

@ -185,7 +185,7 @@ void GcodeSuite::M109() {
}
idle();
refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
reset_stepper_timeout(); // Keep steppers powered
const float temp = thermalManager.degHotend(target_extruder);

View File

@ -122,7 +122,7 @@ void GcodeSuite::M190() {
}
idle();
refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
reset_stepper_timeout(); // Keep steppers powered
const float temp = thermalManager.degBed();