Move dwell to gcode

This commit is contained in:
Scott Lahteine 2017-09-15 20:44:40 -05:00
parent 4f1eadf41f
commit 51f195e698
7 changed files with 25 additions and 20 deletions

View File

@ -163,7 +163,6 @@ volatile bool wait_for_heatup = true;
#endif
// Inactivity shutdown
millis_t previous_cmd_ms = 0;
static millis_t max_inactive_time = 0;
static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
@ -366,16 +365,6 @@ void suicide() {
***************** GCode Handlers *****************
**************************************************/
#if ENABLED(ARC_SUPPORT)
#include "gcode/motion/G2_G3.h"
#endif
void dwell(millis_t time) {
gcode.refresh_cmd_timeout();
time += previous_cmd_ms;
while (PENDING(millis(), time)) idle();
}
#include "gcode/motion/G4.h"
#if ENABLED(BEZIER_CURVE_SUPPORT)
@ -882,7 +871,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
const millis_t ms = millis();
if (max_inactive_time && ELAPSED(ms, previous_cmd_ms + max_inactive_time)) {
if (max_inactive_time && ELAPSED(ms, gcode.previous_cmd_ms + max_inactive_time)) {
SERIAL_ERROR_START();
SERIAL_ECHOLNPAIR(MSG_KILL_INACTIVE_TIME, parser.command_ptr);
kill(PSTR(MSG_KILLED));
@ -895,7 +884,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
#define MOVE_AWAY_TEST true
#endif
if (MOVE_AWAY_TEST && stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time)
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();
@ -965,7 +954,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
#endif
#if ENABLED(EXTRUDER_RUNOUT_PREVENT)
if (ELAPSED(ms, previous_cmd_ms + (EXTRUDER_RUNOUT_SECONDS) * 1000UL)
if (ELAPSED(ms, gcode.previous_cmd_ms + (EXTRUDER_RUNOUT_SECONDS) * 1000UL)
&& thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP) {
#if ENABLED(SWITCHING_EXTRUDER)
const bool oldstatus = E0_ENABLE_READ;

View File

@ -52,10 +52,10 @@
*/
// Wait for spindle to come up to speed
inline void delay_for_power_up() { dwell(SPINDLE_LASER_POWERUP_DELAY); }
inline void delay_for_power_up() { gcode.dwell(SPINDLE_LASER_POWERUP_DELAY); }
// Wait for spindle to stop turning
inline void delay_for_power_down() { dwell(SPINDLE_LASER_POWERDOWN_DELAY); }
inline void delay_for_power_down() { gcode.dwell(SPINDLE_LASER_POWERDOWN_DELAY); }
/**
* ocr_val_mode() is used for debugging and to get the points needed to compute the RPM vs ocr_val line

View File

@ -31,12 +31,13 @@ GcodeSuite gcode;
#include "parser.h"
#include "queue.h"
#include "../module/motion.h"
#include "../module/printcounter.h"
#if ENABLED(PRINTCOUNTER)
#include "../module/printcounter.h"
#endif
#include "../Marlin.h" // for idle()
uint8_t GcodeSuite::target_extruder;
millis_t GcodeSuite::previous_cmd_ms;
@ -99,6 +100,15 @@ void GcodeSuite::get_destination_from_command() {
#endif
}
/**
* 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;
while (PENDING(millis(), time)) idle();
}
//
// Placeholders for non-migrated codes
//

View File

@ -299,6 +299,8 @@ public:
#define KEEPALIVE_STATE(n) NOOP
#endif
void dwell(millis_t time);
private:
static void G0_G1(

View File

@ -67,7 +67,7 @@ void gcode_M0_M1() {
gcode.refresh_cmd_timeout();
if (ms > 0) {
ms += previous_cmd_ms; // wait until this time for a click
ms += gcode.previous_cmd_ms; // wait until this time for a click
while (PENDING(millis(), ms) && wait_for_user) idle();
}
else {

View File

@ -33,5 +33,5 @@ void gcode_G4() {
if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
dwell(dwell_ms);
gcode.dwell(dwell_ms);
}

View File

@ -30,6 +30,10 @@
#include "../inc/MarlinConfig.h"
#if ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
#include "../gcode/gcode.h" // for dwell()
#endif
#if ENABLED(SWITCHING_EXTRUDER)
#if EXTRUDERS > 3
@ -74,7 +78,7 @@
default: OUT_WRITE(SOL0_PIN, state); break;
}
#if PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
dwell(PARKING_EXTRUDER_SOLENOIDS_DELAY);
gcode.dwell(PARKING_EXTRUDER_SOLENOIDS_DELAY);
#endif
}