Improve M600 with timeout, wait for heatup.

This commit is contained in:
Roxy-3D
2017-01-21 16:10:57 -07:00
committed by Scott Lahteine
parent 58b8e0cae7
commit 8bf0b496b9
11 changed files with 212 additions and 18 deletions

View File

@ -7290,6 +7290,28 @@ inline void gcode_M503() {
#if ENABLED(FILAMENT_CHANGE_FEATURE)
millis_t next_buzz = 0;
unsigned long int runout_beep = 0;
void filament_change_beep() {
millis_t ms = millis();
if (ms >= next_buzz) {
if (runout_beep <= FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS ) { // Only beep as long as we are supposed to!
BUZZ(300, 2000);
next_buzz = ms + 2500; // Beep every 2.5s while waiting
runout_beep++;
}
else if (runout_beep > FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS &&
runout_beep <= (FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS + 5)) { // End with a burst of short beeps
BUZZ(200, 2000);
next_buzz = ms + 400; // Beep
runout_beep++;
}
}
}
bool busy_doing_M600 = false;
/**
* M600: Pause for filament change
*
@ -7310,6 +7332,8 @@ inline void gcode_M503() {
return;
}
busy_doing_M600 = true; // Stepper Motors can't timeout when this is set
// Show initial message and wait for synchronize steppers
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INIT);
stepper.synchronize();
@ -7367,6 +7391,7 @@ inline void gcode_M503() {
stepper.synchronize();
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_UNLOAD);
idle();
// Unload filament
if (code_seen('L')) destination[E_AXIS] += code_value_axis_units(E_AXIS);
@ -7384,23 +7409,66 @@ inline void gcode_M503() {
disable_e3();
delay(100);
#if HAS_BUZZER
millis_t next_buzz = 0;
#endif
millis_t nozzle_timeout = millis() + FILAMENT_CHANGE_NOZZLE_TIMEOUT*1000L;
bool nozzle_timed_out = false;
float temps[4];
int iii;
// Wait for filament insert by user and press button
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
// LCD click or M108 will clear this
wait_for_user = true;
idle();
wait_for_user = true; // LCD click or M108 will clear this
next_buzz = 0;
runout_beep = 0;
for( iii=0; iii<HOTENDS; iii++) //Save nozzle temps
temps[iii] = thermalManager.target_temperature[iii];
while (wait_for_user) {
#if HAS_BUZZER
millis_t ms = millis();
if (ms >= next_buzz) {
BUZZ(300, 2000);
next_buzz = ms + 2500; // Beep every 2.5s while waiting
millis_t current_ms = millis();
if (nozzle_timed_out == true)
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
#if HAS_BUZZER
filament_change_beep();
#endif //HAS_BUZZER
if (current_ms >= nozzle_timeout) {
if (nozzle_timed_out == false ) {
nozzle_timed_out = true; // if the nozzle time out happens, remember we turned off the nozzles.
for( iii=0; iii<HOTENDS; iii++) // turn off all the nozzles
thermalManager.setTargetHotend( 0.0 , iii );
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
}
}
idle(true);
}
if (nozzle_timed_out == true ) { // Turn nozzles back on if we turned them off.
for( iii=0; iii<HOTENDS; iii++)
thermalManager.setTargetHotend( temps[iii] , iii );
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT);
}
KEEP_CHECKING_TEMPS:
idle();
for( iii=0; iii<HOTENDS; iii++){
if (abs(thermalManager.degHotend(iii)-temps[iii]) > 3 ) {
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT);
goto KEEP_CHECKING_TEMPS;
}
}
wait_for_user = true; // LCD click or M108 will clear this
next_buzz = 0;
runout_beep = 0;
while (wait_for_user) {
if (nozzle_timed_out == true)
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
else break;
#if HAS_BUZZER
filament_change_beep();
#endif
idle(true);
}
@ -7408,6 +7476,8 @@ inline void gcode_M503() {
// Show load message
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD);
idle();
// 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
@ -7459,6 +7529,7 @@ inline void gcode_M503() {
// Show status screen
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_STATUS);
busy_doing_M600 = false; // Allow Stepper Motors to be turned off during inactivity
}
#endif // FILAMENT_CHANGE_FEATURE
@ -10073,7 +10144,13 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
millis_t ms = millis();
if (max_inactive_time && ELAPSED(ms, previous_cmd_ms + max_inactive_time)) kill(PSTR(MSG_KILLED));
#if ENABLED(FILAMENT_CHANGE_FEATURE)
#ifdef STEPPER_MOTORS_DONT_TIMEOUT_DURING_FILAMENT_CHANGE
if (busy_doing_M600 == false ) // We only allow the stepper motors to time out if
#endif // we are not in the middle of an M600 command.
#endif
if (stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time)
&& !ignore_stepper_queue && !planner.blocks_queued()) {
#if ENABLED(DISABLE_INACTIVE_X)