|
@ -294,6 +294,7 @@ static char command_queue[BUFSIZE][MAX_CMD_SIZE]; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
const float homing_feedrate[] = HOMING_FEEDRATE; |
|
|
const float homing_feedrate[] = HOMING_FEEDRATE; |
|
|
|
|
|
|
|
|
bool axis_relative_modes[] = AXIS_RELATIVE_MODES; |
|
|
bool axis_relative_modes[] = AXIS_RELATIVE_MODES; |
|
|
int feedrate_multiplier = 100; //100->1 200->2
|
|
|
int feedrate_multiplier = 100; //100->1 200->2
|
|
|
int saved_feedrate_multiplier; |
|
|
int saved_feedrate_multiplier; |
|
@ -490,6 +491,10 @@ static uint8_t target_extruder; |
|
|
static bool filament_ran_out = false; |
|
|
static bool filament_ran_out = false; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(FILAMENT_CHANGE_FEATURE) |
|
|
|
|
|
FilamentChangeMenuResponse filament_change_menu_response; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
static bool send_ok[BUFSIZE]; |
|
|
static bool send_ok[BUFSIZE]; |
|
|
|
|
|
|
|
|
#if HAS_SERVOS |
|
|
#if HAS_SERVOS |
|
@ -1564,9 +1569,8 @@ inline void line_to_z(float zPosition) { |
|
|
inline void line_to_destination(float mm_m) { |
|
|
inline void line_to_destination(float mm_m) { |
|
|
planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], mm_m / 60, active_extruder); |
|
|
planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], mm_m / 60, active_extruder); |
|
|
} |
|
|
} |
|
|
inline void line_to_destination() { |
|
|
inline void line_to_destination() { line_to_destination(feedrate); } |
|
|
line_to_destination(feedrate); |
|
|
|
|
|
} |
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* sync_plan_position |
|
|
* sync_plan_position |
|
|
* Set planner / stepper positions to the cartesian current_position. |
|
|
* Set planner / stepper positions to the cartesian current_position. |
|
@ -3123,7 +3127,7 @@ inline void gcode_G28() { |
|
|
enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet, MeshSetZOffset, MeshReset }; |
|
|
enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet, MeshSetZOffset, MeshReset }; |
|
|
|
|
|
|
|
|
inline void _mbl_goto_xy(float x, float y) { |
|
|
inline void _mbl_goto_xy(float x, float y) { |
|
|
saved_feedrate = feedrate; |
|
|
float old_feedrate = feedrate; |
|
|
feedrate = homing_feedrate[X_AXIS]; |
|
|
feedrate = homing_feedrate[X_AXIS]; |
|
|
|
|
|
|
|
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z |
|
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z |
|
@ -3144,7 +3148,7 @@ inline void gcode_G28() { |
|
|
line_to_current_position(); |
|
|
line_to_current_position(); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
feedrate = saved_feedrate; |
|
|
feedrate = old_feedrate; |
|
|
stepper.synchronize(); |
|
|
stepper.synchronize(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -6131,7 +6135,7 @@ inline void gcode_M503() { |
|
|
|
|
|
|
|
|
#endif // HAS_BED_PROBE
|
|
|
#endif // HAS_BED_PROBE
|
|
|
|
|
|
|
|
|
#if ENABLED(FILAMENTCHANGEENABLE) |
|
|
#if ENABLED(FILAMENT_CHANGE_FEATURE) |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* M600: Pause for filament change |
|
|
* M600: Pause for filament change |
|
@ -6153,129 +6157,160 @@ inline void gcode_M503() { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Show initial message and wait for synchronize steppers
|
|
|
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INIT); |
|
|
|
|
|
stepper.synchronize(); |
|
|
|
|
|
|
|
|
float lastpos[NUM_AXIS]; |
|
|
float lastpos[NUM_AXIS]; |
|
|
#if ENABLED(DELTA) |
|
|
|
|
|
float fr60 = feedrate / 60; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < NUM_AXIS; i++) |
|
|
// Save current position of all axes
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_AXIS; i++) |
|
|
lastpos[i] = destination[i] = current_position[i]; |
|
|
lastpos[i] = destination[i] = current_position[i]; |
|
|
|
|
|
|
|
|
|
|
|
// Define runplan for move axes
|
|
|
#if ENABLED(DELTA) |
|
|
#if ENABLED(DELTA) |
|
|
#define RUNPLAN calculate_delta(destination); \ |
|
|
#define RUNPLAN(RATE) calculate_delta(destination); \ |
|
|
planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], fr60, active_extruder); |
|
|
planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], RATE, active_extruder); |
|
|
#else |
|
|
#else |
|
|
#define RUNPLAN line_to_destination(); |
|
|
#define RUNPLAN(RATE) line_to_destination(RATE * 60); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
//retract by E
|
|
|
KEEPALIVE_STATE(IN_HANDLER); |
|
|
|
|
|
|
|
|
|
|
|
// Initial retract before move to filament change position
|
|
|
if (code_seen('E')) destination[E_AXIS] += code_value_axis_units(E_AXIS); |
|
|
if (code_seen('E')) destination[E_AXIS] += code_value_axis_units(E_AXIS); |
|
|
#ifdef FILAMENTCHANGE_FIRSTRETRACT |
|
|
#if defined(FILAMENT_CHANGE_RETRACT_LENGTH) && FILAMENT_CHANGE_RETRACT_LENGTH > 0 |
|
|
else destination[E_AXIS] += FILAMENTCHANGE_FIRSTRETRACT; |
|
|
else destination[E_AXIS] -= FILAMENT_CHANGE_RETRACT_LENGTH; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
RUNPLAN; |
|
|
RUNPLAN(FILAMENT_CHANGE_RETRACT_FEEDRATE); |
|
|
|
|
|
|
|
|
//lift Z
|
|
|
// Lift Z axis
|
|
|
if (code_seen('Z')) destination[Z_AXIS] += code_value_axis_units(Z_AXIS); |
|
|
float z_lift = code_seen('Z') ? code_value_axis_units(Z_AXIS) : |
|
|
#ifdef FILAMENTCHANGE_ZADD |
|
|
#if defined(FILAMENT_CHANGE_Z_ADD) && FILAMENT_CHANGE_Z_ADD > 0 |
|
|
else destination[Z_AXIS] += FILAMENTCHANGE_ZADD; |
|
|
FILAMENT_CHANGE_Z_ADD |
|
|
|
|
|
#else |
|
|
|
|
|
0 |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
RUNPLAN; |
|
|
if (z_lift > 0) { |
|
|
|
|
|
destination[Z_AXIS] += z_lift; |
|
|
|
|
|
NOMORE(destination[Z_AXIS], Z_MAX_POS); |
|
|
|
|
|
RUNPLAN(FILAMENT_CHANGE_Z_FEEDRATE); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//move xy
|
|
|
// Move XY axes to filament exchange position
|
|
|
if (code_seen('X')) destination[X_AXIS] = code_value_axis_units(X_AXIS); |
|
|
if (code_seen('X')) destination[X_AXIS] = code_value_axis_units(X_AXIS); |
|
|
#ifdef FILAMENTCHANGE_XPOS |
|
|
#ifdef FILAMENT_CHANGE_X_POS |
|
|
else destination[X_AXIS] = FILAMENTCHANGE_XPOS; |
|
|
else destination[X_AXIS] = FILAMENT_CHANGE_X_POS; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
if (code_seen('Y')) destination[Y_AXIS] = code_value_axis_units(Y_AXIS); |
|
|
if (code_seen('Y')) destination[Y_AXIS] = code_value_axis_units(Y_AXIS); |
|
|
#ifdef FILAMENTCHANGE_YPOS |
|
|
#ifdef FILAMENT_CHANGE_Y_POS |
|
|
else destination[Y_AXIS] = FILAMENTCHANGE_YPOS; |
|
|
else destination[Y_AXIS] = FILAMENT_CHANGE_Y_POS; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
RUNPLAN; |
|
|
RUNPLAN(FILAMENT_CHANGE_XY_FEEDRATE); |
|
|
|
|
|
|
|
|
|
|
|
stepper.synchronize(); |
|
|
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_UNLOAD); |
|
|
|
|
|
|
|
|
|
|
|
// Unload filament
|
|
|
if (code_seen('L')) destination[E_AXIS] += code_value_axis_units(E_AXIS); |
|
|
if (code_seen('L')) destination[E_AXIS] += code_value_axis_units(E_AXIS); |
|
|
#ifdef FILAMENTCHANGE_FINALRETRACT |
|
|
#if defined(FILAMENT_CHANGE_UNLOAD_LENGTH) && FILAMENT_CHANGE_UNLOAD_LENGTH > 0 |
|
|
else destination[E_AXIS] += FILAMENTCHANGE_FINALRETRACT; |
|
|
else destination[E_AXIS] -= FILAMENT_CHANGE_UNLOAD_LENGTH; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
RUNPLAN; |
|
|
RUNPLAN(FILAMENT_CHANGE_UNLOAD_FEEDRATE); |
|
|
|
|
|
|
|
|
//finish moves
|
|
|
// Synchronize steppers and then disable extruders steppers for manual filament changing
|
|
|
stepper.synchronize(); |
|
|
stepper.synchronize(); |
|
|
//disable extruder steppers so filament can be removed
|
|
|
|
|
|
disable_e0(); |
|
|
disable_e0(); |
|
|
disable_e1(); |
|
|
disable_e1(); |
|
|
disable_e2(); |
|
|
disable_e2(); |
|
|
disable_e3(); |
|
|
disable_e3(); |
|
|
delay(100); |
|
|
delay(100); |
|
|
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE); |
|
|
|
|
|
#if DISABLED(AUTO_FILAMENT_CHANGE) |
|
|
|
|
|
millis_t next_tick = 0; |
|
|
millis_t next_tick = 0; |
|
|
#endif |
|
|
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER); |
|
|
// Wait for filament insert by user and press button
|
|
|
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); |
|
|
|
|
|
|
|
|
while (!lcd_clicked()) { |
|
|
while (!lcd_clicked()) { |
|
|
#if DISABLED(AUTO_FILAMENT_CHANGE) |
|
|
#if HAS_BUZZER |
|
|
millis_t ms = millis(); |
|
|
millis_t ms = millis(); |
|
|
if (ELAPSED(ms, next_tick)) { |
|
|
if (ms >= next_tick) { |
|
|
lcd_quick_feedback(); |
|
|
buzzer.tone(300, 2000); |
|
|
next_tick = ms + 2500UL; // feedback every 2.5s while waiting
|
|
|
next_tick = ms + 2500; // Beep every 2.5s while waiting
|
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
idle(true); |
|
|
idle(true); |
|
|
#else |
|
|
} |
|
|
current_position[E_AXIS] += AUTO_FILAMENT_CHANGE_LENGTH; |
|
|
delay(100); |
|
|
destination[E_AXIS] = current_position[E_AXIS]; |
|
|
while (lcd_clicked()) idle(true); |
|
|
line_to_destination(AUTO_FILAMENT_CHANGE_FEEDRATE); |
|
|
delay(100); |
|
|
stepper.synchronize(); |
|
|
|
|
|
|
|
|
// Show load message
|
|
|
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD); |
|
|
|
|
|
|
|
|
|
|
|
// Load filament
|
|
|
|
|
|
if (code_seen('L')) destination[E_AXIS] -= code_value_axis_units(E_AXIS); |
|
|
|
|
|
#if defined(FILAMENT_CHANGE_LOAD_LENGTH) && FILAMENT_CHANGE_LOAD_LENGTH > 0 |
|
|
|
|
|
else destination[E_AXIS] += FILAMENT_CHANGE_LOAD_LENGTH; |
|
|
#endif |
|
|
#endif |
|
|
} // while(!lcd_clicked)
|
|
|
|
|
|
KEEPALIVE_STATE(IN_HANDLER); |
|
|
|
|
|
lcd_quick_feedback(); // click sound feedback
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(AUTO_FILAMENT_CHANGE) |
|
|
RUNPLAN(FILAMENT_CHANGE_LOAD_FEEDRATE); |
|
|
current_position[E_AXIS] = 0; |
|
|
|
|
|
stepper.synchronize(); |
|
|
stepper.synchronize(); |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
//return to normal
|
|
|
#if defined(FILAMENT_CHANGE_EXTRUDE_LENGTH) && FILAMENT_CHANGE_EXTRUDE_LENGTH > 0 |
|
|
if (code_seen('L')) destination[E_AXIS] -= code_value_axis_units(E_AXIS); |
|
|
do { |
|
|
#ifdef FILAMENTCHANGE_FINALRETRACT |
|
|
// Extrude filament to get into hotend
|
|
|
else destination[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT; |
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_EXTRUDE); |
|
|
|
|
|
destination[E_AXIS] += FILAMENT_CHANGE_EXTRUDE_LENGTH; |
|
|
|
|
|
RUNPLAN(FILAMENT_CHANGE_EXTRUDE_FEEDRATE); |
|
|
|
|
|
stepper.synchronize(); |
|
|
|
|
|
// Ask user if more filament should be extruded
|
|
|
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER); |
|
|
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_OPTION); |
|
|
|
|
|
while (filament_change_menu_response == FILAMENT_CHANGE_RESPONSE_WAIT_FOR) idle(true); |
|
|
|
|
|
KEEPALIVE_STATE(IN_HANDLER); |
|
|
|
|
|
} while (filament_change_menu_response != FILAMENT_CHANGE_RESPONSE_RESUME_PRINT); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
current_position[E_AXIS] = destination[E_AXIS]; //the long retract of L is compensated by manual filament feeding
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_RESUME); |
|
|
sync_plan_position_e(); |
|
|
|
|
|
|
|
|
|
|
|
RUNPLAN; //should do nothing
|
|
|
KEEPALIVE_STATE(IN_HANDLER); |
|
|
|
|
|
|
|
|
lcd_reset_alert_level(); |
|
|
// Set extruder to saved position
|
|
|
|
|
|
current_position[E_AXIS] = lastpos[E_AXIS]; |
|
|
|
|
|
destination[E_AXIS] = lastpos[E_AXIS]; |
|
|
|
|
|
planner.set_e_position_mm(current_position[E_AXIS]); |
|
|
|
|
|
|
|
|
#if ENABLED(DELTA) |
|
|
#if ENABLED(DELTA) |
|
|
// Move XYZ to starting position, then E
|
|
|
// Move XYZ to starting position, then E
|
|
|
calculate_delta(lastpos); |
|
|
calculate_delta(lastpos); |
|
|
planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], fr60, active_extruder); |
|
|
planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], FILAMENT_CHANGE_XY_FEEDRATE, active_extruder); |
|
|
planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); |
|
|
planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], FILAMENT_CHANGE_XY_FEEDRATE, active_extruder); |
|
|
#else |
|
|
#else |
|
|
// Move XY to starting position, then Z, then E
|
|
|
// Move XY to starting position, then Z, then E
|
|
|
destination[X_AXIS] = lastpos[X_AXIS]; |
|
|
destination[X_AXIS] = lastpos[X_AXIS]; |
|
|
destination[Y_AXIS] = lastpos[Y_AXIS]; |
|
|
destination[Y_AXIS] = lastpos[Y_AXIS]; |
|
|
line_to_destination(); |
|
|
RUNPLAN(FILAMENT_CHANGE_XY_FEEDRATE); |
|
|
destination[Z_AXIS] = lastpos[Z_AXIS]; |
|
|
destination[Z_AXIS] = lastpos[Z_AXIS]; |
|
|
line_to_destination(); |
|
|
RUNPLAN(FILAMENT_CHANGE_Z_FEEDRATE); |
|
|
destination[E_AXIS] = lastpos[E_AXIS]; |
|
|
|
|
|
line_to_destination(); |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
stepper.synchronize(); |
|
|
|
|
|
|
|
|
#if ENABLED(FILAMENT_RUNOUT_SENSOR) |
|
|
#if ENABLED(FILAMENT_RUNOUT_SENSOR) |
|
|
filament_ran_out = false; |
|
|
filament_ran_out = false; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// Show status screen
|
|
|
|
|
|
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_STATUS); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endif // FILAMENTCHANGEENABLE
|
|
|
#endif // FILAMENT_CHANGE_FEATURE
|
|
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE) |
|
|
#if ENABLED(DUAL_X_CARRIAGE) |
|
|
|
|
|
|
|
@ -6464,11 +6499,11 @@ inline void gcode_T(uint8_t tmp_extruder) { |
|
|
|
|
|
|
|
|
#if HOTENDS > 1 |
|
|
#if HOTENDS > 1 |
|
|
|
|
|
|
|
|
float stored_feedrate = feedrate; |
|
|
float old_feedrate = feedrate; |
|
|
|
|
|
|
|
|
if (code_seen('F')) { |
|
|
if (code_seen('F')) { |
|
|
float next_feedrate = code_value_axis_units(X_AXIS); |
|
|
float next_feedrate = code_value_axis_units(X_AXIS); |
|
|
if (next_feedrate > 0.0) stored_feedrate = feedrate = next_feedrate; |
|
|
if (next_feedrate > 0.0) old_feedrate = feedrate = next_feedrate; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
feedrate = XY_PROBE_FEEDRATE; |
|
|
feedrate = XY_PROBE_FEEDRATE; |
|
@ -6624,7 +6659,7 @@ inline void gcode_T(uint8_t tmp_extruder) { |
|
|
enable_solenoid_on_active_extruder(); |
|
|
enable_solenoid_on_active_extruder(); |
|
|
#endif // EXT_SOLENOID
|
|
|
#endif // EXT_SOLENOID
|
|
|
|
|
|
|
|
|
feedrate = stored_feedrate; |
|
|
feedrate = old_feedrate; |
|
|
|
|
|
|
|
|
#else // !HOTENDS > 1
|
|
|
#else // !HOTENDS > 1
|
|
|
|
|
|
|
|
@ -7232,11 +7267,11 @@ void process_next_command() { |
|
|
break; |
|
|
break; |
|
|
#endif // HAS_BED_PROBE
|
|
|
#endif // HAS_BED_PROBE
|
|
|
|
|
|
|
|
|
#if ENABLED(FILAMENTCHANGEENABLE) |
|
|
#if ENABLED(FILAMENT_CHANGE_FEATURE) |
|
|
case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
|
|
|
case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
|
|
|
gcode_M600(); |
|
|
gcode_M600(); |
|
|
break; |
|
|
break; |
|
|
#endif // FILAMENTCHANGEENABLE
|
|
|
#endif // FILAMENT_CHANGE_FEATURE
|
|
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE) |
|
|
#if ENABLED(DUAL_X_CARRIAGE) |
|
|
case 605: |
|
|
case 605: |
|
@ -7993,14 +8028,14 @@ void disable_all_steppers() { |
|
|
* Standard idle routine keeps the machine alive |
|
|
* Standard idle routine keeps the machine alive |
|
|
*/ |
|
|
*/ |
|
|
void idle( |
|
|
void idle( |
|
|
#if ENABLED(FILAMENTCHANGEENABLE) |
|
|
#if ENABLED(FILAMENT_CHANGE_FEATURE) |
|
|
bool no_stepper_sleep/*=false*/ |
|
|
bool no_stepper_sleep/*=false*/ |
|
|
#endif |
|
|
#endif |
|
|
) { |
|
|
) { |
|
|
lcd_update(); |
|
|
lcd_update(); |
|
|
host_keepalive(); |
|
|
host_keepalive(); |
|
|
manage_inactivity( |
|
|
manage_inactivity( |
|
|
#if ENABLED(FILAMENTCHANGEENABLE) |
|
|
#if ENABLED(FILAMENT_CHANGE_FEATURE) |
|
|
no_stepper_sleep |
|
|
no_stepper_sleep |
|
|
#endif |
|
|
#endif |
|
|
); |
|
|
); |
|
|