|
|
@ -122,6 +122,7 @@ |
|
|
|
* M119 - Report endstops status. |
|
|
|
* M120 - Enable endstops detection. |
|
|
|
* M121 - Disable endstops detection. |
|
|
|
* M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) |
|
|
|
* M126 - Solenoid Air Valve Open. (Requires BARICUDA) |
|
|
|
* M127 - Solenoid Air Valve Closed. (Requires BARICUDA) |
|
|
|
* M128 - EtoP Open. (Requires BARICUDA) |
|
|
@ -150,7 +151,7 @@ |
|
|
|
* M208 - Set Recover (unretract) Additional (!) Length: S<length> and Feedrate: F<units/min>. (Requires FWRETRACT) |
|
|
|
* M209 - Turn Automatic Retract Detection on/off: S<0|1> (For slicers that don't support G10/11). (Requires FWRETRACT) |
|
|
|
Every normal extrude-only move will be classified as retract depending on the direction. |
|
|
|
* M211 - Enable, Disable, and/or Report software endstops: S<0|1> |
|
|
|
* M211 - Enable, Disable, and/or Report software endstops: S<0|1> (Requires MIN_SOFTWARE_ENDSTOPS or MAX_SOFTWARE_ENDSTOPS) |
|
|
|
* M218 - Set a tool offset: "M218 T<index> X<offset> Y<offset>". (Requires 2 or more extruders) |
|
|
|
* M220 - Set Feedrate Percentage: "M220 S<percent>" (i.e., "FR" on the LCD) |
|
|
|
* M221 - Set Flow Percentage: "M221 S<percent>" |
|
|
@ -199,13 +200,11 @@ |
|
|
|
* M350 - Set microstepping mode. (Requires digital microstepping pins.) |
|
|
|
* M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.) |
|
|
|
* |
|
|
|
* ************ SCARA Specific - This can change to suit future G-code regulations |
|
|
|
* M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration) |
|
|
|
* M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) |
|
|
|
* M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration) |
|
|
|
* M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) |
|
|
|
* M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) |
|
|
|
* ************* SCARA End *************** |
|
|
|
* |
|
|
|
* ************ Custom codes - This can change to suit future G-code regulations |
|
|
|
* M100 - Watch Free Memory (For Debugging). (Requires M100_FREE_MEMORY_WATCHER) |
|
|
@ -448,7 +447,7 @@ volatile bool wait_for_heatup = true; |
|
|
|
|
|
|
|
const char errormagic[] PROGMEM = "Error:"; |
|
|
|
const char echomagic[] PROGMEM = "echo:"; |
|
|
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; |
|
|
|
const char axis_codes[XYZE] = {'X', 'Y', 'Z', 'E'}; |
|
|
|
|
|
|
|
// Number of characters read in the current line of serial input
|
|
|
|
static int serial_count = 0; |
|
|
@ -690,7 +689,7 @@ void get_cartesian_from_steppers(); |
|
|
|
void set_current_from_steppers_for_axis(const AxisEnum axis); |
|
|
|
|
|
|
|
#if ENABLED(ARC_SUPPORT) |
|
|
|
void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise); |
|
|
|
void plan_arc(float target[XYZE], float* offset, uint8_t clockwise); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(BEZIER_CURVE_SUPPORT) |
|
|
@ -1333,7 +1332,7 @@ bool get_target_extruder_from_command(int code) { |
|
|
|
|
|
|
|
static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
|
|
|
|
static bool active_extruder_parked = false; // used in mode 1 & 2
|
|
|
|
static float raised_parked_position[NUM_AXIS]; // used in mode 1
|
|
|
|
static float raised_parked_position[XYZE]; // used in mode 1
|
|
|
|
static millis_t delayed_move_time = 0; // used in mode 1
|
|
|
|
static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
|
|
|
|
static float duplicate_extruder_temp_offset = 0; // used in mode 2
|
|
|
@ -4667,6 +4666,45 @@ inline void gcode_M17() { |
|
|
|
enable_all_steppers(); |
|
|
|
} |
|
|
|
|
|
|
|
#if IS_KINEMATIC |
|
|
|
#define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder) |
|
|
|
#else |
|
|
|
#define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S) |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(PARK_HEAD_ON_PAUSE) |
|
|
|
float resume_position[XYZE]; |
|
|
|
bool move_away_flag = false; |
|
|
|
|
|
|
|
inline void move_back_on_resume() { |
|
|
|
if (!move_away_flag) return; |
|
|
|
move_away_flag = false; |
|
|
|
|
|
|
|
// Set extruder to saved position
|
|
|
|
destination[E_AXIS] = current_position[E_AXIS] = resume_position[E_AXIS]; |
|
|
|
planner.set_e_position_mm(current_position[E_AXIS]); |
|
|
|
|
|
|
|
#if IS_KINEMATIC |
|
|
|
// Move XYZ to starting position
|
|
|
|
planner.buffer_line_kinematic(lastpos, FILAMENT_CHANGE_XY_FEEDRATE, active_extruder); |
|
|
|
#else |
|
|
|
// Move XY to starting position, then Z
|
|
|
|
destination[X_AXIS] = resume_position[X_AXIS]; |
|
|
|
destination[Y_AXIS] = resume_position[Y_AXIS]; |
|
|
|
RUNPLAN(FILAMENT_CHANGE_XY_FEEDRATE); |
|
|
|
destination[Z_AXIS] = resume_position[Z_AXIS]; |
|
|
|
RUNPLAN(FILAMENT_CHANGE_Z_FEEDRATE); |
|
|
|
#endif |
|
|
|
stepper.synchronize(); |
|
|
|
|
|
|
|
#if ENABLED(FILAMENT_RUNOUT_SENSOR) |
|
|
|
filament_ran_out = false; |
|
|
|
#endif |
|
|
|
set_current_to_destination(); |
|
|
|
} |
|
|
|
|
|
|
|
#endif // PARK_HEAD_ON_PAUSE
|
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT) |
|
|
|
|
|
|
|
/**
|
|
|
@ -4694,9 +4732,13 @@ inline void gcode_M17() { |
|
|
|
inline void gcode_M23() { card.openFile(current_command_args, true); } |
|
|
|
|
|
|
|
/**
|
|
|
|
* M24: Start SD Print |
|
|
|
* M24: Start or Resume SD Print |
|
|
|
*/ |
|
|
|
inline void gcode_M24() { |
|
|
|
#if ENABLED(PARK_HEAD_ON_PAUSE) |
|
|
|
move_back_on_resume(); |
|
|
|
#endif |
|
|
|
|
|
|
|
card.startFileprint(); |
|
|
|
print_job_timer.start(); |
|
|
|
} |
|
|
@ -4704,7 +4746,14 @@ inline void gcode_M17() { |
|
|
|
/**
|
|
|
|
* M25: Pause SD Print |
|
|
|
*/ |
|
|
|
inline void gcode_M25() { card.pauseSDPrint(); } |
|
|
|
inline void gcode_M25() { |
|
|
|
card.pauseSDPrint(); |
|
|
|
print_job_timer.pause(); |
|
|
|
|
|
|
|
#if ENABLED(PARK_HEAD_ON_PAUSE) |
|
|
|
enqueue_and_echo_commands_P(PSTR("M125")); // Must be enqueued with pauseSDPrint set to be last in the buffer
|
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|
* M26: Set SD Card file index |
|
|
@ -5918,12 +5967,7 @@ inline void gcode_M18_M84() { |
|
|
|
if (code_seen('Y')) disable_y(); |
|
|
|
if (code_seen('Z')) disable_z(); |
|
|
|
#if ((E0_ENABLE_PIN != X_ENABLE_PIN) && (E1_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS
|
|
|
|
if (code_seen('E')) { |
|
|
|
disable_e0(); |
|
|
|
disable_e1(); |
|
|
|
disable_e2(); |
|
|
|
disable_e3(); |
|
|
|
} |
|
|
|
if (code_seen('E')) disable_e_steppers(); |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
@ -6089,6 +6133,111 @@ inline void gcode_M120() { endstops.enable_globally(true); } |
|
|
|
*/ |
|
|
|
inline void gcode_M121() { endstops.enable_globally(false); } |
|
|
|
|
|
|
|
#if ENABLED(PARK_HEAD_ON_PAUSE) |
|
|
|
|
|
|
|
/**
|
|
|
|
* M125: Store current position and move to filament change position. |
|
|
|
* Called on pause (by M25) to prevent material leaking onto the |
|
|
|
* object. On resume (M24) the head will be moved back and the |
|
|
|
* print will resume. |
|
|
|
* |
|
|
|
* If Marlin is compiled without SD Card support, M125 can be |
|
|
|
* used directly to pause the print and move to park position, |
|
|
|
* resuming with a button click or M108. |
|
|
|
* |
|
|
|
* L = override retract length |
|
|
|
* X = override X |
|
|
|
* Y = override Y |
|
|
|
* Z = override Z raise |
|
|
|
*/ |
|
|
|
inline void gcode_M125() { |
|
|
|
if (move_away_flag) return; // already paused
|
|
|
|
|
|
|
|
const bool job_running = print_job_timer.isRunning(); |
|
|
|
|
|
|
|
// there are blocks after this one, or sd printing
|
|
|
|
move_away_flag = job_running || planner.blocks_queued() |
|
|
|
#if ENABLED(SDSUPPORT) |
|
|
|
|| card.sdprinting |
|
|
|
#endif |
|
|
|
; |
|
|
|
|
|
|
|
if (!move_away_flag) return; // nothing to pause
|
|
|
|
|
|
|
|
// M125 can be used to pause a print too
|
|
|
|
#if ENABLED(SDSUPPORT) |
|
|
|
card.pauseSDPrint(); |
|
|
|
#endif |
|
|
|
print_job_timer.pause(); |
|
|
|
|
|
|
|
// Save current position
|
|
|
|
COPY(resume_position, current_position); |
|
|
|
|
|
|
|
set_destination_to_current(); |
|
|
|
|
|
|
|
// Initial retract before move to filament change position
|
|
|
|
destination[E_AXIS] += code_seen('L') ? code_value_axis_units(E_AXIS) : 0 |
|
|
|
#if defined(FILAMENT_CHANGE_RETRACT_LENGTH) && FILAMENT_CHANGE_RETRACT_LENGTH > 0 |
|
|
|
- (FILAMENT_CHANGE_RETRACT_LENGTH) |
|
|
|
#endif |
|
|
|
; |
|
|
|
RUNPLAN(FILAMENT_CHANGE_RETRACT_FEEDRATE); |
|
|
|
|
|
|
|
// Lift Z axis
|
|
|
|
const float z_lift = code_seen('Z') ? code_value_axis_units(Z_AXIS) : |
|
|
|
#if defined(FILAMENT_CHANGE_Z_ADD) && FILAMENT_CHANGE_Z_ADD > 0 |
|
|
|
FILAMENT_CHANGE_Z_ADD |
|
|
|
#else |
|
|
|
0 |
|
|
|
#endif |
|
|
|
; |
|
|
|
if (z_lift > 0) { |
|
|
|
destination[Z_AXIS] += z_lift; |
|
|
|
NOMORE(destination[Z_AXIS], Z_MAX_POS); |
|
|
|
RUNPLAN(FILAMENT_CHANGE_Z_FEEDRATE); |
|
|
|
} |
|
|
|
|
|
|
|
// Move XY axes to filament change position or given position
|
|
|
|
destination[X_AXIS] = code_seen('X') ? code_value_axis_units(X_AXIS) : 0 |
|
|
|
#ifdef FILAMENT_CHANGE_X_POS |
|
|
|
+ FILAMENT_CHANGE_X_POS |
|
|
|
#endif |
|
|
|
; |
|
|
|
destination[Y_AXIS] = code_seen('Y') ? code_value_axis_units(Y_AXIS) : 0 |
|
|
|
#ifdef FILAMENT_CHANGE_Y_POS |
|
|
|
+ FILAMENT_CHANGE_Y_POS |
|
|
|
#endif |
|
|
|
; |
|
|
|
|
|
|
|
#if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE) |
|
|
|
if (active_extruder > 0) { |
|
|
|
if (!code_seen('X')) destination[X_AXIS] += hotend_offset[X_AXIS][active_extruder]; |
|
|
|
if (!code_seen('Y')) destination[Y_AXIS] += hotend_offset[Y_AXIS][active_extruder]; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
clamp_to_software_endstops(destination); |
|
|
|
RUNPLAN(FILAMENT_CHANGE_XY_FEEDRATE); |
|
|
|
set_current_to_destination(); |
|
|
|
stepper.synchronize(); |
|
|
|
disable_e_steppers(); |
|
|
|
|
|
|
|
#if DISABLED(SDSUPPORT) |
|
|
|
// Wait for lcd click or M108
|
|
|
|
wait_for_user = true; |
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER); |
|
|
|
while (wait_for_user) idle(); |
|
|
|
KEEPALIVE_STATE(IN_HANDLER); |
|
|
|
|
|
|
|
// Return to print position and continue
|
|
|
|
move_back_on_resume(); |
|
|
|
if (job_running) print_job_timer.start(); |
|
|
|
move_away_flag = false; |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
#endif // PARK_HEAD_ON_PAUSE
|
|
|
|
|
|
|
|
#if ENABLED(BLINKM) || ENABLED(RGB_LED) |
|
|
|
|
|
|
|
void set_led_color(const uint8_t r, const uint8_t g, const uint8_t b) { |
|
|
@ -7217,10 +7366,12 @@ inline void gcode_M503() { |
|
|
|
|
|
|
|
#if ENABLED(FILAMENT_CHANGE_FEATURE) |
|
|
|
|
|
|
|
millis_t next_buzz = 0; |
|
|
|
unsigned long int runout_beep = 0; |
|
|
|
void filament_change_beep(const bool init=false) { |
|
|
|
static millis_t next_buzz = 0; |
|
|
|
static uint16_t runout_beep = 0; |
|
|
|
|
|
|
|
if (init) next_buzz = runout_beep = 0; |
|
|
|
|
|
|
|
void filament_change_beep() { |
|
|
|
const millis_t ms = millis(); |
|
|
|
if (ELAPSED(ms, next_buzz)) { |
|
|
|
if (runout_beep <= FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS + 5) { // Only beep as long as we're supposed to
|
|
|
@ -7256,25 +7407,18 @@ inline void gcode_M503() { |
|
|
|
busy_doing_M600 = true; // Stepper Motors can't timeout when this is set
|
|
|
|
|
|
|
|
// Pause the print job timer
|
|
|
|
bool job_running = print_job_timer.isRunning(); |
|
|
|
const bool job_running = print_job_timer.isRunning(); |
|
|
|
|
|
|
|
print_job_timer.pause(); |
|
|
|
|
|
|
|
// Show initial message and wait for synchronize steppers
|
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INIT); |
|
|
|
stepper.synchronize(); |
|
|
|
|
|
|
|
float lastpos[NUM_AXIS]; |
|
|
|
|
|
|
|
// Save current position of all axes
|
|
|
|
LOOP_XYZE(i) |
|
|
|
lastpos[i] = destination[i] = current_position[i]; |
|
|
|
|
|
|
|
// Define runplan for move axes
|
|
|
|
#if IS_KINEMATIC |
|
|
|
#define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder); |
|
|
|
#else |
|
|
|
#define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S); |
|
|
|
#endif |
|
|
|
float lastpos[XYZE]; |
|
|
|
COPY(lastpos, current_position); |
|
|
|
set_destination_to_current(); |
|
|
|
|
|
|
|
// Initial retract before move to filament change position
|
|
|
|
destination[E_AXIS] += code_seen('E') ? code_value_axis_units(E_AXIS) : 0 |
|
|
@ -7328,26 +7472,25 @@ inline void gcode_M503() { |
|
|
|
|
|
|
|
// Synchronize steppers and then disable extruders steppers for manual filament changing
|
|
|
|
stepper.synchronize(); |
|
|
|
disable_e0(); |
|
|
|
disable_e1(); |
|
|
|
disable_e2(); |
|
|
|
disable_e3(); |
|
|
|
disable_e_steppers(); |
|
|
|
delay(100); |
|
|
|
|
|
|
|
millis_t nozzle_timeout = millis() + FILAMENT_CHANGE_NOZZLE_TIMEOUT * 1000L; |
|
|
|
millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000L; |
|
|
|
bool nozzle_timed_out = false; |
|
|
|
float temps[4]; |
|
|
|
|
|
|
|
// Wait for filament insert by user and press button
|
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); |
|
|
|
|
|
|
|
#if HAS_BUZZER |
|
|
|
filament_change_beep(true); |
|
|
|
#endif |
|
|
|
|
|
|
|
idle(); |
|
|
|
|
|
|
|
wait_for_user = true; // LCD click or M108 will clear this
|
|
|
|
next_buzz = 0; |
|
|
|
runout_beep = 0; |
|
|
|
HOTEND_LOOP() temps[e] = thermalManager.target_temperature[e]; // Save nozzle temps
|
|
|
|
|
|
|
|
wait_for_user = true; // LCD click or M108 will clear this
|
|
|
|
while (wait_for_user) { |
|
|
|
millis_t current_ms = millis(); |
|
|
|
if (nozzle_timed_out) |
|
|
@ -7389,9 +7532,11 @@ inline void gcode_M503() { |
|
|
|
if (nozzle_timed_out) |
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); |
|
|
|
|
|
|
|
#if HAS_BUZZER |
|
|
|
filament_change_beep(true); |
|
|
|
#endif |
|
|
|
|
|
|
|
wait_for_user = true; // LCD click or M108 will clear this
|
|
|
|
next_buzz = 0; |
|
|
|
runout_beep = 0; |
|
|
|
while (wait_for_user && nozzle_timed_out) { |
|
|
|
#if HAS_BUZZER |
|
|
|
filament_change_beep(); |
|
|
@ -7583,7 +7728,7 @@ inline void gcode_M503() { |
|
|
|
* Report driver currents when no axis specified |
|
|
|
*/ |
|
|
|
inline void gcode_M906() { |
|
|
|
uint16_t values[NUM_AXIS]; |
|
|
|
uint16_t values[XYZE]; |
|
|
|
LOOP_XYZE(i) |
|
|
|
values[i] = code_seen(axis_codes[i]) ? code_value_int() : 0; |
|
|
|
|
|
|
@ -8557,6 +8702,11 @@ void process_next_command() { |
|
|
|
break; |
|
|
|
#endif // FAN_COUNT > 0
|
|
|
|
|
|
|
|
#if ENABLED(PARK_HEAD_ON_PAUSE) |
|
|
|
case 125: // M125: Store current position and move to filament change position
|
|
|
|
gcode_M125(); break; |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(BARICUDA) |
|
|
|
// PWM for HEATER_1_PIN
|
|
|
|
#if HAS_HEATER_1 |
|
|
@ -9501,7 +9651,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { |
|
|
|
* This calls planner.buffer_line several times, adding |
|
|
|
* small incremental moves for DELTA or SCARA. |
|
|
|
*/ |
|
|
|
inline bool prepare_kinematic_move_to(float ltarget[NUM_AXIS]) { |
|
|
|
inline bool prepare_kinematic_move_to(float ltarget[XYZE]) { |
|
|
|
|
|
|
|
// Get the top feedrate of the move in the XY plane
|
|
|
|
float _feedrate_mm_s = MMS_SCALED(feedrate_mm_s); |
|
|
@ -9513,7 +9663,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { |
|
|
|
} |
|
|
|
|
|
|
|
// Get the cartesian distances moved in XYZE
|
|
|
|
float difference[NUM_AXIS]; |
|
|
|
float difference[XYZE]; |
|
|
|
LOOP_XYZE(i) difference[i] = ltarget[i] - current_position[i]; |
|
|
|
|
|
|
|
// Get the linear distance in XYZ
|
|
|
@ -9738,7 +9888,7 @@ void prepare_move_to_destination() { |
|
|
|
* options for G2/G3 arc generation. In future these options may be GCode tunable. |
|
|
|
*/ |
|
|
|
void plan_arc( |
|
|
|
float logical[NUM_AXIS], // Destination position
|
|
|
|
float logical[XYZE], // Destination position
|
|
|
|
float* offset, // Center of rotation relative to current_position
|
|
|
|
uint8_t clockwise // Clockwise?
|
|
|
|
) { |
|
|
@ -10117,16 +10267,20 @@ void enable_all_steppers() { |
|
|
|
enable_e3(); |
|
|
|
} |
|
|
|
|
|
|
|
void disable_all_steppers() { |
|
|
|
disable_x(); |
|
|
|
disable_y(); |
|
|
|
disable_z(); |
|
|
|
void disable_e_steppers() { |
|
|
|
disable_e0(); |
|
|
|
disable_e1(); |
|
|
|
disable_e2(); |
|
|
|
disable_e3(); |
|
|
|
} |
|
|
|
|
|
|
|
void disable_all_steppers() { |
|
|
|
disable_x(); |
|
|
|
disable_y(); |
|
|
|
disable_z(); |
|
|
|
disable_e_steppers(); |
|
|
|
} |
|
|
|
|
|
|
|
#if ENABLED(AUTOMATIC_CURRENT_CONTROL) |
|
|
|
|
|
|
|
void automatic_current_control(const TMC2130Stepper &st) { |
|
|
@ -10234,10 +10388,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { |
|
|
|
disable_z(); |
|
|
|
#endif |
|
|
|
#if ENABLED(DISABLE_INACTIVE_E) |
|
|
|
disable_e0(); |
|
|
|
disable_e1(); |
|
|
|
disable_e2(); |
|
|
|
disable_e3(); |
|
|
|
disable_e_steppers(); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|